Answer the question
In order to leave comments, you need to log in
How to find the most used words in a book using python?
There is a book in TXT format. It is required to find the frequency of the words used and save the first 1000 words to a file. I can not understand in which direction I should dig. While studying https://courses.edx.org/courses/course-v1:Microsof... .
Answer the question
In order to leave comments, you need to log in
from collections import Counter
x = open('Война и мир.txt', encoding='utf8').read()
c = Counter(x.split()) # Сплит нужен, чтобы вышел список слов, иначе посчитаем частотность символов
c.most_common()
Make a map where the key is the word and the value is the frequency. Each time a word occurs, increase the frequency by 1. Then take the 1000 maximum frequencies and output the keys to a file. That's all.
Based on this program, you can finish https://en.wikiversity.org/wiki/%D0%9F%D1%80%D0%B8...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question