-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDriver.py
68 lines (46 loc) · 1.59 KB
/
Driver.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
57
58
59
60
61
62
63
64
65
66
67
import datetime
from Database.Database import database
from TwitterFiles.TrendTwitter import TrendTwitter
from TwitterFiles.SentimentalAnalysis import SentimentEngine
main_locations = ['india', 'world']
all_locations = ['world',
'india',
'newyork',
'toronto',
'sydney',
'london',
'madrid',
'paris',
]
TrendData = {}
TrendDB_name = 'TrendDB'
TrendDB = database(TrendDB_name)
for location in all_locations:
obj = TrendTwitter(location)
TrendData[location] = obj.getTrends()
TrendDB.dump(TrendData)
SentimentData = {}
SentimentDB_name = 'SentimentDB'
SentimentDB = database(SentimentDB_name)
KeywordData = {}
KeywordDB_name = 'KeywordDB'
KeywordDB = database(KeywordDB_name)
for location in main_locations:
obj = TrendTwitter(location)
Trends = obj.getTrends()
SentimentData[location] = []
for num,Trendname in enumerate(Trends):
Trend = SentimentEngine(Trendname)
TrendScore = {}
Trend.sentimental_analysis()
Trend.keyword_extraction()
Keywords = Trend.get_keywords()
postive, negative = Trend.get_sentiment_scores()
TrendScore['name'] = Trendname
TrendScore['rank'] = num + 1
TrendScore['positive'] = postive
TrendScore['negative'] = negative
KeywordData[Trendname] = Keywords
SentimentData[location].append(TrendScore)
SentimentDB.dump(SentimentData)
KeywordDB.dump(KeywordData)