info.bliki.wiki.model.WikiModel类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中info.bliki.wiki.model.WikiModel类的一些代码示例,展示了WikiModel类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WikiModel类的具体详情如下:
包路径:info.bliki.wiki.model.WikiModel
类名称:WikiModel

WikiModel介绍

[英]Standard model implementation.
[中]

代码示例

代码示例来源:origin: info.bliki.wiki/bliki-core

@Override
public void process(WikiArticle article, Siteinfo siteinfo) throws IOException {
  counter++;
  if (counter >= max_counter) {
    throw new IOException("\nLimit reached after " + max_counter + " entries.");
  }
  String htmlText = "";
  WikiModel wikiModel = new WikiModel("${image}", "${title}");
  try {
    wikiModel.setUp();
    htmlText = wikiModel.render(article.getText(), false);
    if (htmlText == null) {
      System.out.println("An IOException occured!");
    } else {
      System.out.println(htmlText);
    }
  } finally {
    wikiModel.tearDown();
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/wikipediaAPI-multilingual

/**
 * Get the raw wiki text for the given namespace and article name. This model
 * implementation uses a Derby database to cache downloaded wiki template
 * texts.
 * 
 * @param namespace
 *          the namespace of this article
 * @param templateName
 *          the name of the template
 * @param templateParameters
 *          if the namespace is the <b>Template</b> namespace, the current
 *          template parameters are stored as <code>String</code>s in this map
 * 
 * @return <code>null</code> if no content was found
 * 
 * @see info.bliki.api.User#queryContent(String[])
 */
@Override
public String getRawWikiContent(String namespace, String articleName, Map<String, String> templateParameters) {
  String result = super.getRawWikiContent(namespace, articleName, templateParameters);
  if (result != null) {
    // found magic word template
    return result;
  }
  return null;
}

代码示例来源:origin: stackoverflow.com

public String getHTMLFormat() {
  WikiModel wikiModel = new WikiModel(
      "http://en.wikipedia.org/wiki/${image}", "http://en.wikipedia.org/wiki/${title}");
  String htmlText = wikiModel.render(text);
  return htmlText;
}

代码示例来源:origin: info.bliki.wiki/bliki-core

/**
 * Convert a given text in wiki notation into HTML text.
 *
 * @param rawWikiText
 *            a raw wiki text
 * @param resultBuffer
 *            the buffer to which to append the resulting HTML code.
 * @throws IOException
 */
public static void toHtml(String rawWikiText, Appendable resultBuffer)
    throws IOException {
  toText(new WikiModel("/${image}", "/${title}"), new HTMLConverter(),
      rawWikiText, resultBuffer, false, false);
}

代码示例来源:origin: edu.umd/cloud9

public String getDisplayContent() {
 wikiModel.setUp();
 String s = "<h1>" + getTitle() + "</h1>\n" + wikiModel.render(getWikiMarkup());
 wikiModel.tearDown();
 s = DOUBLE_CURLY.matcher(s).replaceAll(" ");
 return s;
}

代码示例来源:origin: yahoo/FEL

e1.printStackTrace();
WikiModel wikiModel = new WikiModel(this.imageBaseURL, this.linkBaseURL);
String plainText = wikiModel.render((ITextConverter)new PlainTextConverter(), article.getText());
Set<String> links = wikiModel.getLinks();
StringBuilder sb = new StringBuilder();
for (String link : links) {

代码示例来源:origin: edu.illinois.cs.cogcomp/wikipediaAPI-multilingual

wikiModel.setUp();
String raw_text = page.getText();
String text = wikiModel.render(renderer, raw_text);

代码示例来源:origin: org.openfuxml/ofx-wiki

@Override
public String render(String rawWikiText) {
  String xhtmlArtifact = super.render(rawWikiText);

代码示例来源:origin: edu.umd/cloud9

/**
 * Creates an empty <code>WikipediaPage</code> object.
 */
public WikipediaPage() {
 wikiModel = new WikiModel("", "");
 textConverter = new PlainTextConverter();
}

代码示例来源:origin: Stratio/morphlines

@Override
  protected boolean doProcess(Record record) {
    Object value = record.get(inputFieldName).get(0);
    WikiModel wikiModel = new WikiModel(
        "http://www.mywiki.com/wiki/${image}",
        "http://www.mywiki.com/wiki/${title}");
    String cleanText = wikiModel.render(new PlainTextConverter(),
        value.toString());
    Pattern p = Pattern.compile(TEMPLATE_PATTERN);
    Matcher m = p.matcher(cleanText);
    while (m.find()) {
      cleanText = m.replaceAll("");
      m = p.matcher(cleanText);
    }
    record.put(outputFieldName, cleanText.trim());
    // pass record to next command in chain:
    return super.doProcess(record);
  }
}

代码示例来源:origin: edu.umd/cloud9

/**
 * Returns the contents of this page (title + text).
 */
public String getContent() {
 String s = getWikiMarkup();
 // Bliki doesn't seem to properly handle inter-language links, so remove manually.
 s = LANG_LINKS.matcher(s).replaceAll(" ");
 wikiModel.setUp();
 s = getTitle() + "\n" + wikiModel.render(textConverter, s);
 wikiModel.tearDown();
 // The way the some entities are encoded, we have to unescape twice.
 s = StringEscapeUtils.unescapeHtml(StringEscapeUtils.unescapeHtml(s));
 s = REF.matcher(s).replaceAll(" ");
 s = HTML_COMMENT.matcher(s).replaceAll(" ");
 // Sometimes, URL bumps up against comments e.g., <!-- http://foo.com/-->
 // Therefore, we want to remove the comment first; otherwise the URL pattern might eat up
 // the comment terminator.
 s = URL.matcher(s).replaceAll(" ");
 s = DOUBLE_CURLY.matcher(s).replaceAll(" ");
 s = HTML_TAG.matcher(s).replaceAll(" ");
 return s;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/wikipediaAPI

wikiModel.setUp();
final List<Href> links = new ArrayList<Href>();
LinkAnnotationConverter renderer = new LinkAnnotationConverter() {
String text = wikiModel.render(renderer, raw_text);
if(StringUtils.isEmpty(text)){
  processAnnotation(null);

代码示例来源:origin: info.bliki.wiki/bliki-core

/**
 * Convert a given text in wiki notation into HTML text.
 *
 * @param rawWikiText
 *            a raw wiki text
 * @param resultBuffer
 *            the buffer to which to append the resulting HTML code.
 * @param imageBaseURL
 *            a url string which must contains a &quot;${image}&quot;
 *            variable which will be replaced by the image name, to create
 *            links to images.
 * @param linkBaseURL
 *            a url string which must contains a &quot;${title}&quot;
 *            variable which will be replaced by the topic title, to create
 *            links to other wiki topics.
 * @throws IOException
 */
public static void toHtml(String rawWikiText, Appendable resultBuffer,
    String imageBaseURL, String linkBaseURL) throws IOException {
  toText(new WikiModel(imageBaseURL, linkBaseURL), new HTMLConverter(),
      rawWikiText, resultBuffer, false, false);
}

代码示例来源:origin: org.openfuxml/ofx-wiki

public String process(String txtMarkup)
  {
    logger.warn("Check image and title");
    String wikiImage="file:///c:/temp/${image}";
    String wikiTitle="file:///c:/temp/${title}";
    
    WikiModel myWikiModel = new WikiDefaultModel(wikiImage,wikiTitle);
    String xHtml = myWikiModel.render(txtMarkup);
    return xHtml;
  }
}

代码示例来源:origin: info.bliki.wiki/bliki-core

@Override
  public void actionPerformed(java.awt.event.ActionEvent event) {
    String strData = input.getText();
    WikiModel wikiModel = new WikiModel(new Configuration(), Locale.ENGLISH, "${image}", "${title}");
    wikiModel.setUp();
    try {
      String result = wikiModel.render(strData, false);
      output.setText(result);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      wikiModel.tearDown();
    }
  }
}

代码示例来源:origin: com.stratio.morphlines/wikipediacleaner

@Override
  protected boolean doProcess(Record record) {
    Object value = record.get(inputFieldName).get(0);
    WikiModel wikiModel = new WikiModel(
        "http://www.mywiki.com/wiki/${image}",
        "http://www.mywiki.com/wiki/${title}");
    String cleanText = wikiModel.render(new PlainTextConverter(),
        value.toString());
    Pattern p = Pattern.compile(TEMPLATE_PATTERN);
    Matcher m = p.matcher(cleanText);
    while (m.find()) {
      cleanText = m.replaceAll("");
      m = p.matcher(cleanText);
    }
    record.put(outputFieldName, cleanText.trim());
    // pass record to next command in chain:
    return super.doProcess(record);
  }
}

代码示例来源:origin: info.bliki.wiki/bliki-core

/**
 * Convert a given text in wiki notation into HTML text.
 *
 * @param rawWikiText
 *            a raw wiki text
 * @return the resulting HTML text; nay returns <code>null</code>, if an
 *         <code>IOException</code> occured.
 */
public static String toHtml(String rawWikiText) {
  try {
    StringBuilder resultBuffer = new StringBuilder(rawWikiText.length()
        + rawWikiText.length() / 10);
    toText(new WikiModel("/${image}", "/${title}"),
        new HTMLConverter(), rawWikiText, resultBuffer, false,
        false);
    return resultBuffer.toString();
  } catch (IOException ignored) {
  }
  return null;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/wikipediaAPI

/**
 * Get the raw wiki text for the given namespace and article name. This model
 * implementation uses a Derby database to cache downloaded wiki template
 * texts.
 * 
 * @param namespace
 *          the namespace of this article
 * @param templateName
 *          the name of the template
 * @param templateParameters
 *          if the namespace is the <b>Template</b> namespace, the current
 *          template parameters are stored as <code>String</code>s in this map
 * 
 * @return <code>null</code> if no content was found
 * 
 * @see info.bliki.api.User#queryContent(String[])
 */
@Override
public String getRawWikiContent(String namespace, String articleName, Map<String, String> templateParameters) {
  String result = super.getRawWikiContent(namespace, articleName, templateParameters);
  if (result != null) {
    // found magic word template
    return result;
  }
  return null;
}

代码示例来源:origin: info.bliki.wiki/bliki-core

@Override
  public void actionPerformed(java.awt.event.ActionEvent event) {
    String strData = input.getText();
    WikiModel wikiModel = new WikiModel(new Configuration(), Locale.ENGLISH, "${image}", "${title}");
    wikiModel.setUp();
    try {
      String result = wikiModel.render(new PlainTextConverter(), strData, false);
      output.setText(result);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      wikiModel.tearDown();
    }
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/wikipediaAPI

WikiModel wikiModel = new WikiModel("${image}", "${title}"); // do not
String text = wikiModel.render(new PlainTextConverter(), rawText); // this

相关文章