本文整理汇总了Java中de.tudarmstadt.ukp.wikipedia.api.Category类的典型用法代码示例。如果您正苦于以下问题:Java Category类的具体用法?Java Category怎么用?Java Category使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Category类属于de.tudarmstadt.ukp.wikipedia.api包,在下文中一共展示了Category类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import de.tudarmstadt.ukp.wikipedia.api.Category; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {
// configure the database connection parameters
DatabaseConfiguration dbConfig = new DatabaseConfiguration();
dbConfig.setHost("SERVER_URL");
dbConfig.setDatabase("DATABASE");
dbConfig.setUser("USER");
dbConfig.setPassword("PASSWORD");
dbConfig.setLanguage(Language.german);
// Create a new German wikipedia.
Wikipedia wiki = new Wikipedia(dbConfig);
String title = "Hello world";
Page page;
try {
page = wiki.getPage(title);
} catch (WikiPageNotFoundException e) {
throw new WikiApiException("Page " + title + " does not exist");
}
StringBuilder sb = new StringBuilder();
// the title of the page
sb.append("Queried string : " + title + LF);
sb.append("Title : " + page.getTitle() + LF);
sb.append(LF);
// output the page's redirects
sb.append("Redirects" + LF);
for (String redirect : page.getRedirects()) {
sb.append(" " + new Title(redirect).getPlainTitle() + LF);
}
sb.append(LF);
// output the page's categories
sb.append("Categories" + LF);
for (Category category : page.getCategories()) {
sb.append(" " + category.getTitle() + LF);
}
sb.append(LF);
// output the ingoing links
sb.append("In-Links" + LF);
for (Page inLinkPage : page.getInlinks()) {
sb.append(" " + inLinkPage.getTitle() + LF);
}
sb.append(LF);
// output the outgoing links
sb.append("Out-Links" + LF);
for (Page outLinkPage : page.getOutlinks()) {
sb.append(" " + outLinkPage.getTitle() + LF);
}
System.out.println(sb);
}
示例2: main
import de.tudarmstadt.ukp.wikipedia.api.Category; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {
// configure the database connection parameters
DatabaseConfiguration dbConfig = new DatabaseConfiguration();
dbConfig.setHost("SERVER_URL");
dbConfig.setDatabase("DATABASE");
dbConfig.setUser("USER");
dbConfig.setPassword("PASSWORD");
dbConfig.setLanguage(Language.german);
// Create a new German wikipedia.
Wikipedia wiki = new Wikipedia(dbConfig);
// Get the category "Säugetiere" (mammals)
String title = "Säugetiere";
Category cat;
try {
cat = wiki.getCategory(title);
} catch (WikiPageNotFoundException e) {
throw new WikiApiException("Category " + title + " does not exist");
}
StringBuilder sb = new StringBuilder();
// the title of the category
sb.append("Title : " + cat.getTitle() + LF);
sb.append(LF);
// the number of links pointing to this page (number of superordinate categories)
sb.append("# super categories : " + cat.getParents().size() + LF);
for (Category parent : cat.getParents()) {
sb.append(" " + parent.getTitle() + LF);
}
sb.append(LF);
// the number of links in this page pointing to other pages (number of subordinate categories)
sb.append("# sub categories : " + cat.getChildren().size() + LF);
for (Category child : cat.getChildren()) {
sb.append(" " + child.getTitle() + LF);
}
sb.append(LF);
// the number of pages that are categorized under this category
sb.append("# pages : " + cat.getArticles().size() + LF);
for (Page page : cat.getArticles()) {
sb.append(" " + page.getTitle() + LF);
}
// extract only the pageIDs of pages that are categorized under this category
sb.append("# pageIDs : " + cat.getArticleIds().size() + LF);
for (int pageID : cat.getArticleIds()) {
sb.append(" " + pageID + LF);
}
System.out.println(sb);
}
示例3: getRelationType
import de.tudarmstadt.ukp.wikipedia.api.Category; //导入依赖的package包/类
public RelationType getRelationType() {
return RelationType.Category;
}
示例4: main
import de.tudarmstadt.ukp.wikipedia.api.Category; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {
// configure the database connection parameters
DatabaseConfiguration dbConfig = new DatabaseConfiguration();
dbConfig.setHost("SERVER_URL");
dbConfig.setDatabase("DATABASE");
dbConfig.setUser("USER");
dbConfig.setPassword("PASSWORD");
dbConfig.setLanguage(Language.german);
// Create a new German wikipedia.
Wikipedia wiki = new Wikipedia(dbConfig);
String title = "Hello world";
Page page;
try {
page = wiki.getPage(title);
} catch (WikiPageNotFoundException e) {
throw new WikiApiException("Page " + title + " does not exist");
}
StringBuilder sb = new StringBuilder();
// the title of the page
sb.append("Queried string : " + title + LF);
sb.append("Title : " + page.getTitle() + LF);
sb.append(LF);
// output the page's redirects
sb.append("Redirects" + LF);
for (String redirect : page.getRedirects()) {
sb.append(" " + new Title(redirect).getPlainTitle() + LF);
}
sb.append(LF);
// output the page's categories
sb.append("Categories" + LF);
for (Category category : page.getCategories()) {
sb.append(" " + category.getTitle() + LF);
}
sb.append(LF);
// output the ingoing links
sb.append("In-Links" + LF);
for (Page inLinkPage : page.getInlinks()) {
sb.append(" " + inLinkPage.getTitle() + LF);
}
sb.append(LF);
// output the outgoing links
sb.append("Out-Links" + LF);
for (Page outLinkPage : page.getOutlinks()) {
sb.append(" " + outLinkPage.getTitle() + LF);
}
System.out.println(sb);
}
示例5: main
import de.tudarmstadt.ukp.wikipedia.api.Category; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {
// configure the database connection parameters
DatabaseConfiguration dbConfig = new DatabaseConfiguration();
dbConfig.setHost("SERVER_URL");
dbConfig.setDatabase("DATABASE");
dbConfig.setUser("USER");
dbConfig.setPassword("PASSWORD");
dbConfig.setLanguage(Language.german);
// Create a new German wikipedia.
Wikipedia wiki = new Wikipedia(dbConfig);
// Get the category "Säugetiere" (mammals)
String title = "Säugetiere";
Category cat;
try {
cat = wiki.getCategory(title);
} catch (WikiPageNotFoundException e) {
throw new WikiApiException("Category " + title + " does not exist");
}
StringBuilder sb = new StringBuilder();
// the title of the category
sb.append("Title : " + cat.getTitle() + LF);
sb.append(LF);
// the number of links pointing to this page (number of superordinate categories)
sb.append("# super categories : " + cat.getParents().size() + LF);
for (Category parent : cat.getParents()) {
sb.append(" " + parent.getTitle() + LF);
}
sb.append(LF);
// the number of links in this page pointing to other pages (number of subordinate categories)
sb.append("# sub categories : " + cat.getChildren().size() + LF);
for (Category child : cat.getChildren()) {
sb.append(" " + child.getTitle() + LF);
}
sb.append(LF);
// the number of pages that are categorized under this category
sb.append("# pages : " + cat.getArticles().size() + LF);
for (Page page : cat.getArticles()) {
sb.append(" " + page.getTitle() + LF);
}
// extract only the pageIDs of pages that are categorized under this category
sb.append("# pageIDs : " + cat.getArticleIds().size() + LF);
for (int pageID : cat.getArticleIds()) {
sb.append(" " + pageID + LF);
}
System.out.println(sb);
}