forked from shivam-97/TwitterDataHandling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre.py
56 lines (45 loc) · 1.04 KB
/
pre.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
tweets = []
for line in open('foo/deepika.json'):
try:
tweets.append(json.loads(line))
except:
pass
print(len(tweets))
d = {}
value = 0
total = 0
for tweet in tweets :
print(tweet['entities']['urls'][0])
string = str(tweet['created_at'])
string = string.replace(",", " , ")
string = string.replace('"', ' " ')
string = string.replace("'", " ' ")
string = string.replace("?", " ? ")
string = string.replace("}", " } ")
string = string.replace("{", " { ")
string = string.replace("/", " / ")
string = string.replace(".", " . ")
string = string.replace("|", " | ")
words = string.split()
count = 1
s = ''
for word in words :
# print(word)
if count <=3 :
s = s + ' ' + word
elif count == 6 :
s = s + ' ' + word
count+= 1
#print(s)
if s in d :
d[s] = d[s] + 1
else :
d[s] = 1
for k in d :
value+=1
total+=d[k]
if((total/value) >= 20) :
print ('active')
else :
print('inactive')