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

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

问题描述

我一直在寻找一种通过查询某种 API 来获取任何给定单词的发音的方法.由于 Wiktionary 可以方便地找到我试图使用他们的 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.MediaWiki,维基词典运行的软件确实有一个API,但它完全不知道维基词典的结构和内容.

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 来查找你想要的词,然后看目录.如果目录有您想要的语言的语言部分,并且其中有一个 Pronunciation 部分,则使用另一个 API 调用来获取该部分的 wikitext你将不得不自己解析.由于维基词典在不断发展,因此它可能对不同的词使用或不使用不同的模板.

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.

还有用于 WiktionaryMediaWiki API.

这篇关于如何使用维基词典 API 获取发音数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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