How to search for word definitions?

我与影子孤独终老i 提交于 2019-12-22 17:30:12

问题


I am working on a app in android where I need to select a word and display its definition from Google. Do I have to use some search API provided by Google, or another API?

An example will do. Thanks!


回答1:


It seems Google Dictionary is no longer available, but even when it was, the API was unavailable to 3rd parties. Instead, I found several alternative options.


XML Dictionary Exchange Format

You could use XDXF to download a flat-file dictionary in your desired language, and use a hash table to index the file appropriately.

This has two distinct advantages:

  • Network access is not required to support dictionary look-ups

  • It's ultimately more flexible because the data can be easily manipulated (sorted, filtered, specially formatted) to better support application design & requirements.


Abbreviations.com API

If you prefer not to home-brew your own hash-table, abbreviations.com has a public dictionary API that uses REST to obtain definition information in XML format for a given word.

Sample Request URL:

http://www.abbreviations.com/services/v1/defs.aspx?tokenid=tk324324&word=consistent 

Sample Response:

<?xml version="1.0" encoding="UTF-8"?>
<results>
  <result>
    <term>consistent, uniform</term>
    <definition>the same throughout in structure or composition</definition>
    <partofspeech>adj</partofspeech>
    <example>
       bituminous coal is often treated as a consistent and homogeneous product
    </example>
  </result>
</results>


来源:https://stackoverflow.com/questions/7740995/how-to-search-for-word-definitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!