-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_GUI.py
78 lines (63 loc) · 2.75 KB
/
main_GUI.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
70
71
72
73
74
75
76
77
78
from src.visulalisation_module.load_srt import LoadSrtDialog
from src.visulalisation_module.export import ExportDialog
from src.visulalisation_module.no_translation_list import NoTranslationController
from src.visulalisation_module.export import ExportDialog
from src.visulalisation_module.most_frequent_list import MostFrequentController
from src.database_integration_module.db_helpers import DbHelpers
from PyQt5 import QtWidgets
from src.config_manip.config_manip import Config
import sys
from os import path
import logging
if __name__ == "__main__":
#config
config = Config("configs/config.yaml")
config.read()
#database
dbh = DbHelpers(config.get()["database_filename"])
dbh.reset_film_stats()
#logging module
logger = logging.getLogger("main_logger")
logger.setLevel(logging.INFO)
err_stream_handler = logging.StreamHandler()
err_stream_handler.setLevel(logging.WARNING)
log_file_handler = logging.FileHandler(config.get()["logs_filename"])
log_file_handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s:%(levelname)s: %(message)s')
err_stream_handler.setFormatter(formatter)
log_file_handler.setFormatter(formatter)
logger.addHandler(log_file_handler)
logger.addHandler(err_stream_handler)
#GUI
app = QtWidgets.QApplication(sys.argv)
load_srt = LoadSrtDialog(config)
app.exec_()
if load_srt.no_translations_words:
logger.info("number of words without translation: %d", len(load_srt.no_translations_words))
no_translations = NoTranslationController(load_srt.no_translations_words)
app.exec_()
black_list = no_translations.getBlacklist()
for item in black_list:
dbh.add_to_blacklist(item)
translated_words = no_translations.getList()
for item in translated_words:
dbh.insert_basic_form(item[0], 5.0, item[1:])
dbh.insert_known_word(item[0], item[0])
treshold = min(dbh.get_biggest_frequency()*0.7, 10)
most_frequent_words = dbh.get_most_frequent_words(treshold)
logger.info("number of most frequent words: %d", len(most_frequent_words))
if most_frequent_words:
most_frequent = MostFrequentController(most_frequent_words)
app.exec_()
score = most_frequent.getScore()
known_words = most_frequent.get_known_words()
logger.info("most frequent score: %d", score)
from_stats = dbh.get_words_from_stats()
to_be_exported = []
for word in from_stats:
if word['word'] not in known_words:
to_be_exported.append(word)
logger.info("number of words to be exported: %d", len(to_be_exported))
export_dialog = ExportDialog(config, to_be_exported, score, len(most_frequent_words))
app.exec_()
sys.exit()