如何搜索单词定义?

时间:2011-10-12 13:41:11

标签: android api search dictionary

我正在使用Android中的应用程序,我需要从Google中选择一个单词并显示其定义。我是否必须使用Google或其他API提供的某些搜索API?

一个例子可以做。谢谢!

1 个答案:

答案 0 :(得分:1)

Google Dictionary似乎已不再可用,但即使是这样,API也是unavailable to 3rd parties。相反,我发现了几种替代选择。


XML字典交换格式

您可以使用所需语言的XDXFdownload a flat-file dictionary,并使用哈希表对文件进行适当索引。

这有两个明显的优点:

  • 支持字典查找不需要网络访问

  • 它最终更灵活,因为数据可以轻松操作(排序,过滤,特殊格式化),以更好地支持应用程序设计和要求。


Abbreviations.com API

如果您不想自己酿造自己的哈希表, abbreviations.com 有一个public dictionary API,它使用REST来获取给定单词的XML格式的定义信息。< / p>

示例请求网址:

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

示例回复:

<?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>