M
M
Marina18022021-12-01 23:44:52
Python
Marina1802, 2021-12-01 23:44:52

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'])


print(all_words.positive['magical'] doesn't work

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question