-
Notifications
You must be signed in to change notification settings - Fork 0
/
movierevies.py
28 lines (23 loc) · 992 Bytes
/
movierevies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#TO KNOW DETAILS https://stackoverflow.com/questions/21107075/classification-using-movie-review-corpus-in-nltk-python
# vip https://www.programcreek.com/python/example/98503/nltk.corpus.movie_reviews.fileids
import nltk
nltk.download("wordnet")
nltk.download("movie_reviews")
import random
from nltk.corpus import movie_reviews
documents = [(list(movie_reviews.words(fileid)), category)
for category in movie_reviews.categories()
for fileid in movie_reviews.fileids(category)]
random.shuffle(documents)
print(documents[1])
all_words = []
for w in movie_reviews.words():
all_words.append(w.lower())
all_words = nltk.FreqDist(all_words)
print(all_words.most_common(5))
print(all_words["stupid"])
documents = [(list(movie_reviews.words(fileid)), category)
for category in movie_reviews.categories()
for fileid in movie_reviews.fileids(category)]
print(all_words.most_common(5))
#print(all_words["stupid"])