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


Java WikiPageNotFoundException类代码示例

本文整理汇总了Java中de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java WikiPageNotFoundException类的具体用法?Java WikiPageNotFoundException怎么用?Java WikiPageNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WikiPageNotFoundException类属于de.tudarmstadt.ukp.wikipedia.api.exception包,在下文中一共展示了WikiPageNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RevisionBasedTalkPageExtractor

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Creates a new TalkPageExtractor that segments a collection of discussion pages into threads and turns
 * 
 * @param wiki the JWPL Wikipedia object with an active database connection
 * @param revApi the JWPL RevisionApi object with an active database connection
 * @param pageTitles a collection of page or talk page ttiles
 * @param includeArchives true, if the extractor should attempt to extract discussions from discussion archives (still buggy)
 * @param aggregateParagraphsToTurns true, whether paragraphs should heuristically be aggregated to turns
 * @throws WikiInitializationException in case the database connection could not be established
 * @throws WikiApiException in case the database could not be accessed
 */
public RevisionBasedTalkPageExtractor(Wikipedia wiki, RevisionApi revApi, Collection<String> pageTitles, boolean includeArchives, boolean aggregateParagraphsToTurns) throws WikiInitializationException, WikiApiException{
	this.wiki =wiki;
	this.includeArchives=includeArchives;
	this.aggregateParagraphsToTurns = aggregateParagraphsToTurns;
	this.revApi = revApi;

	sourcePages = new ArrayList<>();
	talkPages=new ArrayList<>();
	logger.trace("Loading "+pageTitles.size()+" pages....");
	for(String title:pageTitles){
		try{
			sourcePages.add(wiki.getPage(title));
		}catch(WikiPageNotFoundException e){
			logger.warn("Could not find article "+title);
		}
	}
	logger.trace("done.");
	loadTalkPages();
	
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:32,代码来源:RevisionBasedTalkPageExtractor.java

示例2: getCategoryArticleMap

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Building a mapping from categories to article sets.
 * @parm pWiki The wikipedia object.
 * @param pNodes The category nodes that should be used to build the map.
 * @return A mapping from categories to article sets.
 * @throws WikiPageNotFoundException
 */
private Map<Integer,Set<Integer>> getCategoryArticleMap(Wikipedia pWiki, Set<Integer> pNodes) throws WikiPageNotFoundException {
    Map<Integer,Set<Integer>> categoryArticleMap = new HashMap<Integer,Set<Integer>>();

    int progress = 0;
    for (int node : pNodes) {
        progress++;
        ApiUtilities.printProgressInfo(progress, pNodes.size(), 10, ApiUtilities.ProgressInfoMode.TEXT, "Getting category-article map.");

        Category cat = pWiki.getCategory(node);
        if (cat != null) {
            Set<Integer> pages = new HashSet<Integer>(cat.__getPages());
            categoryArticleMap.put(node, pages);
        }
        else {
            logger.info(node + " is not a category.");
        }
    }

    return categoryArticleMap;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:28,代码来源:WikipediaInfo.java

示例3: getPageIds

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Gets the page ids for a given title.<br>
 *
 *
 * @param title The title of the page.
 * @return The id for the page with the given title.
 * @throws WikiApiException
 */
public List<Integer> getPageIds(String title) throws WikiApiException {
	Session session = this.__getHibernateSession();
    session.beginTransaction();
    Iterator results = session.createQuery(
    "select p.pageID from PageMapLine as p where p.name = :pName").setParameter("pName", title, StringType.INSTANCE).list().iterator();

    session.getTransaction().commit();

    if(!results.hasNext()){
    	throw new WikiPageNotFoundException();
    }
    List<Integer> resultList = new LinkedList<Integer>();
    while(results.hasNext()){
    	resultList.add((Integer)results.next());
    }
    return resultList;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:26,代码来源:Wikipedia.java

示例4: getPageIdsCaseInsensitive

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Gets the page ids for a given title with case insensitive matching.<br>
 *
 *
 * @param title The title of the page.
 * @return The ids of the pages with the given title.
 * @throws WikiApiException
 */
public List<Integer> getPageIdsCaseInsensitive(String title) throws WikiApiException {
    title = title.toLowerCase();
    title = title.replaceAll(" ", "_");

    Session session = this.__getHibernateSession();
    session.beginTransaction();
    Iterator results = session.createQuery(
    "select p.pageID from PageMapLine as p where lower(p.name) = :pName").setParameter("pName", title, StringType.INSTANCE).list().iterator();

    session.getTransaction().commit();

    if(!results.hasNext()){
        throw new WikiPageNotFoundException();
    }
    List<Integer> resultList = new LinkedList<Integer>();
    while(results.hasNext()){
        resultList.add((Integer)results.next());
    }
    return resultList;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:29,代码来源:Wikipedia.java

示例5: createCategory

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * @see de.tudarmstadt.ukp.wikipedia.api.Category#Category(Wikipedia, String)
 */
private void createCategory(Title title) throws WikiPageNotFoundException {
    String name = title.getWikiStyleTitle();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();

    Object returnValue;
    returnValue = session.createNativeQuery(
            "select cat.pageId from Category as cat where cat.name = :name COLLATE utf8_bin")
            .setParameter("name", name, StringType.INSTANCE)
            .uniqueResult();
    session.getTransaction().commit();

    // if there is no category with this name, the hibernateCategory is null
    if (returnValue == null) {
        hibernateCategory = null;
        throw new WikiPageNotFoundException("No category with name " + name + " was found.");
    }
    else {
        // now cast it into an integer
        int pageID = (Integer) returnValue;
        createCategory( pageID);
    }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:27,代码来源:Category.java

示例6: getPageIds

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Gets the page ids for a given title.<br/>
 *
 *
 * @param title The title of the page.
 * @return The id for the page with the given title.
 * @throws WikiApiException
 */
public List<Integer> getPageIds(String title) throws WikiApiException {
	Session session = this.__getHibernateSession();
    session.beginTransaction();
    Iterator results = session.createQuery(
    "select p.pageID from PageMapLine as p where p.name = :pName").setString("pName", title).list().iterator();

    session.getTransaction().commit();

    if(!results.hasNext()){
    	throw new WikiPageNotFoundException();
    }
    List<Integer> resultList = new LinkedList<Integer>();
    while(results.hasNext()){
    	resultList.add((Integer)results.next());
    }
    return resultList;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:26,代码来源:Wikipedia.java

示例7: createCategory

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * @see de.tudarmstadt.ukp.wikipedia.api.Category#Category(Wikipedia, String)
 */
private void createCategory(Title title) throws WikiPageNotFoundException {
    String name = title.getWikiStyleTitle();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();

    Object returnValue;
    returnValue = session.createSQLQuery(
            "select cat.pageId from Category as cat where cat.name = :name COLLATE utf8_bin")
            .setString("name", name)
            .uniqueResult();
    session.getTransaction().commit();

    // if there is no category with this name, the hibernateCategory is null
    if (returnValue == null) {
        hibernateCategory = null;
        throw new WikiPageNotFoundException("No category with name " + name + " was found.");
    }
    else {
        // now cast it into an integer
        int pageID = (Integer) returnValue;
        createCategory( pageID);
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:27,代码来源:Category.java

示例8: Page

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Creates a page object.
 *
 * @param wiki
 *            The wikipedia object.
 * @param pName
 *            The name of the page.
 * @param useExactTitle
 *            Whether to use the exact title or try to guess the correct wiki-style title.
 * @throws WikiApiException
 */
public Page(Wikipedia wiki, String pName, boolean useExactTitle)
    throws WikiApiException
{
    if (pName == null || pName.length() == 0) {
        throw new WikiPageNotFoundException();
    }
    this.wiki = wiki;
    this.pageDAO = new PageDAO(wiki);
    Title pageTitle = new Title(pName);
    fetchByTitle(pageTitle, useExactTitle);
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:23,代码来源:Page.java

示例9: fetchByHibernateId

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * @throws WikiApiException
 * @see de.tudarmstadt.ukp.wikipedia.api.Page#Page(long)
 */
private void fetchByHibernateId(long id)
	throws WikiApiException
{
       Session session = this.wiki.__getHibernateSession();
       session.beginTransaction();
       hibernatePage = pageDAO.findById(id);
       session.getTransaction().commit();

       if (hibernatePage == null) {
           throw new WikiPageNotFoundException("No page with id " + id + " was found.");
       }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:17,代码来源:Page.java

示例10: fetchByPageId

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
private void fetchByPageId(int pageID)
	throws WikiApiException
{
       Session session = this.wiki.__getHibernateSession();
       session.beginTransaction();
	hibernatePage = (de.tudarmstadt.ukp.wikipedia.api.hibernate.Page) session
			.createQuery("from Page where pageId = :id").setParameter("id", pageID, IntegerType.INSTANCE).uniqueResult();
       session.getTransaction().commit();

       if (hibernatePage == null) {
           throw new WikiPageNotFoundException("No page with page id " + pageID + " was found.");
       }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:14,代码来源:Page.java

示例11: getArticlesWithOverlappingCategories

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Articles in wikipedia may be tagged with multiple categories.
 * It may be interesting to know how many articles have at least one category in common.
 * Such articles would have a very high semantic relatedness even if they share a quite secondary category.
 * @param pWiki The wikipedia object.
 * @param pGraph The category graph.
 * @return The number of articles that have at least one category in common.
 * @throws WikiPageNotFoundException
 */
private int getArticlesWithOverlappingCategories(Wikipedia pWiki, CategoryGraph pGraph) throws WikiPageNotFoundException {
    Set<Integer> overlappingArticles = new HashSet<Integer>();

    // iterate over all node pairs
    Set<Integer> nodes = pGraph.getGraph().vertexSet();

    Map<Integer,Set<Integer>> categoryArticleMap = getCategoryArticleMap(pWiki, nodes);

    // sort the Array so we can use a simple iteration with two for loops to access all pairs
    Object[] nodeArray = nodes.toArray();
    Arrays.sort(nodeArray);

    int progress = 0;
    for (int i=0; i<nodes.size(); i++) {
        progress++;
        ApiUtilities.printProgressInfo(progress, nodes.size(), 100, ApiUtilities.ProgressInfoMode.TEXT, "");

        int outerNode = (Integer) nodeArray[i];

        for (int j=i+1; j<nodes.size(); j++) {
            int innerNode = (Integer) nodeArray[j];

            // test whether the categories have pages in common
            Set<Integer> outerPages = categoryArticleMap.get(outerNode);
            Set<Integer> innerPages = categoryArticleMap.get(innerNode);

            for (int outerPage : outerPages) {
                if (innerPages.contains(outerPage)) {
                    if (!overlappingArticles.contains(outerPage)) {
                        overlappingArticles.add(outerPage);
                    }
                }
            }

        }
    }

    return overlappingArticles.size();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:49,代码来源:WikipediaInfo.java

示例12: getTitle

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Gets the title for a given pageId.
 *
 * @param pageId The id of the page.
 * @return The title for the given pageId.
 * @throws WikiApiException
 */
public Title getTitle(int pageId) throws WikiApiException {
	Session session = this.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery(
        "select p.name from PageMapLine as p where p.id = :pId").setParameter("pId", pageId, IntegerType.INSTANCE).uniqueResult();
    session.getTransaction().commit();

    String title = (String)returnValue;
    if(title==null){
    	throw new WikiPageNotFoundException();
    }
    return new Title(title);
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:21,代码来源:Wikipedia.java

示例13: getCategory

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Gets the category for a given pageId.
 * @param pageId The id of the category.
 * @return The category object or null if no category with this pageId exists.
 */
public Category getCategory(int pageId) {
    long hibernateId = __getCategoryHibernateId(pageId);
    if (hibernateId == -1) {
        return null;
    }

    try {
        Category cat = new Category(this, hibernateId);
        return cat;
    } catch (WikiPageNotFoundException e) {
        return null;
    }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:19,代码来源:Wikipedia.java

示例14: Category

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * Creates a category object.
 * @param wiki The wikipedia object.
 * @param pName The name of the category.
 * @throws WikiPageNotFoundException If the category does not exist.
 */
public Category(Wikipedia wiki, String pName) throws WikiApiException {
    if (pName == null || pName.length() == 0) {
        throw new WikiPageNotFoundException();
    }
    this.wiki = wiki;
    catDAO = new CategoryDAO(wiki);
    Title catTitle = new Title(pName);
    createCategory(catTitle);
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:16,代码来源:Category.java

示例15: __getPages

import de.tudarmstadt.ukp.wikipedia.api.exception.WikiPageNotFoundException; //导入依赖的package包/类
/**
 * This method exposes implementation details and should not be made public.
 * It is used for performance tuning.
 * @return The set of pages that are categorized under this category.
 * @throws WikiPageNotFoundException
 */
protected Set<Integer> __getPages() throws WikiPageNotFoundException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getPages());
    session.getTransaction().commit();
    return tmpSet;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:15,代码来源:Category.java


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