2

我有兴趣将英语单词翻译成特定语言(例如俄语)。我已经阅读了整个维基词典 API 手册,但我还没有找到一个好方法。对于“狗”这个词,我可以通过以下方式使用维基词典 API 获得包含其他语言翻译的整个部分:

http://en.wiktionary.org/w/api.php?action=query&titles=dog&prop=revisions&rvprop=content&rvsection=11

翻译部分的编号不是恒定的,并且对于不同的单词是不同的。对于“狗”,翻译部分编号是11,但对于“猫”,我需要rvsection=7。是否可以在不下载整个翻译部分的情况下获得任何英语单词的特定语言的翻译?

4

4 回答 4

6

通过从 API 请求跨维基链接,您可以获得相当多的翻译。我使用这种方法编写了一个简单的 JS 应用程序:http: //jsfiddle.net/karlb/PxfrJ/11/

于 2012-09-27T20:21:07.557 回答
2

dbpedia和Dbnary项目从维基词典提取翻译数据作为 RDF,并提供一个 SPARQL 端点,您可以在其中查询翻译,而无需下载大型数据集。

这是 Dbnary 的查询示例:

SELECT DISTINCT ?written_trans AS ?translations
WHERE {
    ?lexentry ontolex:canonicalForm [
        ontolex:writtenRep "dog"@en
    ] .

    ?trans dbnary:isTranslationOf ?lexentry ;
           dbnary:targetLanguage lexvo:rus ;
           dbnary:writtenForm ?written_trans .
}

这导致了这些结果。

于 2014-11-30T16:38:54.030 回答
2

您可以使用它来帮助将“狗”从英语翻译成俄语。此 URL 为标题为“dog”的页面查找以“ru”开头的内部链接:https ://en.wiktionary.org/w/api.php?action=query&prop=iwlinks&titles=dog&iwprop=url&iwprefix=ru&format=json&continue =

我强调帮助是因为你会得到许多模棱两可的翻译,你可能想使用类别和其他东西来消除歧义。

该 URL 具有“iwprop=url”,因此您可以轻松单击链接,但在您的应用程序中,我建议您使用此链接: https ://en.wiktionary.org/w/api.php?action=query&prop=iwlinks&titles=dog&iwprefix=ru&format =json&continue= 并自己制作链接。

于 2015-05-20T04:34:08.913 回答
1

The Wiktionary API won't do specific translations of one word between two languages. It's not possible to do what you are wanting to do here.

However, Google Translate does have an API that can do what you're looking for.

于 2011-08-23T19:15:07.757 回答