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