Python 按用法对单词进行排序

Python 按用法对单词进行排序,python,nltk,Python,Nltk,我有一个英文单词列表(大约10000个),我想根据它们在文学、报纸、博客等中的用法对它们进行排序。我可以用Python或其他语言对它们进行排序吗?我听说了NLTK,这是我所知道的最有帮助的库。或者该任务用于其他工具 谢谢您可以使用。然后,代码就简单到: l = get_iterable_or_list_of_words() # That is up to you c = collections.Counter(l) print(c.most_common()) 我对自然语言处理知之甚少,但我认

我有一个英文单词列表(大约10000个),我想根据它们在文学、报纸、博客等中的用法对它们进行排序。我可以用Python或其他语言对它们进行排序吗?我听说了
NLTK
,这是我所知道的最有帮助的库。或者该任务用于其他工具

谢谢

您可以使用。然后,代码就简单到:

l = get_iterable_or_list_of_words() # That is up to you
c = collections.Counter(l)
print(c.most_common())

我对自然语言处理知之甚少,但我认为Python是用于此目的的理想语言

谷歌搜索“Python自然语言”发现:

对StackOverflow的搜索找到了以下答案:

这反过来又与模式相关联:

你们可能想看看这个模式,这看起来很有希望


祝你好运,玩得开心

Python和NLTK是对单词列表进行排序的完美工具,因为NLTK附带了一些英语语料库,您可以从中提取频率信息

以下代码将按照棕色语料库中单词频率的顺序打印给定的
单词列表

import nltk
from nltk.corpus import brown

wordlist = ["corpus","house","the","Peter","asdf"]
# collect frequency information from brown corpus, might take a few seconds
freqs = nltk.FreqDist([w.lower() for w in brown.words()])
# sort wordlist by word frequency
wordlist_sorted = sorted(wordlist, key=lambda x: freqs[x.lower()], reverse=True)
# print the sorted list
for w in wordlist_sorted:
    print w
输出:

>>> 
the
house
Peter
corpus
asdf

如果你想使用不同的语料库或获取更多信息,你应该看看。

我正在寻找一个图书馆,它可以在一些数据库中查找单词,这些数据库可以下载或在线查询,并且有用法的统计数据(因为我没有统计数据).这些工具很有用,但它们能满足我的要求吗?谢谢,这正是我想要的。