如何在Python中实现这一点? Combining Lists of Word Frequency Data
假设我有两个列表A和B,都包含单词&;一个文件的频率按频率降序排列,我怎样才能完成Python中的问题
from FrequentWords import *
from WordFrequencies import * # makes the list with words&frequencies
L = WordFrequencies('file.txt')
words1 = L[0]
freqs1 = L[1]
L1 = computeWordFrequencies('file1.txt')
words2 = L1[0]
freqs2 = L1[1]
words = zip(*sorted(zip(L,L1)))
both1 = sorted(freqs1+freqs2,reverse=True)
common_words = set(words1) & set(words2)
frequency_common_words = both1
如果您的起始数据在字典中,那么它是可行的:
我会用
collections.Counter
:相关问题 更多 >
编程相关推荐