This commit is contained in:
hsafaei
2025-09-17 14:53:16 +03:30
parent 3fe8ec8588
commit a507fff651
3 changed files with 56 additions and 48 deletions
+13 -11
View File
@@ -10,14 +10,13 @@ class Normalizer():
def __init__(self,
half_space_char='\u200c',
date_normalizing_needed=False,
pinglish_conversion_needed=False,
train_file_path="resource/tokenizer/Bijan_khan_chunk.txt",
token_merger_path="resource/tokenizer/TokenMerger.pckl"):
self.dir_path = os.path.dirname(os.path.realpath(__file__)) + "/"
self.dic1_path = self.dir_path + 'resource/normalizer/Dic1_new.txt'
self.dic2_path = self.dir_path + 'resource/normalizer/Dic2_new.txt'
self.dic3_path = self.dir_path + 'resource/normalizer/Dic3_new.txt'
pinglish_conversion_needed=False):
self.resource_path = os.path.dirname(os.path.realpath(__file__)) + "/../"
self.dic1_path = self.resource_path + 'resource/normalizer/Dic1_new.txt'
self.dic2_path = self.resource_path + 'resource/normalizer/Dic2_new.txt'
self.dic3_path = self.resource_path + 'resource/normalizer/Dic3_new.txt'
self.dic1 = self.load_dictionary(self.dic1_path)
self.dic2 = self.load_dictionary(self.dic2_path)
self.dic3 = self.load_dictionary(self.dic3_path)
@@ -1091,12 +1090,15 @@ class DateNormalizer():
class PinglishNormalizer():
def __init__(self):
self.data_helper = DataHelper()
self.file_dir = os.path.dirname(os.path.realpath(__file__)) + "/"
# self.resource_path = os.path.dirname(os.path.realpath(__file__)) + "/"
self.resource_path = os.path.dirname(os.path.realpath(__file__)) + "/../"
self.en_dict_filename = self.file_dir + "resource/tokenizer/enDict"
self.en_dict_filename = self.resource_path + "resource/tokenizer/enDict"
self.en_dict = self.data_helper.load_var(self.en_dict_filename)
self.fa_dict_filename = self.file_dir + "resource/tokenizer/faDict"
self.fa_dict_filename = self.resource_path + "resource/tokenizer/faDict"
self.fa_dict = self.data_helper.load_var(self.fa_dict_filename)