wikionary API - 单词的含义 [英] wikionary API - meaning of words

查看:160
本文介绍了wikionary API - 单词的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用wikionary API获取所选单词的含义。
内容检索数据应该与当天的词中显示的相同,只有没有etympology,同义词等的基本含义..
例如

I would like get meaning of selected word using wikionary API. Content retrieve data should be the same as is presented in "Word of the day", only the basic meaning without etympology, Synonyms etc.. for example

postiche n
头部或脸部佩戴的任何假发,如假胡须或假发。

"postiche n Any item of false hair worn on the head or face, such as a false beard or wig."

我试过用文档,但我可以找到类似的例子,任何人都可以帮助解决这个问题吗?

I tried use documentation but i can find similar example, can anybody help with this problem?

推荐答案

虽然MediaWiki有一个API( api.php ),您可能最简单的方法是将 action = raw 参数用于索引.php 如果您只想检索一个修订版的源代码(不包含在XML,JSON等中,而不是API)。

Although MediaWiki has an API (api.php), it might be easiest for your purposes to just use the action=raw parameter to index.php if you just want to retrieve the source code of one revision (not wrapped in XML, JSON, etc., as opposed to the API).

例如,这是11月14日日页的原始词:

For example, this is the raw word of the day page for November 14:

http://en.wiktionary.org/w/index.php?title=Wiktio nary:Word_of_the_day / November_14& action = raw

不幸的是,wiki页面的格式侧重于演示(针对人类读者)而非语义(对于机器而言),所以你不应该对没有get word definitionAPI命令感到惊讶。相反,您的脚本必须理解维基编辑人员创建和使用的众多文本格式模板,以及复杂的表示格式语法,包括标题,无序列表等。例如,以下是溢出页面的源代码:

What's unfortunate is that the format of wiki pages focuses on presentation (for the human reader) rather than on semantics (for the machine), so you should not be surprised that there is no "get word definition" API command. Instead, your script will have to make sense of the numerous text formatting templates that Wiktionary editors have created and used, as well as complex presentational formatting syntax, including headings, unordered lists, and others. For example, here is the source code for the page "overflow":

http://en.wiktionary.org/w/index.php?title=overflow&action=raw

API中有 生成XML解析树选项,但它并没有将大部分表示格式化为XML。亲自看看:

There is a "generate XML parse tree" option in the API, but it doesn't break much of the presentational formatting into XML. Just see for yourself:

http://en.wiktionary.org/w/api.php?action=query&titles=overflow&prop=revisions&rvprop = content& rvgeneratexml =& format = jsonfm

如果您想知道MediaWiki以外的MediaWiki格式页面是否存在解析器,不,没有。至少没有任何用JavaScript编写的内容(参见备选解析器列表),并检查网页列出的两个网站)。即使这样,支持大多数/所有常见模板也将是一个巨大的挑战。祝你好运。

In case you are wondering whether there exists a parser for MediaWiki-format pages other than MediaWiki, no, there isn't. At least not anything written in JavaScript that's currently maintained (see list of alternative parsers, and check the web sites of the two listed ones). And even then, supporting most/all of the common templates will be a big challenge. Good luck.

这篇关于wikionary API - 单词的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆