CaoHaiNam commited on
Commit
51c2c06
1 Parent(s): c58e97a

update code

Browse files
Files changed (1) hide show
  1. app.py +17 -15
app.py CHANGED
@@ -3,22 +3,24 @@ import siameser
3
  import norm_typing
4
  import json
5
  import logging
6
- # import os
7
- # import parameters
8
- # import stat
9
- # import utils
 
10
 
11
  std = siameser.Siameser(stadard_scope='all')
12
 
13
- # directory = parameters.LOG_DIRECTORY
14
- # file_path = os.path.join(directory, parameters.LOG_RESULT_FILE)
15
- # if not os.path.exists(directory):
16
- # os.mkdir(directory)
17
- # os.chmod(directory, stat.S_IRWXU)
18
- # data = []
19
- # with open(file_path, 'w', encoding='utf8') as f:
20
- # json.dump(data, f, ensure_ascii=False, indent=4)
21
- # os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR)
 
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
- # utils.save_result(file_path, top_5)
 
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