From a507fff651b26a5b6da55f2339981d076701749c Mon Sep 17 00:00:00 2001 From: hsafaei Date: Wed, 17 Sep 2025 14:53:16 +0330 Subject: [PATCH] fix bugs --- .gitignore | 1 + common/normalizer.py | 24 ++++++++------ temp_codes.py | 79 +++++++++++++++++++++++--------------------- 3 files changed, 56 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index c14b462..de117f4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules data_back/ data/ output/ +__pycache__/ # local env files config.env diff --git a/common/normalizer.py b/common/normalizer.py index 36d0d87..01a5ff2 100644 --- a/common/normalizer.py +++ b/common/normalizer.py @@ -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) diff --git a/temp_codes.py b/temp_codes.py index 4087d6b..bb45ad5 100644 --- a/temp_codes.py +++ b/temp_codes.py @@ -4,17 +4,17 @@ from common.text_normalizer import TextNormalizer # from general import * from common.general_functions import * from common.elastic_helper import ElasticHelper -from create_relation_tags import * +from for_ai.create_relation_tags import * from temp_refactor_gn_dataset import * load_dotenv(dotenv_path='config.env') -host=os.getenv('HOST_160') -password=os.getenv('HOST_160_PASS') +# host=os.getenv('HOST_160') +# password=os.getenv('HOST_160_PASS') -# host=os.getenv('HOST_112') -# password=os.getenv('HOST_112_PASS') +host=os.getenv('HOST_112') +password=os.getenv('HOST_112_PASS') # host=os.getenv('HOST_118') # password=os.getenv('HOST_118_PASS') @@ -41,9 +41,14 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map) # elastic.backupIndexToZipfile("G:/Project2/111/haditha", "dh_volume") # elastic.backupIndexToZipfile("G:/Project2/111/haditha", "dh_haditha") -#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section-m1") -elastic.createIndex( 'mj_qa_section-m1', 'majles', 'mj_qa_section') -elastic.restorFileToElastic2('G:/Project2/111/server112/mj_qa_section-m1.zip', 'mj_qa_section-m1', 'majles', False, 'mj_qa_section') +# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_domain") +# elastic.createIndex( 'mj_qa_domain', 'majles', 'mj_domain') +# elastic.restorFileToElastic2('G:/Project2/111/mj_qa_domain.zip', 'mj_qa_domain', 'majles', False, 'mj_domain') + + +# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section-m1") +# elastic.createIndex( 'mj_qa_section-m1', 'majles', 'mj_qa_section') +# elastic.restorFileToElastic2('G:/Project2/111/server112/mj_qa_section-m1.zip', 'mj_qa_section-m1', 'majles', False, 'mj_qa_section') # elastic.backupIndexToZipfile("G:/Project2/111", "gn_calendar") #elastic.createIndex( 'gn_calendar', 'general', 'gn_calendar') @@ -150,35 +155,35 @@ path_back = 'G:/Project2/111/server112/' # elastic.restorFileToElastic2('G:/Project2/111/mj_qa_section_2_majles_repair.zip', 'mj_qa_section', 'majles', False, 'mj_qa_section') -body= { - "query": { - "terms": { - "qanon_id": [ - "qq83354", - "qq83382", - "qq112748", - "qq112296", - "qq83435", - "qq114127", - "qq175888", - "qq85335", - "qq84208", - "qq114652", - "qq114640" - ] - } - }, - "sort": [ - { - "qanon_id": { - "order": "asc" - }, - "child_order": { - "order": "asc" - } - } - ] -} +# body= { +# "query": { +# "terms": { +# "qanon_id": [ +# "qq83354", +# "qq83382", +# "qq112748", +# "qq112296", +# "qq83435", +# "qq114127", +# "qq175888", +# "qq85335", +# "qq84208", +# "qq114652", +# "qq114640" +# ] +# } +# }, +# "sort": [ +# { +# "qanon_id": { +# "order": "asc" +# }, +# "child_order": { +# "order": "asc" +# } +# } +# ] +# } #elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section", "mj_qa_section_Aab", body, False, ["content", "simplifies", "tcode_sub_old", "tcode_main_old", "code-ai", "ai_keywords"])