Answer the question
In order to leave comments, you need to log in
How to find the number of times a word is used among positive reviews?
name = input('Please, put your surname, name, group and number of Lab:')
a = name
print(a)
import nltk
nltk.download()
from nltk.corpus import movie_reviews
import random
doc = [(list(movie_reviews.words(fileid)), category)
for category in movie_reviews.categories()
for fileid in movie_reviews.fileids(category)]
random.shuffle(doc)
all_words = []
for w in movie_reviews.words():
all_words.append(w.lower())
all_words = nltk.FreqDist(all_words)
print(all_words.most_common(20))
print (all_words['magical'])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question