• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Wiki类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
  String wiki = "commons.wikimedia.org";
  String protocol = "https://";
  String scriptPath = "/w";

  for (String arg : args) {
    String[] pair = arg.split("=");
    if (pair[0].contains("wiki")) {
      wiki = pair[1];
    } else if (pair[0].contains("protocol")) {
      protocol = pair[1];
    } else if (pair[0].contains("scriptPath")) {
      scriptPath = pair[1];
    }
  }

  LOGGER.log(Level.INFO,
          "Wiki set as: {0}\nProtocol set as: {1}\nScript path set as: {2}",
          new String[]{wiki, protocol, scriptPath}
  );
  
  Session.WIKI = new Wiki(wiki, scriptPath, protocol);
  launch(args);
}
 
开发者ID:yarl,项目名称:pattypan,代码行数:28,代码来源:Main.java


示例2: templateReplace

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 * Replaces all transclusions of a template/page with specified text
 * 
 * @param template The template (including namespace prefix) to be replaced
 * @param replacementText The text to replace the template with (can include subst:XXXX)
 * @param reason Edit summary to use
 * @param wiki The wiki object to use.
 * 
 * @throws IOException If network error.
 * 
 * 
 */

public static void templateReplace(String template, String replacementText, String reason, Wiki wiki) throws IOException
{
	String[] list = wiki.whatTranscludesHere(template);
	if (template.startsWith("Template:"))
		template = namespaceStrip(template, wiki);

	for (String page : list)
	{
		try
		{
			wiki.edit(page, wiki.getPageText(page).replaceAll("(?i)(" + template + ")", replacementText), reason);
		}
		catch (Throwable e)
		{
			e.printStackTrace();
		}
	}
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:32,代码来源:ParseUtils.java


示例3: nullEdit

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 * Performs null edit on a list of pages by wiki. PRECONDITION: wiki object must be logged in
 * 
 * @param wiki The wiki object to use
 * @param l The list of pages to null edit.
 */
public static void nullEdit(Wiki wiki, String... l)
{
	for (String s : l)
	{
		try
		{
			System.err.println("Attempting null edit on '" + s + "'");
			wiki.edit(s, wiki.getPageText(s), "");
			
		}
		catch (Throwable e)
		{
			e.printStackTrace();
		}
	}
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:23,代码来源:WikiUtils.java


示例4: namespaceFilter

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 * Removes all titles of a certain namespace. 
 * 
 * @param wiki The wiki object to use.
 * @param titles The list of titles to use.
 * @param ns The namespaces to filter out.
 * @return A new list of titles with this change.
 * @throws IOException Eh?
 */
public static String[] namespaceFilter(Wiki wiki, String[] titles, int... ns) throws IOException
{
	ArrayList<String> l = new ArrayList<String>();
	for(String s : titles)
	{
		boolean flag = false;
		for(int i : ns)
			if(wiki.namespace(s) == i)
			{
				flag = true;
				break;
			}
		
		if(!flag)
			l.add(s);
	}
	
	return l.toArray(new String[0]);		
	
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:30,代码来源:WikiUtils.java


示例5: guiLogin

import org.wikipedia.Wiki; //导入依赖的package包/类
public static void guiLogin(Wiki wiki) {
    JTextField u = new JTextField(12);
    JPasswordField px = new JPasswordField(12);
    do {

        JPanel pl = FbotUtil.buildForm("Login",
                new JLabel("Username:", 11), u,
                new JLabel("Password:", 11), px);
        if (JOptionPane.showConfirmDialog(null, pl, "Login", 2, -1) != 0) {
            System.exit(0);
        }
    } while (!Fbot.loginAndSetPrefs(wiki, u.getText().trim(),
            px.getPassword()));

    wiki.setThrottle(5);
}
 
开发者ID:Commonists,项目名称:Up,代码行数:17,代码来源:Fbot.java


示例6: fileReplace

import org.wikipedia.Wiki; //导入依赖的package包/类
public static void fileReplace(String[] list, String file,
        String replacement, String summary, Wiki wiki) {
    file = file.replace((CharSequence) "_", (CharSequence) " ");
    String regex = "(?i)(" + file + "|"
            + file.replace((CharSequence) " ", (CharSequence) "_") + ")";
    for (String page : list) {
        try {
            wiki.edit(page,
                    wiki.getPageText(page).replaceAll(regex, replacement),
                    summary);
            continue;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:Commonists,项目名称:Up,代码行数:17,代码来源:Fbot.java


示例7: findAndReplace

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 * Generic find and replace method.
 * 
 * @param find The text to be found. You can use a regex for this
 * @param replacement The text to replace any text matching the <tt>find</tt> field
 * @param summary The edit summary to use
 * @param wiki The wiki object to use
 * @param pages The wiki pages to act upon.
 */
public static void findAndReplace(String find, String replacement, String summary, Wiki wiki, String... pages)
{
	for (String s : pages)
	{
		try
		{
			wiki.edit(s, wiki.getPageText(s).replaceAll(find, replacement), summary);
		}
		catch (Throwable e)
		{
			e.printStackTrace();
		}
	}
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:24,代码来源:WikiUtils.java


示例8: categoryIsEmpty

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 * Determines if a category is empty.
 * 
 * @param wiki The wiki object to use
 * @param cat Category name, with or without "Category:" prefix, in any language, is fine.
 * 
 * @return True if the category is empty.
 */
public static boolean categoryIsEmpty(Wiki wiki, String cat)
{
	try
	{
		return wiki.getCategoryMembers(ParseUtils.namespaceStrip(cat, wiki)).length == 0;
	}
	catch (Throwable e)
	{
		return false;
	}
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:20,代码来源:WikiUtils.java


示例9: intersectEditors

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 *  Given a set of <var>users</var>, find the list of articles they have 
 *  edited. Includes deleted contributions if {@link #isUsingAdminPrivileges()}
 *  is <code>true</code> and ignores minor edits if {@link #isIgnoringMinorEdits()}
 *  is <code>true</code>.
 * 
 *  @param users the list of users to fetch contributions for
 *  @return a map with page &#8594; list of revisions made
 *  @throws IOException if a network error occurs
 */
public Map<String, List<Wiki.Revision>> intersectEditors(String[] users) throws IOException
{
    // fetch the list of (deleted) edits
    List<Wiki.Revision>[] revisions = wiki.contribs(users, "", null, null, null);
    Stream<Wiki.Revision> revstream = Arrays.stream(revisions).flatMap(List::stream);
    
    if (adminmode)
    {
        Stream<Wiki.Revision> revstream2 = Arrays.stream(users).flatMap(user -> 
        {
            try
            {
                return Arrays.stream(wiki.deletedContribs(user));
            }
            catch (IOException | CredentialNotFoundException ex)
            {
                // If a network or privilege error occurs when fetching 
                // deleted contributions, that will be skipped with live 
                // edits returned.
                return Stream.empty();
            }
        });
        revstream = Stream.concat(revstream, revstream2);
    }
    // we cannot filter by sizediff here, the MediaWiki API does not return
    // this information for deleted revisions
    if (nominor)
        revstream = revstream.filter(rev -> !rev.isMinor());
    return revstream.collect(Collectors.groupingBy(Wiki.Revision::getPage));
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:41,代码来源:ArticleEditorIntersector.java


示例10: parseDiff

import org.wikipedia.Wiki; //导入依赖的package包/类
@Test
public void parseDiff() throws IOException
{
    Wiki.Revision[] revs = testWiki.getRevisions(new long[]
    { 
        244169L, 244170L, 244171L, 320307L 
    });
    
    // https://test.wikipedia.org/w/index.php?oldid=244169&diff=prev
    Map<Wiki.Revision, List<String>> results = UserLinkAdditionFinder.parseDiff(revs[0]);
    List<String> links = results.get(revs[0]);
    assertNotNull(links);
    assertEquals(1, links.size());
    assertEquals("http://spam.example.com", links.get(0));
            
    // https://test.wikipedia.org/w/index.php?oldid=244170&diff=prev
    results = UserLinkAdditionFinder.parseDiff(revs[1]);
    links = results.get(revs[1]);
    assertEquals("https://en.wikipedia.org", links.get(0));
    
    // https://test.wikipedia.org/w/index.php?oldid=244171&diff=prev
    results = UserLinkAdditionFinder.parseDiff(revs[2]);
    links = results.get(revs[2]);
    assertEquals("http://www.example.net", links.get(0));
    
    // dummy edit
    // https://test.wikipedia.org/w/index.php?oldid=320307&diff=prev
    results = UserLinkAdditionFinder.parseDiff(revs[3]);
    links = results.get(revs[3]);
    assertEquals(0, links.size());
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:32,代码来源:UserLinkAdditionFinderUnitTest.java


示例11: setUpClass

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 *  Initializes intersector object.
 *  @throws Exception if a network error occurs
 */
@BeforeClass
public static void setUpClass() throws Exception
{
    Wiki testWiki = Wiki.createInstance("test.wikipedia.org");
    testWiki.setMaxLag(-1);
    intersector = new ArticleEditorIntersector(testWiki);
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:12,代码来源:ArticleEditorIntersectorUnitTest.java


示例12: MBot

import org.wikipedia.Wiki; //导入依赖的package包/类
public /* varargs */ MBot(String user, char[] px, String domain, int instances, String[] list, String ... reason) throws FailedLoginException, IOException {
    Wiki t = new Wiki(domain);
    t.setMaxLag(-1);
    t.login(user, px);
    this.lists = FbotUtil.arraySplitter(list, instances);
    this.wikis = new Wiki[this.lists.length];
    for (int i = 0; i < this.lists.length; ++i) {
        this.wikis[i] = Fbot.wikiFactory(user, px, domain);
    }
    this.reason = reason;
}
 
开发者ID:Commonists,项目名称:Up,代码行数:12,代码来源:MBot.java


示例13: getRedirectsAsRegex

import org.wikipedia.Wiki; //导入依赖的package包/类
public static String getRedirectsAsRegex(String template, Wiki wiki) throws IOException {
    String r = "(?si)\\{{2}?\\s*?(Template:)??\\s*?(" + FbotParse.namespaceStrip(template);
    for (String str : wiki.whatLinksHere(template, true, 10)) {
        r = r + "|" + FbotParse.namespaceStrip(str);
    }
    r = r + ").*?\\}{2}?";
    return r;
}
 
开发者ID:Commonists,项目名称:Up,代码行数:9,代码来源:FbotParse.java


示例14: templateReplace

import org.wikipedia.Wiki; //导入依赖的package包/类
public static void templateReplace(String template, String replacementText, String reason, Wiki wiki) throws IOException {
    String[] list = wiki.whatTranscludesHere(template, new int[0]);
    if (template.startsWith("Template:")) {
        template = FbotParse.namespaceStrip(template);
    }
    for (String page : list) {
        try {
            wiki.edit(page, wiki.getPageText(page).replaceAll("(?i)(" + template + ")", replacementText), reason);
            continue;
        }
        catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:Commonists,项目名称:Up,代码行数:16,代码来源:FbotParse.java


示例15: getRedirectTarget

import org.wikipedia.Wiki; //导入依赖的package包/类
public static String getRedirectTarget(String redirect, Wiki wiki)
        throws IOException {
    String text = wiki.getPageText(redirect).trim();
    if (text.matches("(?si)^#(redirect)\\s*?\\[\\[.+?\\]\\].*?")) {
        return text.substring(text.indexOf("[[") + 2, text.indexOf("]]"));
    }
    throw new UnsupportedOperationException(
            "Parameter passed in is not a redirect page!");
}
 
开发者ID:Commonists,项目名称:Up,代码行数:10,代码来源:Fbot.java


示例16: dbrDump

import org.wikipedia.Wiki; //导入依赖的package包/类
public static void dbrDump(String page, String[] list, String headerText,
        String footerText, Wiki wiki) throws LoginException, IOException {
    String dump = headerText + "  This report last updated as of ~~~~~\n";
    for (String s : list) {
        dump = dump + "*[[:" + s + "]]\n";
    }
    dump = dump + "\n" + footerText;
    wiki.edit(page, dump, "Updating list");
}
 
开发者ID:Commonists,项目名称:Up,代码行数:10,代码来源:Fbot.java


示例17: listNamespaceSort

import org.wikipedia.Wiki; //导入依赖的package包/类
public static String[] listNamespaceSort(String[] list, int namespace,
        Wiki wiki) throws IOException {
    ArrayList<String> l = new ArrayList<String>();
    for (String s : list) {
        if (wiki.namespace(s) != namespace)
            continue;
        l.add(s);
    }
    return l.toArray(new String[0]);
}
 
开发者ID:Commonists,项目名称:Up,代码行数:11,代码来源:Fbot.java


示例18: addTextList

import org.wikipedia.Wiki; //导入依赖的package包/类
public static void addTextList(String[] pages, String text, String summary,
        Wiki wiki) {
    for (String page : pages) {
        try {
            wiki.edit(page, wiki.getPageText(text) + text, summary);
            continue;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:Commonists,项目名称:Up,代码行数:12,代码来源:Fbot.java


示例19: ArticleEditorIntersector

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 *  Creates a new intersector instance.
 *  @param wiki the wiki to fetch data from
 */
public ArticleEditorIntersector(Wiki wiki)
{
    this.wiki = wiki;
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:9,代码来源:ArticleEditorIntersector.java


示例20: getWiki

import org.wikipedia.Wiki; //导入依赖的package包/类
/**
 *  Returns the wiki that this intersector fetches data from.
 *  @return (see above)
 */
public Wiki getWiki()
{
    return wiki;
}
 
开发者ID:MER-C,项目名称:wiki-java,代码行数:9,代码来源:ArticleEditorIntersector.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TestSchemaMetrics类代码示例发布时间:2022-05-22
下一篇:
Java SpnegoConstants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap