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


Java WikiModel类代码示例

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


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

示例1: WikiParser

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
/**
 * Creates a new create of TrecWebParser
 */
public WikiParser(DocumentSplit split, Parameters p) throws IOException {
  super(split, p);
  this.reader = getBufferedReader(split);
  DocumentBuilderFactory builderFactory =
          DocumentBuilderFactory.newInstance();

  try {
    builder = builderFactory.newDocumentBuilder();
  } catch (ParserConfigurationException e) {
    throw new IOException("bliki configuration exception", e);
  }
  this.wikiParser = new WikiModel("http://en.wikipedia.org/wiki/${image}",
          "http://en.wikipedia.org/wiki/${title}");

  this.specialPrefixWhiteList = new HashSet<String>();
  this.specialPrefixWhiteList.add("Category:");
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:21,代码来源:WikiParser.java

示例2: markupToPlainText

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
/** 
 * Conversion of a String in wikipedia markup language to the short
 * description String in plain text
 * 
 * @param markup The wikipedia markup language String
 * @return The resulting short description String
 */
public static String markupToPlainText(String markup, String title) {
	WikiModel wikiModel = new WikiModel("http://de.wikipedia.org/wiki/${image}", "http://de.wikipedia.org/wiki/${title}");
	
	String encodedTitle;
	try {
		encodedTitle = URLEncoder.encode(title, "UTF-8");
	} catch (UnsupportedEncodingException e) {
		Logger.getInstance().error("UTF-8 encoding not supported.");
		return null;
	}
	
	markup = markup.replaceAll("\\{[^\\(]*\\}", "");
	
       String html = wikiModel.render(markup).replaceAll("<ref>"," <ref>").replaceAll("&nbsp;", " ");
       
       html += "<br/><a href=\"http://de.wikipedia.org/wiki/" + encodedTitle + "\">Gesamten Artikel lesen</a>";
       
       return html;
}
 
开发者ID:johb,项目名称:GAIA,代码行数:27,代码来源:WikiMarkupParser.java

示例3: refresh

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
public void refresh() {
	WebView wvContent = (WebView)rootView.findViewById(R.id.webViewContent);
	//wvContent.getSettings().setJavaScriptEnabled(true);
	wvContent.getSettings().setSupportZoom(false);
	wvContent.getSettings().setUseWideViewPort(false);
	wvContent.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
	wvContent.getSettings().setDefaultTextEncodingName("utf-8");
	//wvContent.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);

	//WikiModel wikiModel = new WikiModel("http://wiki.occc.ir/wiki/${image}", "http://wiki.occc.ir/wiki/${title}");
	WikiModel wikiModel = new WikiModel("${image}", "${title}");
	content = wikiModel.render(content);
	
	StringBuilder sbMessage = new StringBuilder();
	if (isRtlRequired) {
		sbMessage.append("<html><body dir='rtl'><div >");
	}
	else {
		sbMessage.append("<html><body dir='ltr'><div >");
	}
	sbMessage.append(content);
	sbMessage.append("</div></body></html>");

	wvContent.loadDataWithBaseURL("about:blank", sbMessage.toString(), "text/html", "utf-8", null);
	//wvContent.loadData("<html><head>><meta HTTP-EQUIV='Content-Type' content='text/html; charset=utf-8' /></head><body dir='rtl'>" + description +"</body></html>", "text/html", "utf-8");
}
 
开发者ID:occc-ir,项目名称:cloud_android_client,代码行数:27,代码来源:WikiContentFragment.java

示例4: process

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
public void process(WikiArticle article, Siteinfo siteinfo) throws SAXException {
	counter++;
	if (counter >= max_counter) {
		throw new SAXException("\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();
	}
}
 
开发者ID:abdollahpour,项目名称:xweb-wiki,代码行数:20,代码来源:PrintArticle.java

示例5: main

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
public static void main(String[] args) {
    User user = new User("", "", "http://en.wikipedia.org/w/api.php");
    user.login();

    String[] titles = {"Data science"};
    List<Page> pageList = user.queryContent(titles);

    for (Page page : pageList) {
        WikiModel wikiModel = new WikiModel("${image}", "${title}");
        out.println("Image Base URL: " + wikiModel.getImageBaseURL() + "\n"
                + "Page Name: " + wikiModel.getPageName() + "\n"
                + "Wiki Base URL: " + wikiModel.getWikiBaseURL());
        String htmlStr = wikiModel.render("This is a simple [[Hello World]] wiki tag");
        System.out.println(htmlStr);

        String htmlText = wikiModel.render(page.toString());
        out.println("Title: " + page.getTitle() + "\n"
                + "Image URL: " + page.getImageUrl()+ "\n"
                + "Timestamp: " + page.getCurrentRevision().getTimestamp());
        
        List <Reference> referenceList = wikiModel.getReferences();
        out.println(referenceList.size());
        for(Reference reference : referenceList) {
            out.println(reference.getRefString());
        }
        
        ITableOfContent toc = wikiModel.getTableOfContent();
        List<SectionHeader> sections = toc.getSectionHeaders();
        for(SectionHeader sh : sections) {
            out.println(sh.getFirst());
        }
        
        out.println(htmlText);
    }
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:36,代码来源:BlikiExample.java

示例6: process

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
@SuppressWarnings( "deprecation" )
@Override
public void process( WikiArticle article, Siteinfo siteinfo ) throws SAXException {
    this.title.length( 0 );
    this.firstPar.length( 0 );
    this.title.append( URLEncoder.encode( article.getTitle().replace( ' ', '_' ) ) );
    WikiModel wikiModel = new WikiModel( this.imageBaseURL, this.linkBaseURL );
    String plainText = wikiModel.render( new PlainTextConverter(), article.getText() );
    for( int start = 0; start < plainText.length(); ++start ) {
        if( Character.isWhitespace( plainText.charAt( start ) ) ) continue;
        if( plainText.charAt( start ) == '{' ) {
            if( ( start = BRACES_CLOSED.search( plainText, start ) ) == -1 ) break;
            ++start;
            continue;
        }
        if( plainText.charAt( start ) == '[' ) {
            if( ( start = BRACKETS_CLOSED.search( plainText, start ) ) == -1 ) break;
            ++start;
            continue;
        }
        int end = plainText.indexOf( 10, start );
        if( end <= start ) break;
        this.firstPar.append( plainText.substring( start, end ) );
        break;
    }
    this.word.length( 0 );
    this.nonWord.length( 0 );
    this.wordReader.setReader( ( Reader ) new FastBufferedReader( this.firstPar ) );
    try {
        this.writer.append( this.title ).append( "\t" );
        while( this.wordReader.next( this.word, this.nonWord ) ) {
            this.writer.append( this.word.toLowerCase() ).append( " " );
        }
        this.writer.append( "\n" );
    } catch( IOException e ) {
        e.printStackTrace();
    }
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:39,代码来源:ExtractFirstParagraphs.java

示例7: process

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
@Override
public void process(WikiArticle article, Siteinfo siteinfo) throws SAXException {
    this.title.length(0);
    this.html.length(0);
    try {
        this.title.append(URLEncoder.encode(article.getTitle().replace(' ', '_'), "UTF-8"));
    }
    catch (UnsupportedEncodingException e1) {
        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) {
        sb.append( " " ).append( this.processLink( link ) );
    }
    sb.append("\t");
    String slinks = sb.toString();
    MutableString allText = new MutableString(plainText);
    this.word.length(0);
    this.nonWord.length(0);
    this.wordReader.setReader((Reader)new FastBufferedReader(allText));
    try {
        this.writer.append( this.title ).append( "\t" );
        this.writer.append(slinks);
        while (this.wordReader.next(this.word, this.nonWord)) {
            this.writer.append( this.word.toLowerCase() ).append( " " );
        }
        this.writer.append("\n");
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:36,代码来源:ExtractLinks.java

示例8: processLink

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
public String processLink(String input) {
    String jj = WikiModel.toHtml((String)("[[" + input + "]]"));
    Matcher matcher = pattern.matcher(jj);
    if (!matcher.find()) {
        return "";
    }
    jj = matcher.group(2);
    return jj;
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:10,代码来源:ExtractLinks.java

示例9: actionPerformed

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
public void actionPerformed(java.awt.event.ActionEvent event) {
	String strData = input.getText();
	WikiModel wikiModel = new WikiModel(Configuration.DEFAULT_CONFIGURATION, Locale.ENGLISH, "${image}", "${title}");
	wikiModel.setUp();
    try {
	String result = wikiModel.render(strData, false);
	output.setText(result);
    } finally {
      wikiModel.tearDown();
    }
}
 
开发者ID:abdollahpour,项目名称:xweb-wiki,代码行数:12,代码来源:BlikiConverter.java

示例10: mediawikiConvert

import info.bliki.wiki.model.WikiModel; //导入依赖的package包/类
public static void mediawikiConvert(final File src, final File dst, final String wikiDir) throws IOException {
    final String wiki = Tools.readTextFile(src);



    final WikiModel model = new WikiModel(wikiDir + "${image}", "${title}");

    String html = model.render(wiki, false);

    // there's some problem with WikiModel, if you just put [[File:example.jpg|caption]]
    // you will get
    // <a ... href="File:example.jpg" ...>
    // that is actually no where! so we fix it by this regex

    html = html.replaceAll("(?i)href=\"file:", "href=\"" + wikiDir);

    final String attributesToRemove = "width";

    html = html.replaceAll("\\s+(?:" + attributesToRemove + ")\\s*=\\s*\"[^\"]*\"","");

    // another solution remove attr,
    // htmlFragment.replaceAll("\\s+(?:" + attributesToRemove + ")\\s*=\\s*\"[^\"]*\"","");
    // code:
    // String attributesToRemove = "id\\=\\\"3nav";
    // html = html.replaceAll("\\s+(?:" + attributesToRemove + ")[^\"]*\"","");

    // Fix toc
    // We don't need TITLE, because it's different in different language. We add title by CSS
    final int startTocIndex = html.indexOf("<div id=\"toctitle\">");
    if(startTocIndex > 0) {
        final int endTocIndex = html.indexOf("</div>") + "</div>".length();
        html = html.substring(0, startTocIndex) + html.substring(endTocIndex);
    }

    Tools.writeTextFile(html, dst);
}
 
开发者ID:abdollahpour,项目名称:xweb-wiki,代码行数:37,代码来源:WikiModule.java


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