本文整理汇总了Java中de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language.english方法的典型用法代码示例。如果您正苦于以下问题:Java Language.english方法的具体用法?Java Language.english怎么用?Java Language.english使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language
的用法示例。
在下文中一共展示了Language.english方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
示例3: 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());
}
示例4: LinkAnchorExtractor
import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language; //导入方法依赖的package包/类
public LinkAnchorExtractor(){
MediaWikiParserFactory pf = new MediaWikiParserFactory(Language.english);
parser = pf.createParser();
}