forked from daniil-dushenev/gagarin-hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_me.py
37 lines (24 loc) · 966 Bytes
/
run_me.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
import json
import pathlib
import typing as tp
import time
import final_solution
PATH_TO_TEST_DATA = pathlib.Path("data") / "test_texts.json"
PATH_TO_OUTPUT_DATA = pathlib.Path("results") / "output_scores.json"
def load_data(path: pathlib.PosixPath = PATH_TO_TEST_DATA) -> tp.List[str]:
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
return data
def save_data(data, path: pathlib.PosixPath = PATH_TO_OUTPUT_DATA):
with open(path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=1, ensure_ascii=False)
def main():
model_path = 'weights/DENCHIK3000'
alias_path = 'data/alias_dict.pickle'
synonyms_path = 'data/new_names_and_synonyms_i_already_letter_maybe.csv'
cfg = final_solution.solution.create_cfg(model_path, alias_path, synonyms_path)
texts = load_data()
scores = final_solution.solution.score_texts(texts, cfg)
save_data(scores)
if __name__ == '__main__':
main()