-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (51 loc) · 1.64 KB
/
main.py
File metadata and controls
60 lines (51 loc) · 1.64 KB
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
import json
from time import time
from pr_nlu_analysis import Repository
# main function for testing code
if __name__ == '__main__':
# '''
# to test nlu
file = open("fetched_data/test_data.json")
data = json.load(file)
print("Performing sentiment analysis...\n")
start_time = time()
repo = Repository(data, "pullRequests")
end_time = time()
print(repo)
print('\nSentiment analysis took', round(end_time - start_time, 3), 'seconds to run')
repo.to_csv()
'''
# or with data extraction
print("Enter an access token: ", end="")
auth = input()
pull_type = ""
valid = False
while not valid:
print("Enter a repo (owner/repo): ", end="")
owner_repo = input().split("/")
if len(owner_repo) != 2:
print("Invalid input")
else:
print("Get issues or pull requests? (i or p): ", end="")
letter = input()
if letter == "i":
pull_type = "issues"
valid = True
elif letter == "p":
pull_type = "pullRequests"
valid = True
else:
print("Invalid input")
if valid:
data = run_query(auth, owner_repo[1], owner_repo[0], pull_type)
if pull_type == "issues":
pprint(data)
if pull_type == "pullRequests":
data = json.loads(data)
print("Performing sentiment analysis...\n")
start_time = time()
repo = Repository(data)
end_time = time()
print(repo)
print('\nSentiment analysis took', round(end_time - start_time, 3), 'seconds to run')
# '''