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


Java MediaWikiParserFactory.setTemplateParserClass方法代码示例

本文整理汇总了Java中de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory.setTemplateParserClass方法的典型用法代码示例。如果您正苦于以下问题:Java MediaWikiParserFactory.setTemplateParserClass方法的具体用法?Java MediaWikiParserFactory.setTemplateParserClass怎么用?Java MediaWikiParserFactory.setTemplateParserClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory的用法示例。


在下文中一共展示了MediaWikiParserFactory.setTemplateParserClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory; //导入方法依赖的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

示例2: WikipediaTemplateInfoGenerator

import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory; //导入方法依赖的package包/类
public WikipediaTemplateInfoGenerator(DatabaseConfiguration dbc, int pageBuffer,
		String charset, String outputPath, long maxAllowedPacket,
		TemplateFilter pageFilter, TemplateFilter revisionFilter,
		GeneratorMode mode)
	throws WikiApiException
{
	this.dbConf = dbc;

	this.pageBuffer=pageBuffer;

	MediaWikiParserFactory pf = new MediaWikiParserFactory(
			dbc.getLanguage());
	pf.setTemplateParserClass(ShowTemplateNamesAndParameters.class);
	parser = pf.createParser();

	// this.maxAllowedPacket = maxAllowedPacket;
	this.charset = charset;
	this.outputPath = outputPath;

	// Filters
	this.pageFilter = pageFilter;
	this.revisionFilter = revisionFilter;
	//

	this.mode = mode;

}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:28,代码来源:WikipediaTemplateInfoGenerator.java

示例3: main

import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory; //导入方法依赖的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

示例4: getDocumentFromText

import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory; //导入方法依赖的package包/类
public Document_Lara getDocumentFromText(String path) throws UnsupportedEncodingException, FileNotFoundException{
	
	/**
	 * ParserFactory
	 */
	IO_Service io_service = new IO_Service();
	String wikiText = io_service.readFile(path);
	
	MediaWikiParserFactory parserFactory = new MediaWikiParserFactory(
			Language.french);
	// Add ParserTemplate
	parserFactory.setTemplateParserClass(FrenchTemplateParser.class);
	MediaWikiParser mediawiki_parser = parserFactory.createParser();

	wikiText = preParseWikiText(wikiText);
	ParsedPage parsedpage = mediawiki_parser.parse(wikiText);

	Document_Lara currDocument = new Document_Lara();
	currDocument.setName("mediawiki" + "");
	currListChunk = new ArrayList<Chunk_Lara>();
	
	Chunk_Lara root_Chunk = new Chunk_Lara(0, 0, 0, 0);
	root_Chunk.setType("root");
	root_Chunk.setDepRel("");
	root_Chunk.setDepId(-1);
	root_Chunk.setText("mediawiki");
	currListChunk.add(root_Chunk);

	for (Content currContent : parsedpage.getSections()) {
		runDependencyRecursive(0, currContent);
	}
	
	int index = 0; 
	for (Chunk_Lara currChunk : currListChunk) {
		currChunk.setId(index);
		index++;
	}
	currDocument.setChunk(currListChunk);

	ShiftReduce_Service shiftReduce_Service = new ShiftReduce_Service();
	currDocument = shiftReduce_Service
			.assign_shiftreduce(currDocument, 0);

	return currDocument;
	
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:47,代码来源:Wikipedia_Service.java

示例5: runDependencyBase

import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory; //导入方法依赖的package包/类
public static Document_Lara runDependencyBase(Page page)
		throws WikiTitleParsingException {
	/**
	 * ParserFactory
	 */
	MediaWikiParserFactory parserFactory = new MediaWikiParserFactory(
			Language.french);
	// Add ParserTemplate
	parserFactory.setTemplateParserClass(FrenchTemplateParser.class);
	MediaWikiParser mediawiki_parser = parserFactory.createParser();

	String wikiText = page.getText();
	wikiText = preParseWikiText(wikiText);
	ParsedPage parsedpage = mediawiki_parser.parse(wikiText);

	Document_Lara currDocument = new Document_Lara();
	currDocument.setName(page.getTitle() + "");
	currListChunk = new ArrayList<Chunk_Lara>();
	
	Chunk_Lara root_Chunk = new Chunk_Lara(0, 0, 0, 0);
	root_Chunk.setType("root");
	root_Chunk.setDepRel("");
	root_Chunk.setDepId(-1);
	root_Chunk.setText(page.getTitle()+"");
	currListChunk.add(root_Chunk);

	for (Content currContent : parsedpage.getSections()) {
		runDependencyRecursive(0, currContent);
	}
	int index = 0; 
	for (Chunk_Lara currChunk : currListChunk) {
		currChunk.setId(index);
		index++;
	}

	currDocument.setChunk(currListChunk);

	ShiftReduce_Service shiftReduce_Service = new ShiftReduce_Service();
	currDocument = shiftReduce_Service
			.assign_shiftreduce(currDocument, 0);

	return currDocument;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:44,代码来源:Wikipedia_Service.java


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