如何使用Wiktionary API获取发音数据? [英] How can I use the Wiktionary API for getting pronunciation data?

查看:101
本文介绍了如何使用Wiktionary API获取发音数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种通过查询某种API来获取任何给定单词的发音的方法.由于维基词典可以方便地查找我试图使用其API的单词的发音,但是如何我会得到特定单词的发音吗?

I was looking for a way to get the pronunciation of any given word by querying an API of some sort. As Wiktionary comes in handy to find pronunciations of words I was trying to use their API, but how do I get the pronunciation of a specific word?

似乎他们的API仅允许获取整个Wiki文章.

It seems their API only allows getting the entire Wiki article.

推荐答案

维基词典没有自己的API. Wiktionary所运行的MediaWiki软件确实具有API,但它完全不了解Wiktionary的结构和内容.

Wiktionary doesn't have an API of its own. MediaWiki, the software the Wiktionary runs on does have an API but it is completely unaware of the structure and content of Wiktionary.

您能做的最好的就是使用 MediaWiki API 查找以下内容的Wiki页面:您想要的单词,然后查看目录.如果目录中有您要使用的语言的语言部分,并且其中有一个Pronunciation部分,则使用另一个API调用来获取该部分的wikitext,您必须自己对其进行解析.由于Wiktionary不断发展,因此它可能会在不同的单词上使用或不使用不同的模板.

The best you can do is use the MediaWiki API to find the wiki page for the word you want, then look at the table of contents. If the table of contents has a language section for the language you want and within that there is a Pronunciation section, then use another API call to get the wikitext of that section which you will have to parse yourself. It may well use or not different templates on different words since Wiktionary is constantly evolving.

也有维基词典 查看全文

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