1

私のdjangoアプリケーションでは、ユーザーはテキストボックスにいくつかの文字を入力し、文字に基づいて英語の辞書から一般的な単語を提供し、それをユーザーに提案する必要があります.

利用可能な一般的な英語辞書データベース、またはタスクを達成できる他のサイトからのある種のAPIはありますか

4

1 に答える 1

4

アナグラムを見つけることができるプログラムを探しているようです。これは非ジャンゴソリューションです。Joel が提案するように、/usr/share/dict/words を使用します。

from collections import defaultdict

def canonical_form(word):
    return tuple(sorted(word))

anagrams = defaultdict(list)

for word in open("/usr/share/dict/words"):
    word = word.lower().strip()
    anagrams[canonical_form(word)].append(word)

while True:
    print anagrams[canonical_form(raw_input())]
于 2012-11-29T04:53:32.893 に答える