Java 如何使用 Google Dictionary 作为 API?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22740789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:36:37  来源:igfitidea点击:

How to use to Google Dictionary as an API?

javadictionarygoogle-api

提问by zack0438

Because the Google Dictionary API is deprecated (e.g., following)

因为 Google Dictionary API 已被弃用(例如,以下)

http://www.google.com/dictionary/json?callback=a&sl=en&tl=en&q=love

and has been replaced with define (e.g., following)

并已替换为定义(例如,以下)

https://www.google.com/#q=define+love

Does anybody know how to use/invoke the "Google define" API in java?

有人知道如何在 Java 中使用/调用“Google 定义”API?

Here is the chrome extension which does similar thing.

这是执行类似操作的 chrome 扩展。

https://chrome.google.com/webstore/detail/google-dictionary-by-goog/mgijmajocgfcbeboacabfgobmjgjcoja

As an alternative, are there any open source dictionary APIs? I found Oxford (OED), Cambridge, Merriam-Webster, Wordnik APIs which provide APIs in subscription models.

作为替代方案,是否有任何开源词典 API?我发现 Oxford (OED)、Cambridge、Merriam-Webster、Wordnik APIs 在订阅模型中提供 APIs。

Also found Wordnet 3.1 which is pretty old. Not sure if it being updated or not.

还发现 Wordnet 3.1 已经很老了。不知道有没有更新。

回答by atNav

Yes! Google Dictionary access is removed. Thisdoes the same job but still has access.

是的!谷歌词典访问被删除。 做同样的工作,但仍然可以访问。

AFAIK, Dictionary Lookupis one of the most popular as listed by

AFAIK,Dictionary Lookup是最受欢迎的工具之一

www.programmableweb.com/apitag/dictionary/1?q=dictionary&sort=mashups

www.programmableweb.com/apitag/dictionary/1?q=dictionary&sort=mashups

回答by 8Fervor

To get the very best definitions I would go with api for Merriam-Webster or Oxford. As long as your use is not commercial you'll be okay up to 1,000 queries per day (Merriam-Webster) and up to 3,000 queries per month (Oxford).

为了获得最好的定义,我会使用 api for Merriam-Webster 或 Oxford。只要您的使用不是商业用途,您每天最多可以进行 1,000 次查询(Merriam-Webster),每月最多可以进行 3,000 次查询(牛津)。

回答by Suraj Jain

Unfortunately, like others have said, the Google Dictionary API is deprecated.

不幸的是,正如其他人所说,Google Dictionary API 已被弃用。

As I needed a Google Dictionary API for my project, I decided to create one.

因为我的项目需要一个 Google Dictionary API,所以我决定创建一个。

I scraped the web page for the URL https://www.google.com/#q=define+termwhere termis any word you want to get meaning of, and created the API. You can find it here.

我刮了网页的URLhttps://www.google.com/#q=define+term那里term是你想要得到的含义任何单词,并创建了API。你可以在这里找到它。

How to use

如何使用

The basic syntax of a URL request to the API is shown below:

对 API 的 URL 请求的基本语法如下所示:

https://api.dictionaryapi.dev/api/v1/entries/<--language_code-->/<--word-->

https://api.dictionaryapi.dev/api/v1/entries/<--language_code-->/<--word-->

As an example, to get definition of English word hello, you can send request to:

例如,要获取英文单词 hello 的定义,您可以发送请求到:

https://api.dictionaryapi.dev/api/v1/entries/en/hello

https://api.dictionaryapi.dev/api/v1/entries/en/hello

The API also provides other meanings of the word, example sentences, and synonyms, if any.

API 还提供了该词的其他含义、例句和同义词(如果有)。

If you want me to include any other details, please comment and I will happily extend the API to cover your needs.

如果您希望我包含任何其他详细信息,请发表评论,我将很乐意扩展 API 以满足您的需求。

The source code is on GitHub.

源代码在GitHub 上