簡體   English   中英

如何獲得頻率大於的單詞列表?

[英]How to get a list of words with frequency greater than?

我從數據框中創建了一個單詞列表並從中刪除了停用詞。 我想創建一個頻率大於某個值 n 的單詞列表。 我怎么做。

Here is my code to generate the list:

tokenizer = RegexpTokenizer(r"\w+(?:[-']\w+)?")
wineData['description'] = wineData['description'].apply(lambda x: 
str.lower(x))
wineDataTokenized = wineData['description'].apply(lambda x: [el for el in 
tokenizer.tokenize(x) if el not in stop_words])
filteredList = chain.from_iterable(wineDataTokenized)
frequencyList = FreqDist(filteredList)
highFreq = list(frequencyList.keys())
wordstring = 'it was the best of times it was the worst of times '
wordstring += 'it was the age of wisdom it was the age of foolishness'
wordlist = wordstring.split()

wordfreq = []
for w in wordlist:
    wordfreq.append(wordlist.count(w))

print("String\n" + wordstring +"\n")
print("List\n" + str(wordlist) + "\n")
print("Frequencies\n" + str(wordfreq) + "\n")
print("Pairs\n" + str(zip(wordlist, wordfreq)))

來源: https : //programminghistorian.org/en/lessons/counting-frequencies

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM