【问题标题】:English dictionary as txt or xml file with support of synonyms [closed]支持同义词的 txt 或 xml 文件的英语词典 [关闭]
【发布时间】:2010-04-19 11:46:25
【问题描述】:

谁能指出我可以将英语词典下载为 txt 或 xml 文件的地方。我正在为自己构建一个简单的应用程序,并正在寻找可以立即开始使用而无需学习复杂 API 的东西。

对同义词的支持会很好,也就是说,检索特定单词的所有同义词应该会更容易。

如果字典能列出它们不同的单词的英式和美式拼写,那就太棒了。

即使是小字典(几千字)也没关系,我只需要它用于一个小项目。

如果价格合理,并且字典易于使用,我什至愿意购买 - 简单的 XML 会很棒。

请指路。

【问题讨论】:

标签: dictionary nlp wordnet


【解决方案1】:

WordNet 是你想要的。它很大,包含十万多个条目,并且可以免费使用。

但是,它不存储为 XML。要访问数据,您需要使用现有的WordNet APIs 之一作为您选择的语言。

使用 API 通常非常简单,因此我认为您不必担心“学习 (a) 复杂的 API”。例如,借用WordNet How to 为基于Python 的Natural Language Toolkit (NLTK)

 >>> from nltk.corpus import wordnet
 >>> 
 >>> # Get All Synsets for 'dog'
 >>> # This is essentially all senses of the word in the db
 >>> wordnet.synsets('dog')
 [Synset('dog.n.01'), Synset('frump.n.01'), Synset('dog.n.03'), 
  Synset('cad.n.01'), Synset('frank.n.02'),Synset('pawl.n.01'), 
  Synset('andiron.n.01'), Synset('chase.v.01')]
 
 >>> # Get the definition and usage for the first synset
 >>> wn.synset('dog.n.01').definition
 'a member of the genus Canis (probably descended from the common 
 wolf) that has been domesticated by man since prehistoric times; 
 occurs in many breeds'
 >>> wn.synset('dog.n.01').examples
 ['the dog barked all night']

 >>> # Get antonyms for 'good'
 >>> wordnet.synset('good.a.01').lemmas[0].antonyms()
 [Lemma('bad.a.01.bad')]

 >>> # Get synonyms for the first noun sense of 'dog'
 >>> wordnet.synset('dog.n.01').lemmas
 [Lemma('dog.n.01.dog'), Lemma('dog.n.01.domestic_dog'), 
 Lemma('dog.n.01.Canis_familiaris')]

 >>> # Get synonyms for all senses of 'dog'
 >>> for synset in wordnet.synsets('dog'): print synset.lemmas
 [Lemma('dog.n.01.dog'), Lemma('dog.n.01.domestic_dog'), 
 Lemma('dog.n.01.Canis_familiaris')]
 ...
 [Lemma('frank.n.02.frank'), Lemma('frank.n.02.frankfurter'), 
 ...

虽然 WordNet 中存在美式英语偏见,但它支持英式拼写和用法。例如,您可以查找“color”,“lift”的同义词之一是“elevator.n.01”。

关于 XML 的说明

如果必须将数据表示为 XML,您可以轻松地使用其中一种 API 来访问 WordNet 数据库 并将其转换为 XML,例如见Thinking XML: Querying WordNet as XML

【讨论】:

  • 如果您更喜欢原始 xml,Guy Lapalme(蒙特利尔大学)did the job already
  • 我想补充一点,wordnet 不包含形容词或副词的变位、复数或其他扩展。
【解决方案2】:

我知道这个问题已经很老了,但我自己发现它是一个 txt 文件时遇到了问题,所以如果有人要查找同义词和反义词 txt 文件数据库,最简单但非常详细的尝试 https://ia801407.us.archive.org/10/items/synonymsantonyms00ordwiala/synonymsantonyms00ordwiala_djvu.txt.

【讨论】:

  • 再次,老问题,新评论。使用 notepad++ 将其修改为使用正则表达式的所需输出非常容易。谷歌您的问题,将 notepad++ 添加到您的查询中。
【解决方案3】:

我过去使用过Roget's thesaurus。它在纯文本文件中具有同义词信息。还有一些java代码可以帮助你解析文本。

这些页面提供了指向大量叙词表/词汇资源的链接,其中一些可以免费下载。

http://www.w3.org/2001/sw/Europe/reports/thes/thes_links.html

http://www-a2k.is.tokushima-u.ac.jp/member/kita/NLP/lex.html

【讨论】:

    【解决方案4】:

    试试WordNet

    【讨论】:

      猜你喜欢
      • 2011-05-27
      • 2011-07-06
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多