permission entity tree list
This commit is contained in:
+77
-5
@@ -21,7 +21,7 @@ class TextNormalizer:
|
||||
words = re.split(r"[\t\n\r\.\'\"«»\)\(\]\[\{\}\%\#\$\*\<\>\/,;،؛ \-!?:٭؟]+", text)
|
||||
return words
|
||||
|
||||
def normalize_qanon(self, text):
|
||||
def normalize_qanon(self, text, error_state=False):
|
||||
if not text :
|
||||
return ""
|
||||
|
||||
@@ -34,7 +34,10 @@ class TextNormalizer:
|
||||
text = text.replace("\r", "\n")
|
||||
|
||||
# یکسان سازی اختلاف حروف کیبوردهای مختلف - کدهای مختلف ولی نمایش یکسان
|
||||
text = self.replace_alphabets(text)
|
||||
if error_state :
|
||||
text = self.replace_alphabets_error(text)
|
||||
else :
|
||||
text = self.replace_alphabets(text)
|
||||
|
||||
# اعداد چسبیده به کلمات را با یک فاصله جدا می کند
|
||||
text = self.word_digit_correction(text)
|
||||
@@ -103,6 +106,71 @@ class TextNormalizer:
|
||||
|
||||
return text
|
||||
|
||||
def replace_alphabets_error(self, text):
|
||||
if not text :
|
||||
return ""
|
||||
|
||||
text = re.sub(r"\u200e|\u200f", " ", text) # LTR, RTL
|
||||
|
||||
text = re.sub(r"\u00AD|\u00AC", "\u200C", text) # نیم اسپیس خاص
|
||||
text = re.sub(r"(\u002C)+", "\u200C", text) # نیم اسپیس تکراری
|
||||
text = re.sub(r"ﺁ|آ", "آ", text)
|
||||
text = re.sub(r"ﺎ|ٱ|ﺍ", "ا", text)
|
||||
text = re.sub(r"ٲ|أ|ﺄ|ﺃ", "أ", text)
|
||||
text = re.sub(r"ﺈ|ﺇ", "إ", text)
|
||||
text = re.sub(r"ﺐ|ﺏ|ﺑ|ﺒ", "ب", text)
|
||||
text = re.sub(r"ﭖ|ﭗ|ﭙ|ﭘ", "پ", text)
|
||||
text = re.sub(r"ﭡ|ٺ|ٹ|ﭞ|ٿ|ټ|ﺕ|ﺗ|ﺖ|ﺘ", "ت", text)
|
||||
text = re.sub(r"ﺙ|ﺛ|ﺚ|ﺜ", "ث", text)
|
||||
text = re.sub(r"ﺝ|ڃ|ﺠ|ﺟ", "ج", text)
|
||||
text = re.sub(r"ڃ|ﭽ|ﭼ", "چ", text)
|
||||
text = re.sub(r"ﺢ|ﺤ|څ|ځ|ﺣ", "ح", text)
|
||||
text = re.sub(r"ﺥ|ﺦ|ﺨ|ﺧ", "خ", text)
|
||||
text = re.sub(r"ڏ|ډ|ﺪ|ﺩ", "د", text)
|
||||
text = re.sub(r"ﺫ|ﺬ|ذ", "ذ", text)
|
||||
text = re.sub(r"ڙ|ڗ|ڒ|ڑ|ڕ|ﺭ|ﺮ", "ر", text)
|
||||
text = re.sub(r"ﺰ|ﺯ", "ز", text)
|
||||
text = re.sub(r"ﮊ", "ژ", text)
|
||||
text = re.sub(r"ݭ|ݜ|ﺱ|ﺲ|ښ|ﺴ|ﺳ", "س", text)
|
||||
text = re.sub(r"ﺵ|ﺶ|ﺸ|ﺷ", "ش", text)
|
||||
text = re.sub(r"ﺺ|ﺼ|ﺻ|ﺹ", "ص", text)
|
||||
text = re.sub(r"ﺽ|ﺾ|ﺿ|ﻀ", "ض", text)
|
||||
text = re.sub(r"ﻁ|ﻂ|ﻃ|ﻄ", "ط", text)
|
||||
text = re.sub(r"ﻆ|ﻇ|ﻈ", "ظ", text)
|
||||
text = re.sub(r"ڠ|ﻉ|ﻊ|ﻋ|ﻌ", "ع", text)
|
||||
text = re.sub(r"ﻎ|ۼ|ﻍ|ﻐ|ﻏ", "غ", text)
|
||||
text = re.sub(r"ﻒ|ﻑ|ﻔ|ﻓ", "ف", text)
|
||||
text = re.sub(r"ﻕ|ڤ|ﻖ|ﻗ|ﻘ", "ق", text)
|
||||
text = re.sub(r"ڭ|ﻚ|ﮎ|ﻜ|ﮏ|ګ|ﻛ|ﮑ|ﮐ|ڪ|ك", "ک", text)
|
||||
text = re.sub(r"ﮚ|ﮒ|ﮓ|ﮕ|ﮔ", "گ", text)
|
||||
text = re.sub(r"ﻝ|ﻞ|ﻠ|ڵ|ﻟ", "ل", text)
|
||||
text = re.sub(r"ﻵ|ﻶ|ﻷ|ﻸ|ﻹ|ﻺ|ﻻ|ﻼ", "لا", text)
|
||||
text = re.sub(r"ﻡ|ﻤ|ﻢ|ﻣ", "م", text)
|
||||
text = re.sub(r"ڼ|ﻦ|ﻥ|ﻨ|ﻧ", "ن", text)
|
||||
text = re.sub(r"ވ|ﯙ|ۈ|ۋ|ﺆ|ۊ|ۇ|ۏ|ۅ|ۉ|ﻭ|ﻮ|ؤ", "و", text)
|
||||
text = re.sub(r"ﻬ|ھ|ﻩ|ﻫ|ﻪ|ە|ہ", "ه", text)
|
||||
text = re.sub(r"ﭛ|ﻯ|ۍ|ﻰ|ﻱ|ﻲ|ں|ﻳ|ﻴ|ﯼ|ې|ﯽ|ﯾ|ﯿ|ێ|ے|ى|ي", "ی", text)
|
||||
text = re.sub(r"¬", "", text)
|
||||
text = re.sub(r"•|·|●|·|・|∙|。|ⴰ", ".", text)
|
||||
text = re.sub(r",|٬|٫|‚|،", "،", text)
|
||||
text = re.sub(r"ʕ", "؟", text)
|
||||
text = re.sub(r"”|“", "\"", text)
|
||||
text = re.sub(r"۰|٠", "0", text)
|
||||
text = re.sub(r"۱|١", "1", text)
|
||||
text = re.sub(r"۲|٢", "2", text)
|
||||
text = re.sub(r"۳|٣", "3", text)
|
||||
text = re.sub(r"۴|٤", "4", text)
|
||||
text = re.sub(r"۵", "5", text)
|
||||
text = re.sub(r"۶|٦", "6", text)
|
||||
text = re.sub(r"۷|٧", "7", text)
|
||||
text = re.sub(r"۸|٨", "8", text)
|
||||
text = re.sub(r"۹|٩", "9", text)
|
||||
text = re.sub(r"²", "2", text)
|
||||
text = re.sub(r"|ِ|ُ|َ|ٍ|ٌ|ً|", "", text)
|
||||
|
||||
text = re.sub(r"ـ", "", text) # حذف حروف کشیده # این باعث خطای حذف اضافی شد و با خط بعدی جایگزین شد
|
||||
return text
|
||||
|
||||
def replace_alphabets(self, text):
|
||||
if not text :
|
||||
return ""
|
||||
@@ -165,10 +233,14 @@ class TextNormalizer:
|
||||
text = re.sub(r"۹|٩", "9", text)
|
||||
text = re.sub(r"²", "2", text)
|
||||
text = re.sub(r"|ِ|ُ|َ|ٍ|ٌ|ً|", "", text)
|
||||
|
||||
#text = re.sub(r"ـ", "", text) # حذف حروف کشیده # این باعث خطای حذف اضافی شد و با خط بعدی جایگزین شد
|
||||
text = re.sub(r'([\u0600-\u06FF])ـ([\u0600-\u06FF])', r'\1\2', text) # حذف حروف کشیده
|
||||
text = re.sub(r'([\u0600-\u06FF])ـ', r'\1', text) # حذف حروف کشیده
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def date_correction(self, text):
|
||||
# فرمت YYYY/MM/DD یا YYYY-MM-DD --> YYYY/MM/DD
|
||||
text = re.sub(r'(\d{4})[\/\-](\d{1,2})[\/\-](\d{1,2})', r'\1/\2/\3', text)
|
||||
@@ -240,7 +312,7 @@ class TextNormalizer:
|
||||
# "trimLine": True # حذف فضای خالی اضافی در ابتدا و انتهای متن
|
||||
# }
|
||||
|
||||
normalizer = TextNormalizer()
|
||||
# normalizer = TextNormalizer()
|
||||
# text = """
|
||||
# سلام -- ـ ـ خوبی
|
||||
# دادی ییی بی داد
|
||||
@@ -263,7 +335,7 @@ normalizer = TextNormalizer()
|
||||
# تبصره 4 ـ در مواردي كه وراث سهم خود از اموال موضوع بندهاي (2)، (4) و (5) اين ماده را به اشخاص ثالث يا وراث ديگر انتقال دهند، علاوه بر ماليات بر ارث به شرح اين فصل، مشمول ماليات طبق مقررات فصول مربوط خواهند بود.
|
||||
# تبصره 5 ـ حقوق ناشي از عقود اجاره به شرط تمليك با بانكها و ساير نهادهاي مالي و اعتباري، نسبت به عرصه و اعيان املاك بر اساس ارزش معاملاتي در تاريخ ثبت انتقال به نام وراث محاسبه خواهد شد.
|
||||
# """
|
||||
# text="سلـام"
|
||||
# text="46- متون زیر به عنوان تبصره های ( 3 ) و ( 4 ) به ماده (-187-) قانون الحاق می شود:"
|
||||
# # text="سلـام"
|
||||
# # text="46- متون زیر به عنوان تبصره های ( 3 ) و ( 4 ) به ماده (-187-) قانون الحاق می شود:"
|
||||
# normalized_text = normalizer.normalize_qanon(text)
|
||||
# print(normalized_text)
|
||||
|
||||
Reference in New Issue
Block a user