update code
Browse files
app.py
CHANGED
@@ -3,22 +3,24 @@ import siameser
|
|
3 |
import norm_typing
|
4 |
import json
|
5 |
import logging
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
std = siameser.Siameser(stadard_scope='all')
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
22 |
|
23 |
count = 0
|
24 |
|
@@ -26,9 +28,9 @@ def standardize(raw_address):
|
|
26 |
global count
|
27 |
raw_address = norm_typing.norm_vietnamese_sentence_accent(raw_address)
|
28 |
top_1, top_5 = std.get_top_k(raw_address, 5)
|
29 |
-
#
|
|
|
30 |
count += 1
|
31 |
-
# logging.info(f'Request {count}')
|
32 |
if count % 10 == 9:
|
33 |
print(f'Request: {count}')
|
34 |
return top_1, top_5
|
|
|
3 |
import norm_typing
|
4 |
import json
|
5 |
import logging
|
6 |
+
#
|
7 |
+
import os
|
8 |
+
import parameters
|
9 |
+
import stat
|
10 |
+
import utils
|
11 |
|
12 |
std = siameser.Siameser(stadard_scope='all')
|
13 |
|
14 |
+
#
|
15 |
+
directory = parameters.LOG_DIRECTORY
|
16 |
+
file_path = os.path.join(directory, parameters.LOG_RESULT_FILE)
|
17 |
+
if not os.path.exists(directory):
|
18 |
+
os.mkdir(directory)
|
19 |
+
os.chmod(directory, stat.S_IRWXU)
|
20 |
+
data = []
|
21 |
+
with open(file_path, 'w', encoding='utf8') as f:
|
22 |
+
json.dump(data, f, ensure_ascii=False, indent=4)
|
23 |
+
os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR)
|
24 |
|
25 |
count = 0
|
26 |
|
|
|
28 |
global count
|
29 |
raw_address = norm_typing.norm_vietnamese_sentence_accent(raw_address)
|
30 |
top_1, top_5 = std.get_top_k(raw_address, 5)
|
31 |
+
#
|
32 |
+
utils.save_result(file_path, top_5)
|
33 |
count += 1
|
|
|
34 |
if count % 10 == 9:
|
35 |
print(f'Request: {count}')
|
36 |
return top_1, top_5
|