import_codes_to_list
This commit is contained in:
@@ -45,6 +45,12 @@ def isNeedHtml(html):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# erab
|
||||
def remove_arabic_diacritics(text):
|
||||
# Regular expression to match all Arabic diacritics
|
||||
diacritics_pattern = r'[\u064B-\u0652\u0670]'
|
||||
return re.sub(diacritics_pattern, '', text)
|
||||
|
||||
|
||||
def removeHtmlTags(html, exeptionTag=[]):
|
||||
|
||||
+23
-1
@@ -7,4 +7,26 @@
|
||||
قانون بودجه سال 1369کل کشور=qq84519
|
||||
قانون اصلاح مواد 4 و 6 قانون تغییر نام وزارت آبادانی و مسکن بوزارت مسکن و شهرسازی و تعیین وظایف آن=qq86848
|
||||
ائیننامه[آئین نامه] اجرای مالیات اراضی بایر موضوع تبصره 4 ماده 214 قانون مالیاتهای مستقیم مصوب 28ر12ر1345=qq115135
|
||||
قانون اعطای امتیاز نفط بشرکت نفط انگیس[انگلیس] و ایران محدود=qq85083
|
||||
قانون اعطای امتیاز نفط بشرکت نفط انگیس[انگلیس] و ایران محدود=qq85083
|
||||
آئین نامه اجرائی لایحه قانونی اصلاح لایحه قانونی واگذاری و احیاء اراضی در حکومت جمهوری اسلامی ایران مصوب 21/1/59=qq83760
|
||||
لایحه قانونی ملی کردن سهام شرکت سهامی انبارهای عمومی=qq83938
|
||||
لایحه قانونی الحاق سه تبصره به مواد 7 و 11 و 14 قانون تشکیل دادگاههای عمومی و یک تبصره بماده 17 قانون اصلاح قانون منع کشت خشخاش مصوب سال 1338 و اصلاح ماده 46 قانون اصول تشکیلات دادگستری=qq87062
|
||||
لایحه قانونی مالکیت و بهره برداری از اراضی واقع در آبخورسد دز و الغاء قردادهای کشت و صنعت=qq87024
|
||||
لایحه قانونی اصلاح قانون مربوط بسرسید سفته ها وتضمین نامه ها وبروات و چکها=qq86971
|
||||
تصمیم قانونی راجع به آئین نامه جلوگیری از آلودگی هوا=0
|
||||
قانون قراداد تشویق وحمایت متقابل سرمایه گذاری بین دولت ایران وجمهوری فدرال آلمان=qq85065
|
||||
قانون اجازه تحصیل مبلغ بیست و پنج میلیون دلار وام از صندوق وامهای عمرانی امریکا=qq85231
|
||||
رد لایحه راجع به تشکیل اداره دعاوی وزارت دارائی که در کمیسیون مشترک مجلسین رد شده است=qq114031
|
||||
آئین نامه اجرائی ماده 18 قانون اصلاح قانون مالیات بر درآمد=qq113975
|
||||
قانون مربوط بالحاق یک تبصره بماده 370 قانون امور حسبی و یک تبصره بماده 56 قانون شریع(تسریع) محاکمات=qq113534
|
||||
لایحه قانونی تصویب قرارداد بین المللی ارتباطات دوره منعقده در بوئنوس آیرس در سال 1331=qq113460
|
||||
قانون مربوط بموافقتنامه راجع به سرویسهای حمل و نقل بازرگانی منعقده بین دولت شاهنشاهی ایران و دولت هلند=qq114554
|
||||
تصمیم متخذه کمیسیون مشترک در مورد هزینه های دادگستری و ثبت و حق تمبر پروانه=qq113344
|
||||
قانون تصویب عهدنامه تسویه مسالمت آمیز اختلافات بین دولت شاهنشاهی ایران و دولت پادشاهی عراق=qq85019
|
||||
قانون راجع برشد متعاملین=qq112444
|
||||
قانون اصلاح مواد 13ر 41ر 43ر70ر111ر117قانون ثبت اسناد و املاک=qq112144
|
||||
قانون اجازه مبادله عهدنامه مودت منعقده بین دولتین ایران و افغانستان=qq84876
|
||||
قانون اصلاح جداول شماره (4) و (8) قانون برنامه چهارم توسعه اقتصادی، اجتماعی و فرهنگی جمهوری اسلامی ایران و قانون بودجه سال 1386 کل کشور به منظور تآمین کسری اعتبار گاز رسانی به روستاهای کشور=qq36662
|
||||
قانون الحاق دولت جمهوری اسلامی ایران به پروتکل 1992جهت اصلاح کنوانسیون بین المللی مسوولیت مدنی ناشی ازخسارت آلودگی نفتی ( 1969 ) و پروتکل 1992 جهت اصلاح کنوانسیون تاسیس یک صندوق بین المللی برای جبران خسارت آلودگی نفتی (1971)=qq116450
|
||||
قانون مربوط بقرداد فروش و خرید گاز طبیعی بین شرکت ملی ایران وشرکت متالیمکس (METALIMEX)چکسلواکی=qq86609
|
||||
قانون مربوط بقرداد فروش و خریدگازطبیعی بین شرکت ملی گاز ایران و شرکتهای روهرگاز Ruhrgaz گاز دوفرانس (Gaz de France)و نفت معدنی اطریش Oesterreichische Mineraloel Verwaltung Aktiengesellschaft=qq86601
|
||||
|
||||
+23
-12
@@ -49,6 +49,14 @@ def get_qanon_title_sample(text):
|
||||
text = re.sub(r"( |\u200C)+", "", text)
|
||||
return text
|
||||
|
||||
def get_section_title_sample(text):
|
||||
text = text_normalizer.normalize_search_qanon(text)
|
||||
text = text_normalizer.remove_arabic_diacritics(text)
|
||||
text = text_normalizer.hamzah_normal(text)
|
||||
text = text_normalizer.alaem_normal(text)
|
||||
text = re.sub(r"( |\u200C|\>|\<|-|ـ)+", "", text)
|
||||
return text
|
||||
|
||||
def searchSectionId(elastic, index_name, qanon_id, section_title):
|
||||
score = 100
|
||||
body = {
|
||||
@@ -73,12 +81,12 @@ def searchSectionId(elastic, index_name, qanon_id, section_title):
|
||||
}
|
||||
}
|
||||
s_res = elastic.es.search(index=index_name, body=body)
|
||||
section_title = re.sub(r"( |\u200C|\>|\<)+", "", section_title)
|
||||
section_title = get_section_title_sample(section_title)
|
||||
for item in s_res["hits"]["hits"]:
|
||||
other_info = item['_source']['other_info']
|
||||
title = other_info['full_path']
|
||||
# حذف اضافات
|
||||
title = re.sub(r"( |\u200C|\>|\<|-|ـ)+", "", title)
|
||||
title = get_section_title_sample(title)
|
||||
|
||||
if title == section_title :
|
||||
return item["_id"], 100, item
|
||||
@@ -191,7 +199,7 @@ def importDataToElastic(elastic, file_excel, index_name_o, tcode, file_log, resu
|
||||
column_names = df.columns.tolist()
|
||||
print(column_names)
|
||||
|
||||
file = open(file_log, 'w', encoding='utf8')
|
||||
file = open(file_log, 'w+', encoding='utf8')
|
||||
|
||||
dict_qanon_id = get_dict_qanon_title("qanon_title_ids.txt")
|
||||
# Print the list of rows
|
||||
@@ -267,11 +275,6 @@ def importDataToElastic(elastic, file_excel, index_name_o, tcode, file_log, resu
|
||||
if result_path == '' :
|
||||
directory_path = os.path.dirname(file_excel)
|
||||
result_path = directory_path + "/result/"
|
||||
|
||||
try:
|
||||
os.makedirs(result_path, exist_ok=True)
|
||||
except Exception as e:
|
||||
print(result_path)
|
||||
|
||||
file_name = os.path.basename(file_excel)
|
||||
file_excel2 = result_path + file_name.replace('.xlsx', '_result.xlsx')
|
||||
@@ -301,10 +304,15 @@ def run_in_directory(elastic, directory, output):
|
||||
for file in files :
|
||||
file_name = os.path.basename(file)
|
||||
code_name = os.path.splitext(file_name)[0]
|
||||
log_file = output + "/log_r_"+code_name+".txt"
|
||||
w1 = text_normalizer.split_words(code_name)[0]
|
||||
log_file = output + "/log_r_"+w1+".txt"
|
||||
file_path = os.path.join(directory, file)
|
||||
try:
|
||||
os.makedirs(output, exist_ok=True)
|
||||
except Exception as e:
|
||||
print(output)
|
||||
|
||||
# importDataToElastic(elastic, file_path, "mj_qa_section", code_name, log_file)
|
||||
importDataToElastic(elastic, file_path, "mj_qa_section", code_name, log_file)
|
||||
|
||||
|
||||
|
||||
@@ -321,9 +329,9 @@ path_base_map = "G:/Project2/gateway2_main/repo/_other/"
|
||||
elastic = ElasticHelper(host, password, "elastic", path_base_map)
|
||||
|
||||
|
||||
# run_in_directory(elastic, "./data/tcodes", "./data/tcodes/result")
|
||||
run_in_directory(elastic, "./data/tcodes", "./data/tcodes/result")
|
||||
|
||||
importDataToElastic(elastic, "./data/tcodes/مسکن و شهرسازی.xlsx", "mj_qa_section", "مسکن و شهرسازی", "./data/log_r3.txt")
|
||||
# importDataToElastic(elastic, "./data/tcodes/مسکن و شهرسازی.xlsx", "mj_qa_section", "مسکن و شهرسازی", "./data/log_r3.txt")
|
||||
# importDataToElastic(elastic, "./data/tcodes/آمار، برنامه و بودجه.xlsx", "mj_qa_section", "مسکن و شهرسازی", "./data/log_r_آمار.txt")
|
||||
# importDataToElastic(elastic, "./data/tcodes/آیین دادرسی مدنی.xlsx", "mj_qa_section", "مسکن و شهرسازی", "./data/log_r_دادرسی.txt")
|
||||
# importDataToElastic(elastic, "./data/tcodes/نفت و گاز.xlsx", "mj_qa_section", "مسکن و شهرسازی", "./data/log_r_نفت.txt")
|
||||
@@ -337,6 +345,9 @@ importDataToElastic(elastic, "./data/tcodes/مسکن و شهرسازی.xlsx", "m
|
||||
# text="قانون تشکیلات، وظایف و انتخابات شوراهای اسلامی کشور و انتخاب شهرداران مصوب 1/3/1375 و اصلاحات بعدی آن"
|
||||
text="قانون بودجه سال 1369کل کشور"
|
||||
|
||||
text="پیوست 3>متن >ضمیمه 1>قسمت الف>فصل پنجم>جدول الف-1-1-1 /5"
|
||||
# searchSectionId(elastic, "mj_qa_section", "qq240970", text )
|
||||
|
||||
# text = text_normalizer.date_correction(text)
|
||||
# text = re.sub(r"(\d+?) /(\d+?) /(\d+?)", r"\1/\2/\3", text)
|
||||
# text = re.sub(r"(\d)/(\d)/(\d{4})", r"0\1/0\2/\3", text)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import pandas as pd
|
||||
from config_base import *
|
||||
from general_functions import *
|
||||
from text_normalizer import TextNormalizer
|
||||
import pandas as pd
|
||||
import requests
|
||||
|
||||
|
||||
def import_codes_to_list(file_excel, project_id):
|
||||
|
||||
df = pd.read_excel(file_excel, sheet_name=0)
|
||||
count = 0
|
||||
rows_list = df.to_dict(orient='records')
|
||||
total = len(df[0])
|
||||
print('total : ', total)
|
||||
|
||||
column_names = df.columns.tolist()
|
||||
print(column_names)
|
||||
try:
|
||||
for row in rows_list:
|
||||
pass
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
|
||||
|
||||
import_codes_to_list("./data/کدهای 50 گانه.xlsx", 8)
|
||||
+13
-13
@@ -56,22 +56,22 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
|
||||
#-------------------------------------------------------
|
||||
## backup from hamfahmi.ir
|
||||
#-------------------------------------------------------
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_bayanat")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_synonym")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_log_search")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_log_change")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_calendar") # ???
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_entity")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_setting")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_research") # ???
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_bayanat")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_synonym")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_log_search")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_log_change")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_calendar") # ???
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_entity")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_setting")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_research") # ???
|
||||
|
||||
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_jahat")
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_crition")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_jahat")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_crition")
|
||||
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_sanad") # ???
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_steps") # ???
|
||||
elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_nesha")
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_sanad") # ???
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_steps") # ???
|
||||
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_nesha")
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
|
||||
@@ -358,6 +358,12 @@ class TextNormalizer:
|
||||
return s
|
||||
else:
|
||||
return char * (length - len(s)) + s
|
||||
# erab
|
||||
def remove_arabic_diacritics(self, text):
|
||||
# Regular expression to match all Arabic diacritics
|
||||
diacritics_pattern = r'[\u064B-\u0652\u0670]'
|
||||
return re.sub(diacritics_pattern, '', text)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user