• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Language类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {

		//db connection settings
		DatabaseConfiguration dbConfig = new DatabaseConfiguration();
	    dbConfig.setDatabase("DATABASE");
	    dbConfig.setHost("HOST");
	    dbConfig.setUser("USER");
	    dbConfig.setPassword("PASSWORD");
	    dbConfig.setLanguage(Language.english);

		//initialize a wiki
		Wikipedia wiki = new Wikipedia(dbConfig);

        MediaWikiParserFactory pf = new MediaWikiParserFactory(Language.english);
        MediaWikiParser parser = pf.createParser();

		//get the page 'House_(disambiguation)'
		ParsedPage pp = parser.parse(wiki.getPage("House_(disambiguation)").getText());

		int i = 1;
		// print out all nested lists of the page
		for(NestedList nl : pp.getNestedLists()){
			System.out.println(i + ": \n" + outputNestedList(nl,0));
			i++;
		}
	}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:27,代码来源:T6_NestedLists.java


示例2: setupWikipedia

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
    * Made this static so that following tests don't run if assumption fails.
    * (With AT_Before, tests also would not be executed but marked as passed)
    * This could be changed back as soon as JUnit ignored tests after failed
    * assumptions
 */
@BeforeClass
public static void setupWikipedia() {
	DatabaseConfiguration db = new DatabaseConfiguration();
	db.setDatabase("wikiapi_test");
	db.setHost("bender.ukp.informatik.tu-darmstadt.de");
	db.setUser("student");
	db.setPassword("student");
	db.setLanguage(Language._test);
	try {
		wiki = new Wikipedia(db);
	} catch (Exception e) {
		Assume.assumeNoException(e);
		//fail("Wikipedia could not be initialized.");
	}
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:22,代码来源:ParsedPageTest.java


示例3: getUniqueArticleTitles

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public static Set<String> getUniqueArticleTitles() throws WikiInitializationException {
    // 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);

    Set<String> uniqueArticleTitles = new TreeSet<String>();
    for (Title title : wiki.getTitles()) {
        uniqueArticleTitles.add(title.getPlainTitle());
    }

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


示例4: main

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	DatabaseConfiguration db = new DatabaseConfiguration();
	db.setDatabase("wikiapi_uk");
	db.setHost("bender.ukp.informatik.tu-darmstadt.de");
	db.setUser("student");
	db.setPassword("student");
	db.setLanguage(Language.ukrainian);
	Wikipedia wiki = new Wikipedia(db);
	System.out.println("Test: retrieve 4000 pages ...");
	test(4000, 1, wiki);
	test(4000, 10, wiki);
	test(4000, 50, wiki);
	test(4000, 100, wiki);
	test(4000, 200, wiki);
	test(4000, 500, wiki);
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:17,代码来源:PerformanceTestPageIterator.java


示例5: setupWikipedia

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
    * Made this static so that following tests don't run if assumption fails.
    * (With AT_Before, tests also would not be executed but marked as passed)
    * This could be changed back as soon as JUnit ignored tests after failed
    * assumptions
 */
@BeforeClass
public static void setupWikipedia() {
	DatabaseConfiguration db = new DatabaseConfiguration();
	db.setDatabase("wikiapi_test");
	db.setHost("bender.ukp.informatik.tu-darmstadt.de");
	db.setUser("student");
	db.setPassword("student");
	db.setLanguage(Language._test);
	try {
		wiki = new Wikipedia(db);
	} catch (Exception e) {
		assumeNoException(e);
		//fail("Wikipedia could not be initialized.");
	}
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:22,代码来源:CategoryTest.java


示例6: setupWikipedia

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
    * Made this static so that following tests don't run if assumption fails.
    * (With AT_Before, tests would also not be executed but marked as passed)
 */
@BeforeClass
public static void setupWikipedia() {
	DatabaseConfiguration db = new DatabaseConfiguration();
	db.setDatabase("wikiapi_test");
	db.setHost("bender.ukp.informatik.tu-darmstadt.de");
	db.setUser("student");
	db.setPassword("student");
	db.setLanguage(Language._test);
	try {
		wiki = new Wikipedia(db);
	} catch (Exception e) {
		assumeNoException(e);
		//fail("Wikipedia could not be initialized.");
	}
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:20,代码来源:CategoryDescendantsIteratorTest.java


示例7: setupWikipedia

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Made this static so that following tests don't run if assumption fails.
 * (With AT_Before, tests also would not be executed but marked as passed)
 * This could be changed back as soon as JUnit ignores tests after failed
 * assumptions
 */
@BeforeClass
public static void setupWikipedia()
{
	DatabaseConfiguration db = new DatabaseConfiguration();
	db.setHost("bender.ukp.informatik.tu-darmstadt.de");
	db.setDatabase("wikiapi_simple_20090119");
	db.setUser("student");
	db.setPassword("student");
	db.setLanguage(Language.simple_english);
	try {
		wiki = new Wikipedia(db);
	}
	catch (Exception e) {
		assumeNoException(e);
	}
	Assume.assumeNotNull(wiki);

	config = new RevisionAPIConfiguration();
	config.setHost(db.getHost());
	config.setDatabase(db.getDatabase());
	config.setUser(db.getUser());
	config.setPassword(db.getPassword());
	config.setLanguage(db.getLanguage());
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:31,代码来源:RevisionIteratorTest.java


示例8: setupWikipedia

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Made this static so that following tests don't run if assumption fails.
 * (With AT_Before, tests also would not be executed but marked as passed)
 * This could be changed back as soon as JUnit ignores tests after failed
 * assumptions
 */
@BeforeClass
public static void setupWikipedia()
{
	DatabaseConfiguration db = new DatabaseConfiguration();
	db.setDatabase("wikiapi_simple_20090119");
	db.setHost("bender.ukp.informatik.tu-darmstadt.de");
	db.setUser("student");
	db.setPassword("student");
	db.setLanguage(Language.simple_english);
	try {
		wiki = new Wikipedia(db);
	}
	catch (Exception e) {
		assumeNoException(e);
	}
	Assume.assumeNotNull(wiki);
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:24,代码来源:RevisionApiTest.java


示例9: MediaWikiParserFactory

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Creates a fully configurated parser factory for the specified language.<br/>
 * Next step is .createParser()...
 */
public MediaWikiParserFactory(Language language){
       initVariables();
       if (language.equals(Language.german)) {
           initGermanVariables();
       }
       else if(language.equals(Language.english)){
       	initEnglishVariables();
       }
       else if(language.equals(Language.french)){
       	try {
			initFrenchVariables();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			System.err.println("Erreur dans la lecture d'un fichier de configuration");
			e.printStackTrace();
		}
       }
       
       else{
       	logger.warn("No language specific parser for "+language.toString()+" available. Using default values.");
       }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:27,代码来源:MediaWikiParserFactory.java


示例10: main

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {
	//db connection settings
	DatabaseConfiguration dbConfig = new DatabaseConfiguration();
       dbConfig.setDatabase("DATABASE");
       dbConfig.setHost("HOST");
       dbConfig.setUser("USER");
       dbConfig.setPassword("PASSWORD");
       dbConfig.setLanguage(Language.english);
	
	//initialize a wiki
	Wikipedia wiki = new Wikipedia(dbConfig);
	
	//get the page 'Dog'
	Page p = wiki.getPage("Dog");
	
	//get a ParsedPage object
	MediaWikiParserFactory pf = new MediaWikiParserFactory();
	MediaWikiParser parser = pf.createParser();
	ParsedPage pp = parser.parse(p.getText());

	//get the sections of the page
	List<Section> sections = pp.getSections();
	
	for(Section section : sections) {
           System.out.println(section.getTitle());
       }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:28,代码来源:T4_InterfacingWithWikipedia.java


示例11: main

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {

		//db connection settings
		DatabaseConfiguration dbConfig = new DatabaseConfiguration();
	    dbConfig.setDatabase("DATABASE");
	    dbConfig.setHost("HOST");
	    dbConfig.setUser("USER");
	    dbConfig.setPassword("PASSWORD");
	    dbConfig.setLanguage(Language.english);

		//initialize a wiki
		Wikipedia wiki = new Wikipedia(dbConfig);
		
		//get the page 'Dog'
		Page p = wiki.getPage("Dog");
		
		//get a ParsedPage object
		MediaWikiParserFactory pf = new MediaWikiParserFactory();
		pf.setTemplateParserClass(FlushTemplates.class); // Filtering TEMPLATE-Elements
		
		String IMAGE = "Image"; // Replace it with the image template name in your Wiki language edition,
								// e.g. "Image" in English
		
		// filtering Image-Elements
		pf.getImageIdentifers().add(IMAGE);	
		
		// parse page text
		MediaWikiParser parser = pf.createParser();
		ParsedPage pp = parser.parse(p.getText());
		
		System.out.println(pp.getText());	
	}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:33,代码来源:T5_CleaningTemplateImage.java


示例12: MediaWikiParserFactory

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Creates a fully configurated parser factory for the specified language.<br>
 * Next step is .createParser()...
 */
public MediaWikiParserFactory(Language language){
       initVariables();
       if (language.equals(Language.german)) {
           initGermanVariables();
       }
       else if(language.equals(Language.english)){
       	initEnglishVariables();
       }else
       {
       	logger.warn("No language specific parser for "+language.toString()+" available. Using default values.");
       }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:17,代码来源:MediaWikiParserFactory.java


示例13: testParsedPage

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
@Test
public void testParsedPage(){
       String title = "Wikipedia API";
       Page p = null;
       try {
           p = wiki.getPage(title);
       } catch (WikiApiException e) {
           e.printStackTrace();
           fail("A WikiApiException occured while getting the page " + title);
       }

       String LF = "\n";
       String text = "Wikipedia API ist die wichtigste Software überhaupt." + LF +
       	"Wikipedia API. Nicht zu übertreffen. Unglaublich http://www.ukp.tu-darmstadt.de en:Wikipedia API";


       MediaWikiParserFactory pf = new MediaWikiParserFactory(Language.english);
       MediaWikiParser parser = pf.createParser();

	ParsedPage pp = parser.parse(p.getText());


       int i=0;
       for (Link link : pp.getSection(0).getLinks()) {
           if (i==0) {
               assertEquals("Software", link.getText());
           }
           else if (i==1) {
               assertEquals("Wikipedia API", link.getText());
               assertEquals("JWPL", link.getTarget());
           }
           i++;
       }
       assertEquals(text, pp.getText());
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:36,代码来源:ParsedPageTest.java


示例14: DatabaseConfiguration

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public DatabaseConfiguration(String host, String database, String user, String password, Language language) {
    this.host = host;
    this.database = database;
    this.user = user;
    this.password = password;
    this.language = language;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:8,代码来源:DatabaseConfiguration.java


示例15: initializeWikipedia

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Creates a Wikipedia object.
 * Made this static so that following tests don't run if assumption fails.
 * (With AT_Before, tests would also not be executed but marked as passed)
 */
@BeforeClass
public static void initializeWikipedia(){
    DatabaseConfiguration dbConfig = new DatabaseConfiguration();
    dbConfig.setDatabase("wikiapi_test");
    dbConfig.setHost("bender.ukp.informatik.tu-darmstadt.de");
    dbConfig.setLanguage(Language._test);
    dbConfig.setPassword("student");
    dbConfig.setUser("student");
    try{
    	wiki = new Wikipedia(dbConfig);
    }catch(Exception e){
    	assumeNoException(e);
    }
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:20,代码来源:GraphSerializationTest.java


示例16: MediaWikiParserFactory

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Creates a fully configurated parser factory for the specified language.<br/>
 * Next step is .createParser()...
 */
public MediaWikiParserFactory(Language language){
       initVariables();
       if (language.equals(Language.german)) {
           initGermanVariables();
       }
       else if(language.equals(Language.english)){
       	initEnglishVariables();
       }else
       {
       	logger.warn("No language specific parser for "+language.toString()+" available. Using default values.");
       }
}
 
开发者ID:naveenmadhire,项目名称:json-wikipedia-dbspotlight,代码行数:17,代码来源:MediaWikiParserFactory.java


示例17: main

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public static void main(String[] args) throws WikiApiException {

		//db connection settings
		DatabaseConfiguration dbConfig = new DatabaseConfiguration();
	    dbConfig.setDatabase("DATABASE");
	    dbConfig.setHost("HOST");
	    dbConfig.setUser("USER");
	    dbConfig.setPassword("PASSWORD");
	    dbConfig.setLanguage(Language.english);

		//initialize a wiki
		Wikipedia wiki = new Wikipedia(dbConfig);
		
		//get the page 'Dog'
		Page p = wiki.getPage("Dog");
		
		//get a ParsedPage object
		MediaWikiParserFactory pf = new MediaWikiParserFactory(Language.english);
		pf.setTemplateParserClass(FlushTemplates.class); // Filtering TEMPLATE-Elements
		
		String IMAGE = "Image"; // Replace it with the image template name in your Wiki language edition,
								// e.g. "Image" in English
		
		// filtering Image-Elements
		pf.getImageIdentifers().add(IMAGE);	
		
		// parse page text
		MediaWikiParser parser = pf.createParser();
		ParsedPage pp = parser.parse(p.getText()); 
		
		System.out.println(pp.getText());	
	}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:33,代码来源:T5_CleaningTemplateImage.java


示例18: connect

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
public void connect(String bdd_host, String bdd_name, String bdd_user, String bdd_pwd) throws WikiInitializationException{
	// configure the database connection parameters
	dbConfig = new DatabaseConfiguration();
	dbConfig.setHost(bdd_host);
	dbConfig.setDatabase(bdd_name);
	dbConfig.setUser(bdd_user);
	dbConfig.setPassword(bdd_pwd);
	dbConfig.setLanguage(Language.french);
	wiki = new Wikipedia(dbConfig);
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:11,代码来源:Wikipedia_Service.java


示例19: createLuceneWikipediaIndex

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的package包/类
/**
 * Creates a Lucene index from Wikipedia based on lower cased stems with length >=3 containing only characters.
 * 
 * @throws UIMAException
 * @throws IOException
 */
private static void createLuceneWikipediaIndex() throws UIMAException, IOException {
	CollectionReader reader = createCollectionReader(
			ExtendedWikipediaArticleReader.class,
			WikipediaReaderBase.PARAM_HOST, "localhost",
			WikipediaReaderBase.PARAM_DB, "DEWIKI",
			WikipediaReaderBase.PARAM_USER, "root",
			WikipediaReaderBase.PARAM_PASSWORD, "jimmywales",
			WikipediaReaderBase.PARAM_LANGUAGE, Language.german);
	
	AnalysisEngine segmenter = createPrimitive(
			BreakIteratorSegmenter.class,
			BreakIteratorSegmenter.PARAM_LOCALE, Locale.GERMAN);
	
	AnalysisEngine stemmer = createPrimitive(
			SnowballStemmer.class,
			SnowballStemmer.PARAM_LANGUAGE, "de",
			SnowballStemmer.PARAM_LOWER_CASE, true);
	
	AnalysisEngine indexTermGenerator = createPrimitive(
			LuceneIndexer.class,
			LuceneIndexer.PARAM_INDEX_PATH, luceneIndexPath,
			LuceneIndexer.PARAM_MIN_TERMS_PER_DOCUMENT, 50);

	SimplePipeline.runPipeline(reader, segmenter, stemmer, indexTermGenerator);
	
}
 
开发者ID:parzonka,项目名称:esa-indexer,代码行数:33,代码来源:EsaWikipedia.java


示例20: run

import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MailValidation类代码示例发布时间:2022-05-22
下一篇:
Java Architecture类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap