iwords.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:ip6words 作者: lstn 项目源码 文件源码
def load_words(num_words):

    words = get_words_from_nltk()
    fdist = nltk.FreqDist(words)

    fdistmc = fdist.most_common()

    nd = OrderedDict()
    nda = []

    occurences = set([wt[1] for wt in fdistmc])
    occurences = sorted(occurences, key=int, reverse=True)

    for idx in occurences:
        nd[idx] = sorted([wt[0] for wt in fdistmc if wt[1] == idx])

    for key, val in nd.items():
        nda += val

    words = nda[:num_words]
    return words
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号