-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
executable file
·69 lines (62 loc) · 2.14 KB
/
application.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
68
69
import argparse
from aggregator import Aggregator
from github_fetcher import GithubFetcher
from paper_fetcher import PaperFetcher
from database_client import DatabaseClient
import pdb
class Application:
def __init__(self):
self.keywords = ["numpy", "scikit", "tensorflow", "pytorch", "matlab"]
self.github_fetcher = GithubFetcher(self.keywords)
self.paper_fetcher = PaperFetcher()
self.db = DatabaseClient()
def get_paper_stats(self):
# Returns the (paper, conference, libraries) tuple of the most recently
# processed data. Not guranteed to be fresh.
rows = self.db.get_all_papers_stats()
formatted_result = []
for row in rows:
column_names = ['paper_title', 'conference_name'] + self.keywords
zipped = zip(column_names, row)
formatted_result.append(zipped)
return formatted_result
def get_conference_stats(self):
# Returns the (conference, library_count) tuple for each conference.
# Not guranteed to be fresh.
rows = self.db.get_all_conference_stats()
formatted_result = []
for row in rows:
column_names = ['conference_name'] + self.keywords
zipped = zip(column_names, row)
formatted_result.append(zipped)
return formatted_result
def start(self, response):
if response == "0":
# Run the offline pipeline.
self.paper_fetcher.start()
self.github_fetcher.start()
self.aggregator.start()
elif response == "1":
results = self.get_paper_stats()
for result in results:
print "================================="
print result
elif response == "2":
results = self.get_conference_stats()
for result in results:
print "================================="
print result
else:
print "Not a valid response"
if __name__=="__main__":
while True:
print "================================="
print "Press 0 to fetch/update data (only done once)"
print "Press 1 to see paper stats"
print "Press 2 to see conference stats"
print "================================="
response = raw_input()
if response == "4":
break
app = Application()
app.start(response)