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


Java Template类代码示例

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


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

示例1: parseTemplate

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
public ResolvedTemplate parseTemplate(Template t, ParsedPage pp) {
	ResolvedTemplate result = new ResolvedTemplate( t );
	result.setPreParseReplacement( ResolvedTemplate.TEMPLATESPACER );
	
	StringBuilder sb = new StringBuilder();
	sb.append(templatePrefix);
	sb.append( t.getName()+parameterDivisor );
	for( String s: t.getParameters()){
		sb.append( s +parameterDivisor );
	}
	sb.delete( sb.length()-parameterDivisor.length(), sb.length() );
	sb.append(templatePostfix);
	result.setPostParseReplacement( sb.toString() );
	
	result.setParsedObject( t );
	return result;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:18,代码来源:ShowTemplateNamesAndParameters.java

示例2: getTemplateNames

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 *
 * Returns the set of names of all templates that are contained in the given
 * article (without duplicates).<br>
 * The names are SQL escaped using StringUtils.sqlEscape
 *
 * @param pageText
 *            the page to get the templates from
 * @return a set of template names (without duplicates)
 */
private Set<String> getTemplateNames(String pageText)
{
	Set<String> names = new HashSet<String>();
	if (!pageText.isEmpty()) {
		try {
			ParsedPage pp = parser.parse(pageText);
			List<Template> templates = pp.getTemplates();
			for (Template t : templates) {
				names.add(StringUtils.sqlEscape(t.getName().toLowerCase()));
			}
		}
		catch (Exception e) {
			// Most likely parsing problems
			e.printStackTrace();
			logger.warn("Problems parsing page");
		}
	}
	return names;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:30,代码来源:WikipediaTemplateInfoGenerator.java

示例3: getTemplateNames

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 *
 * Returns the set of names of all templates that are contained in the given
 * article (without duplicates).<br/>
 * The names are SQL escaped using StringUtils.sqlEscape
 *
 * @param pageText
 *            the page to get the templates from
 * @return a set of template names (without duplicates)
 */
private Set<String> getTemplateNames(String pageText)
{
	Set<String> names = new HashSet<String>();
	if (!pageText.isEmpty()) {
		try {
			ParsedPage pp = parser.parse(pageText);
			List<Template> templates = pp.getTemplates();
			for (Template t : templates) {
				names.add(StringUtils.sqlEscape(t.getName().toLowerCase()));
			}
		}
		catch (Exception e) {
			// Most likely parsing problems
			e.printStackTrace();
			logger.warn("Problems parsing page");
		}
	}
	return names;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:30,代码来源:WikipediaTemplateInfoGenerator.java

示例4: parseTemplate

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
public ResolvedTemplate parseTemplate(Template t, ParsedPage pp) {
	ResolvedTemplate result = new ResolvedTemplate( t );
	result.setPreParseReplacement( ResolvedTemplate.TEMPLATESPACER );
	result.setPostParseReplacement( "" );
	result.setParsedObject( null );
	return result;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:8,代码来源:FlushTemplates.java

示例5: templateToHtml

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 * Generates HTML Output for a Template.
 */
private static String templateToHtml( Template t){
	if( t == null ) {
		return "null";
	}

	StringBuilder result = new StringBuilder();

	result.append(
		"<table class=\"Template\">\n" +
		"<tr><th class=\"Template\">Template</th></tr>\n"+
		"<tr><td class=\"Template\">" +
		"Name: \""+convertTags( t.getName() )+"\"<br>"+
		"</td></tr>\n");

	if( t.getParameters().size() != 0 ){
		result.append("<tr><td class=\"Template\">");
		for( String parameter: t.getParameters() ) {
			result.append("Parameter: \""+convertTags( parameter )+"\"<br>");
		}
		result.append("</td></tr>\n");
	}

	result.append("</table>" );

	return result.toString();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:30,代码来源:HtmlWriter.java

示例6: templateToHtml

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 * Generates HTML Output for a Template.
 */
private static String templateToHtml( Template t){
	if( t == null ) {
		return "null";
	}

	StringBuilder result = new StringBuilder();

	result.append(
		"<table class=\"Template\">\n" +
		"<tr><th class=\"Template\">Template</th></tr>\n"+
		"<tr><td class=\"Template\">" +
		"Name: \""+convertTags( t.getName() )+"\"<br/>"+
		"</td></tr>\n");

	if( t.getParameters().size() != 0 ){
		result.append("<tr><td class=\"Template\">");
		for( String parameter: t.getParameters() ) {
			result.append("Parameter: \""+convertTags( parameter )+"\"<br/>");
		}
		result.append("</td></tr>\n");
	}

	result.append("</table>" );

	return result.toString();
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:30,代码来源:HtmlWriter.java

示例7: ResolvedTemplate

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 * Creates a new ResolvedTemplate linked to the original template.
 * @param template the original template
 */
public ResolvedTemplate(Template template){
	this.template = template;
	this.postParseReplacement = "";
	checkPreParseReplacement();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:10,代码来源:ResolvedTemplate.java

示例8: parseTemplate

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 * Takes a Template and do whatever is required for handling this Template.
 * It is possible to delete this template, to parse it to e.g a Link or
 * to return MediaWiki code which can be parsed by a MediaWiki parser.<br>
 * If you are interested how this works, you shoud read the documentation
 * of ResolvedTemplate.
 */
public ResolvedTemplate parseTemplate(Template t, ParsedPage pp);
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:9,代码来源:MediaWikiTemplateParser.java

示例9: getTemplate

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 * In case of an Error the Parser will use the Original Template
 * as parsed object.
 */
public Template getTemplate() {
	return template;
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:8,代码来源:ResolvedTemplate.java

示例10: parseTemplate

import de.tudarmstadt.ukp.wikipedia.parser.Template; //导入依赖的package包/类
/**
 * Takes a Template and do whatever is required for handling this Template.
 * It is possible to delete this template, to parse it to e.g a Link or 
 * to return MediaWiki code which can be parsed by a MediaWiki parser.<br/>
 * If you are interested how this works, you shoud read the documentation 
 * of ResolvedTemplate.
 */
public ResolvedTemplate parseTemplate(Template t, ParsedPage pp);
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:9,代码来源:MediaWikiTemplateParser.java


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