-
Notifications
You must be signed in to change notification settings - Fork 2
/
hmi.py
66 lines (56 loc) · 1.76 KB
/
hmi.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
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from app.collect import Collect
from app.miner.mining import Mining
from app.storage import Storage
from app.trainer.training import Training
from app.cli import Cli
def start(cli):
cli.clear_terminal()
cli.dashboard()
cli.waiting_input()
def display_help(cli):
cli.clear_terminal()
cli.help()
def collect(cli):
if not cli.args:
cli.error(cli.option)
else:
tweets = Collect(cli.args[0]).search()
Storage('collected').save(tweets)
cli.success(cli.option)
def training():
data = Storage('collected').load()
tweets = Training(data).evaluate()
Storage('trained').save(tweets)
def prediction():
collect_files = Storage('collected').load()
trained_files = Storage('trained').load()
Mining(collect_files, trained_files).start()
if __name__ == '__main__':
"""
Human-Machine Interface
"""
cli = Cli()
start(cli)
while cli.option != 'x':
if cli.option == 'h':
display_help(cli)
elif cli.option == 'c' or cli.option == "collect":
collect(cli)
elif cli.option == 't' or cli.option == "training":
training()
elif cli.option == 'p' or cli.option == "prediction":
prediction()
elif cli.option == 'tweets':
data = Storage('collected').load()
cli.tweets_colleted(data)
elif cli.option == 'tweets trained':
data = Storage('trained').load()
cli.tweets_trained(data)
elif cli.option == 'tweets metrics':
collected = Storage('collected').load()
trained = Storage('trained').load()
cli.tweets_metrics(collected, trained)
cli.waiting_input()
cli.finished()