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


Java WikiHibernateUtil类代码示例

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


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

示例1: getIdMappingPages

import de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil; //导入依赖的package包/类
/** Hibernate IDs are needed to load an object from the database.
 *  Internal references are via pageIDs.
 * @return A mapping of pageIDs to hibernate IDs.
 */
public Map<Integer, Long> getIdMappingPages() {
    Map<Integer, Long> idMapping = new HashMap<Integer, Long>();

    Session session = WikiHibernateUtil.getSessionFactory(this.dbConfig).getCurrentSession();
    session.beginTransaction();
    Iterator results = session.createQuery("select page.id, page.pageId from Page as page").list().iterator();
    while (results.hasNext()) {
        Object[] row = (Object[]) results.next();
        // put (pageID, id)
        idMapping.put((Integer) row[1], (Long) row[0]);
    }
    session.getTransaction().commit();
    return idMapping;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:19,代码来源:HibernateUtilities.java

示例2: getIdMappingCategories

import de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil; //导入依赖的package包/类
/** Hibernate IDs are needed to load an object from the database.
 *  Internal references are via pageIDs.
 * @return A mapping of pageIDs to hibernate IDs.
 */
public Map<Integer, Long> getIdMappingCategories() {
    Map<Integer, Long> idMapping = new HashMap<Integer, Long>();

    Session session = WikiHibernateUtil.getSessionFactory(this.dbConfig).getCurrentSession();
    session.beginTransaction();
    Iterator results = session.createQuery("select cat.id, cat.pageId from Category as cat").list().iterator();
    while (results.hasNext()) {
        Object[] row = (Object[]) results.next();
        // put (pageID, id)
        idMapping.put((Integer) row[1], (Long) row[0]);
    }
    session.getTransaction().commit();
    return idMapping;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:19,代码来源:HibernateUtilities.java

示例3: getIdMappingPages

import de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil; //导入依赖的package包/类
/** Hibernate IDs are needed to load an object from the database.
 *  Internal references are via pageIDs.
 * @return A mapping of pageIDs to hibernate IDs. 
 */
public Map<Integer, Long> getIdMappingPages() {
    Map<Integer, Long> idMapping = new HashMap<Integer, Long>();
    
    Session session = WikiHibernateUtil.getSessionFactory(this.dbConfig).getCurrentSession();
    session.beginTransaction();
    Iterator results = session.createQuery("select page.id, page.pageId from Page as page").list().iterator();
    while (results.hasNext()) {
        Object[] row = (Object[]) results.next();
        // put (pageID, id)
        idMapping.put((Integer) row[1], (Long) row[0]);
    }
    session.getTransaction().commit();
    return idMapping;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:19,代码来源:HibernateUtilities.java

示例4: getIdMappingCategories

import de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil; //导入依赖的package包/类
/** Hibernate IDs are needed to load an object from the database.
 *  Internal references are via pageIDs.
 * @return A mapping of pageIDs to hibernate IDs. 
 */
public Map<Integer, Long> getIdMappingCategories() {
    Map<Integer, Long> idMapping = new HashMap<Integer, Long>();
    
    Session session = WikiHibernateUtil.getSessionFactory(this.dbConfig).getCurrentSession();
    session.beginTransaction();
    Iterator results = session.createQuery("select cat.id, cat.pageId from Category as cat").list().iterator();
    while (results.hasNext()) {
        Object[] row = (Object[]) results.next();
        // put (pageID, id)
        idMapping.put((Integer) row[1], (Long) row[0]);
    }
    session.getTransaction().commit();
    return idMapping;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:19,代码来源:HibernateUtilities.java

示例5: run

import de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil; //导入依赖的package包/类
@Override
public void run(String... args) throws Exception {
	if(args.length!=8){			
		throw new RuntimeException("Incorrect number of launch parameters.");
	}
	final String discourseName=args[0];		

	final String dataSetName=args[1];		
	if(dataSourceService.dataSourceExists(dataSetName)){
		logger.warn("Dataset "+dataSetName+" has already been imported into DiscourseDB. Existing pages will be skipped.");			
	}
	
	final String titleListFilename=args[2];
	File titleListFile = new File(titleListFilename);
	if(!titleListFile.exists()||!titleListFile.isFile()){
		logger.error("Title list file "+titleListFilename+" cannot be read. Aborting ... ");			
		return;			
	}
	List<String> titles = FileUtils.readLines(titleListFile);

	logger.trace("Establishing connection to Wikipedia db...");
	DatabaseConfiguration dbconf = new DatabaseConfiguration();
	dbconf.setHost(args[3]);
	dbconf.setDatabase(args[4]);
	dbconf.setUser(args[5]);
	dbconf.setPassword(args[6]);
	dbconf.setLanguage(Language.valueOf(args[7]));
	Wikipedia wiki = new Wikipedia(dbconf);
	RevisionApi revApi = new RevisionApi(dbconf);
	
	RevisionBasedTalkPageExtractor extractor = null;
	logger.info("Start mapping Talk pages for "+titles.size()+" articles to DiscourseDB...");		
	int tpNum = 1;
	for(String title:titles){
		//first check if we alrady have the discussions from this article from a previous import
		if(discoursePartService.exists(discourseService.createOrGetDiscourse(discourseName), title, DiscoursePartTypes.TALK_PAGE)){
			logger.warn("Discussions for article "+title+ "have already been imported. Skipping ...");
			continue;			
		}			

		logger.info("Segmenting Talk Pages for article "+title);
		extractor = new RevisionBasedTalkPageExtractor(wiki, revApi, title, false, true);
		List<TalkPage> talkPages = extractor.getTalkPages();
		for(TalkPage tp:talkPages){
			if(tp!=null){
				logger.info("Mapping Talk Page #"+tpNum++);
				converterService.mapTalkPage(discourseName, dataSetName, title, tp);									
			}
		}
	}
	logger.info("Finished mapping Talk pages.");

	//manually close the hibernate session for the Wikipedia connection which is not managed by Spring
	WikiHibernateUtil.getSessionFactory(dbconf).close();
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:56,代码来源:WikipediaTalkPageConverter.java

示例6: __getHibernateSession

import de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil; //导入依赖的package包/类
/**
 * Shortcut for getting a hibernate session.
 * @return
 */
protected Session __getHibernateSession() {
    return WikiHibernateUtil.getSessionFactory(this.dbConfig).getCurrentSession();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:8,代码来源:Wikipedia.java


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