当前位置: 首页>>代码示例>>Java>>正文


Java Category类代码示例

本文整理汇总了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);
    }
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:58,代码来源:T3_PageDetails.java

示例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);
    }
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:57,代码来源:T4_Categories.java

示例3: getRelationType

import de.tudarmstadt.ukp.wikipedia.api.Category; //导入依赖的package包/类
public RelationType getRelationType() {
	return RelationType.Category;
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:4,代码来源:CategoryExtractor.java

示例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);
    }
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:58,代码来源:T3_PageDetails.java

示例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);
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:57,代码来源:T4_Categories.java


注:本文中的de.tudarmstadt.ukp.wikipedia.api.Category类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。