forked from bautzon/NLP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounter.py
33 lines (24 loc) · 890 Bytes
/
Counter.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
29
30
31
32
33
import nltk,re
from nltk.corpus import twitter_samples
from collections import Counter
nltk.download('twitter_samples')
all_positive_tweets = twitter_samples.strings('positive_tweets.json')
all_negative_tweets = twitter_samples.strings('negative_tweets.json')
all_positive_tweets[0:10]
newtext = all_positive_tweets[0:100]
from Cleaner import *
#print (newtext)
print(len(newtext))
positive_counts = Counter()
negative_counts = Counter()
total_counts = Counter()
for i in range(len(all_positive_tweets)):
for word in all_positive_tweets[i].lower().split(" "):
positive_counts[word]+=1
total_counts[word]+=1
for i in range(len(all_negative_tweets)):
for word in all_negative_tweets[i].lower().split(" "):
negative_counts[word]+=1
total_counts[word]+=1
#print(positive_counts.most_common()[0:10])
#print(positive_counts.most_common()[0:10])