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


Java Language类代码示例

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


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


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