Spaces:
Sleeping
Sleeping
update code: add save result func
Browse files
app.py
CHANGED
@@ -3,22 +3,30 @@ import siameser
|
|
3 |
import norm_typing
|
4 |
import json
|
5 |
import logging
|
6 |
-
|
|
|
|
|
|
|
7 |
|
8 |
-
# print(1)
|
9 |
std = siameser.Siameser(stadard_scope='all')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
count = 0
|
11 |
|
12 |
def standardize(raw_address):
|
13 |
global count
|
14 |
raw_address = norm_typing.norm_vietnamese_sentence_accent(raw_address)
|
15 |
-
std_add = std.standardize(raw_address)
|
16 |
-
std_address = dict()
|
17 |
-
# top_1 = std.standardize(raw_address)
|
18 |
-
# detail_address = Utils.get_detail_address(raw_address, main_address)
|
19 |
-
# std_address['detail address'] = detail_address
|
20 |
-
# std_address['main address'] = main_address
|
21 |
top_1, top_5 = std.get_top_k(raw_address, 5)
|
|
|
22 |
count += 1
|
23 |
# logging.info(f'Request {count}')
|
24 |
if count % 10 == 9:
|
@@ -27,7 +35,6 @@ def standardize(raw_address):
|
|
27 |
|
28 |
|
29 |
demo = gr.Interface(
|
30 |
-
# fn=test,
|
31 |
fn=standardize,
|
32 |
inputs=gr.Textbox(label='raw address', lines=1, placeholder="Nhập địa chỉ thô"),
|
33 |
outputs=[gr.JSON(label='stadard address'), gr.JSON(label='top 5 standard addresses')],
|
@@ -44,15 +51,8 @@ demo = gr.Interface(
|
|
44 |
'dablend hostel, 417/2 hoà hảo, phường 5, quận 10, hồ chí minh, vietnam',
|
45 |
'17-05, tower 4,the sun avenue, 28 mai chi tho, district 2, ho chi minh city'
|
46 |
],
|
47 |
-
# article='Contact<br>Email: chnhust1@gmail.com <br> Facebook: https://www.facebook.com/CaoHaiNamHust/'
|
48 |
article='Contact<br>Email: chnhust1@gmail.com'
|
49 |
)
|
50 |
|
51 |
-
# with gr.Blocks() as demo:
|
52 |
-
# name = gr.Textbox(label='raw address', placeholder="150 kim hoa ha noi")
|
53 |
-
# output1 = gr.Textbox(label='standard address')
|
54 |
-
# output2 = gr.Textbox(label='top 5 addresses')
|
55 |
-
# greet_btn = gr.Button("standardize")
|
56 |
-
# greet_btn.click(fn=standardize, inputs=name, outputs=[output1, output2])
|
57 |
|
58 |
demo.launch()
|
|
|
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 |
|
25 |
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:
|
|
|
35 |
|
36 |
|
37 |
demo = gr.Interface(
|
|
|
38 |
fn=standardize,
|
39 |
inputs=gr.Textbox(label='raw address', lines=1, placeholder="Nhập địa chỉ thô"),
|
40 |
outputs=[gr.JSON(label='stadard address'), gr.JSON(label='top 5 standard addresses')],
|
|
|
51 |
'dablend hostel, 417/2 hoà hảo, phường 5, quận 10, hồ chí minh, vietnam',
|
52 |
'17-05, tower 4,the sun avenue, 28 mai chi tho, district 2, ho chi minh city'
|
53 |
],
|
|
|
54 |
article='Contact<br>Email: chnhust1@gmail.com'
|
55 |
)
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
demo.launch()
|