本文整理汇总了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++;
}
}
示例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.");
}
}
示例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;
}
示例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);
}
示例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.");
}
}
示例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.");
}
}
示例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());
}
示例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);
}
示例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.");
}
}
示例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());
}
}
示例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());
}
示例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.");
}
}
示例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());
}
示例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;
}
示例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);
}
}