本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}