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

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

本文整理了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

  1. @Override
  2. public void process(WikiArticle article, Siteinfo siteinfo) throws IOException {
  3. counter++;
  4. if (counter >= max_counter) {
  5. throw new IOException("\nLimit reached after " + max_counter + " entries.");
  6. }
  7. String htmlText = "";
  8. WikiModel wikiModel = new WikiModel("${image}", "${title}");
  9. try {
  10. wikiModel.setUp();
  11. htmlText = wikiModel.render(article.getText(), false);
  12. if (htmlText == null) {
  13. System.out.println("An IOException occured!");
  14. } else {
  15. System.out.println(htmlText);
  16. }
  17. } finally {
  18. wikiModel.tearDown();
  19. }
  20. }

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

  1. /**
  2. * Get the raw wiki text for the given namespace and article name. This model
  3. * implementation uses a Derby database to cache downloaded wiki template
  4. * texts.
  5. *
  6. * @param namespace
  7. * the namespace of this article
  8. * @param templateName
  9. * the name of the template
  10. * @param templateParameters
  11. * if the namespace is the <b>Template</b> namespace, the current
  12. * template parameters are stored as <code>String</code>s in this map
  13. *
  14. * @return <code>null</code> if no content was found
  15. *
  16. * @see info.bliki.api.User#queryContent(String[])
  17. */
  18. @Override
  19. public String getRawWikiContent(String namespace, String articleName, Map<String, String> templateParameters) {
  20. String result = super.getRawWikiContent(namespace, articleName, templateParameters);
  21. if (result != null) {
  22. // found magic word template
  23. return result;
  24. }
  25. return null;
  26. }

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

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

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

  1. /**
  2. * Convert a given text in wiki notation into HTML text.
  3. *
  4. * @param rawWikiText
  5. * a raw wiki text
  6. * @param resultBuffer
  7. * the buffer to which to append the resulting HTML code.
  8. * @throws IOException
  9. */
  10. public static void toHtml(String rawWikiText, Appendable resultBuffer)
  11. throws IOException {
  12. toText(new WikiModel("/${image}", "/${title}"), new HTMLConverter(),
  13. rawWikiText, resultBuffer, false, false);
  14. }

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Creates an empty <code>WikipediaPage</code> object.
  3. */
  4. public WikipediaPage() {
  5. wikiModel = new WikiModel("", "");
  6. textConverter = new PlainTextConverter();
  7. }

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

  1. @Override
  2. protected boolean doProcess(Record record) {
  3. Object value = record.get(inputFieldName).get(0);
  4. WikiModel wikiModel = new WikiModel(
  5. "http://www.mywiki.com/wiki/${image}",
  6. "http://www.mywiki.com/wiki/${title}");
  7. String cleanText = wikiModel.render(new PlainTextConverter(),
  8. value.toString());
  9. Pattern p = Pattern.compile(TEMPLATE_PATTERN);
  10. Matcher m = p.matcher(cleanText);
  11. while (m.find()) {
  12. cleanText = m.replaceAll("");
  13. m = p.matcher(cleanText);
  14. }
  15. record.put(outputFieldName, cleanText.trim());
  16. // pass record to next command in chain:
  17. return super.doProcess(record);
  18. }
  19. }

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

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

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

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

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

  1. /**
  2. * Convert a given text in wiki notation into HTML text.
  3. *
  4. * @param rawWikiText
  5. * a raw wiki text
  6. * @param resultBuffer
  7. * the buffer to which to append the resulting HTML code.
  8. * @param imageBaseURL
  9. * a url string which must contains a &quot;${image}&quot;
  10. * variable which will be replaced by the image name, to create
  11. * links to images.
  12. * @param linkBaseURL
  13. * a url string which must contains a &quot;${title}&quot;
  14. * variable which will be replaced by the topic title, to create
  15. * links to other wiki topics.
  16. * @throws IOException
  17. */
  18. public static void toHtml(String rawWikiText, Appendable resultBuffer,
  19. String imageBaseURL, String linkBaseURL) throws IOException {
  20. toText(new WikiModel(imageBaseURL, linkBaseURL), new HTMLConverter(),
  21. rawWikiText, resultBuffer, false, false);
  22. }

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

  1. public String process(String txtMarkup)
  2. {
  3. logger.warn("Check image and title");
  4. String wikiImage="file:///c:/temp/${image}";
  5. String wikiTitle="file:///c:/temp/${title}";
  6. WikiModel myWikiModel = new WikiDefaultModel(wikiImage,wikiTitle);
  7. String xHtml = myWikiModel.render(txtMarkup);
  8. return xHtml;
  9. }
  10. }

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

  1. @Override
  2. public void actionPerformed(java.awt.event.ActionEvent event) {
  3. String strData = input.getText();
  4. WikiModel wikiModel = new WikiModel(new Configuration(), Locale.ENGLISH, "${image}", "${title}");
  5. wikiModel.setUp();
  6. try {
  7. String result = wikiModel.render(strData, false);
  8. output.setText(result);
  9. } catch (IOException e) {
  10. e.printStackTrace();
  11. } finally {
  12. wikiModel.tearDown();
  13. }
  14. }
  15. }

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

  1. @Override
  2. protected boolean doProcess(Record record) {
  3. Object value = record.get(inputFieldName).get(0);
  4. WikiModel wikiModel = new WikiModel(
  5. "http://www.mywiki.com/wiki/${image}",
  6. "http://www.mywiki.com/wiki/${title}");
  7. String cleanText = wikiModel.render(new PlainTextConverter(),
  8. value.toString());
  9. Pattern p = Pattern.compile(TEMPLATE_PATTERN);
  10. Matcher m = p.matcher(cleanText);
  11. while (m.find()) {
  12. cleanText = m.replaceAll("");
  13. m = p.matcher(cleanText);
  14. }
  15. record.put(outputFieldName, cleanText.trim());
  16. // pass record to next command in chain:
  17. return super.doProcess(record);
  18. }
  19. }

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

  1. /**
  2. * Convert a given text in wiki notation into HTML text.
  3. *
  4. * @param rawWikiText
  5. * a raw wiki text
  6. * @return the resulting HTML text; nay returns <code>null</code>, if an
  7. * <code>IOException</code> occured.
  8. */
  9. public static String toHtml(String rawWikiText) {
  10. try {
  11. StringBuilder resultBuffer = new StringBuilder(rawWikiText.length()
  12. + rawWikiText.length() / 10);
  13. toText(new WikiModel("/${image}", "/${title}"),
  14. new HTMLConverter(), rawWikiText, resultBuffer, false,
  15. false);
  16. return resultBuffer.toString();
  17. } catch (IOException ignored) {
  18. }
  19. return null;
  20. }

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

  1. /**
  2. * Get the raw wiki text for the given namespace and article name. This model
  3. * implementation uses a Derby database to cache downloaded wiki template
  4. * texts.
  5. *
  6. * @param namespace
  7. * the namespace of this article
  8. * @param templateName
  9. * the name of the template
  10. * @param templateParameters
  11. * if the namespace is the <b>Template</b> namespace, the current
  12. * template parameters are stored as <code>String</code>s in this map
  13. *
  14. * @return <code>null</code> if no content was found
  15. *
  16. * @see info.bliki.api.User#queryContent(String[])
  17. */
  18. @Override
  19. public String getRawWikiContent(String namespace, String articleName, Map<String, String> templateParameters) {
  20. String result = super.getRawWikiContent(namespace, articleName, templateParameters);
  21. if (result != null) {
  22. // found magic word template
  23. return result;
  24. }
  25. return null;
  26. }

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

  1. @Override
  2. public void actionPerformed(java.awt.event.ActionEvent event) {
  3. String strData = input.getText();
  4. WikiModel wikiModel = new WikiModel(new Configuration(), Locale.ENGLISH, "${image}", "${title}");
  5. wikiModel.setUp();
  6. try {
  7. String result = wikiModel.render(new PlainTextConverter(), strData, false);
  8. output.setText(result);
  9. } catch (IOException e) {
  10. e.printStackTrace();
  11. } finally {
  12. wikiModel.tearDown();
  13. }
  14. }
  15. }

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

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

相关文章