-
Notifications
You must be signed in to change notification settings - Fork 2
/
Analysis.py
67 lines (56 loc) · 1.69 KB
/
Analysis.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
# types
from typing import Callable, Union, NoReturn, Dict
# GLOBAL MODULES
import sys
from json import loads as str2json
# LOCAL MODULES
from interface import texts
from auth import getKey
from auth import createKey
from choice import choices
from utils.fileTreatment import readFile
from utils.fileTreatment import writeFile
from utils.colors import style
from check.checkModules import checkModules
from check.clientKey import getClientKey
from check.textToAnalyse import getTextToAnalyse
# <start> rules for test
try:
from auto_test.newFeature import newFeature
from auto_test.unique_test import unique_test
arguments = sys.argv
testFlags = {
'-tf': lambda: newFeature(),
'-tu': lambda: unique_test()
}
testFlags[arguments[1]]()
exit()
except IndexError:
pass
# <end> rules for test
if checkModules(texts, style):
import Algorithmia
import googletrans
def start() -> NoReturn:
"""
The kernel of algorithm
"""
CLIENT = getClientKey(Algorithmia)
TEXT = getTextToAnalyse()
texts.clearAndShowHeader(style)
print(texts.choicesMenu(style))
choice = input('> ')
texts.clearAndShowHeader(style)
selectChoice = {
'1': lambda: choices('tag', CLIENT, TEXT),
'2': lambda: choices('feeling', CLIENT, TEXT),
'3': lambda: choices('summarize', CLIENT, TEXT),
'4': lambda: choices('entity', CLIENT, TEXT),
'5': lambda: choices('frequency', CLIENT, TEXT),
'6': lambda: choices('count', CLIENT, TEXT),
'7': lambda: choices('email', CLIENT, TEXT),
'8': lambda: choices('date', CLIENT, TEXT)
}
selectChoice[choice]()
if __name__ == "__main__":
start()