/
performance_testing.py
34 lines (29 loc) · 1.09 KB
/
performance_testing.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
"""This module is for compare hazm and this normalizer"""
# pylint: skip-file
import time
from tqdm import tqdm
from src import NormalizerBuilder
if __name__ == '__main__':
import hazm
with open('./input.txt', encoding="utf-8") as f:
text = f.read()
norm = NormalizerBuilder() \
.alphabet_fa().alphabet_en() \
.digit_fa().punctuation_fa().diacritic_delete() \
.space_normal().tokenizing().remove_extra_spaces() \
.build()
start = time.time()
for i in tqdm(range(1)):
result = norm.normalize(text)
end = time.time()
print("ME : ", end - start)
with open("./output_piraye.txt", "w", encoding="utf-8") as text_file:
text_file.write(result)
start2 = time.time()
normalizer_hazm = hazm.Normalizer()
for i in tqdm(range(1)):
result2 = normalizer_hazm.normalize(text)
end2 = time.time()
print("Hazm : ", end2 - start2)
with open("./output_hazm.txt", "w", encoding="utf-8") as text_file:
text_file.write(result2)