refactor auto import

This commit is contained in:
hsafaei
2025-01-18 15:32:25 +03:30
parent a5da45d7a5
commit c1ef81c632
31 changed files with 1613 additions and 1123 deletions
+13
View File
@@ -15,10 +15,15 @@ class TextNormalizer:
}
def split_words(self, text) :
if not text :
return []
words = re.split(r"[\t\n\r\.\"«»\)\(\]\[,;،؛ \-!?:]+", text)
return words
def normalize_qanon(self, text):
if not text :
return ""
text = text.strip()
# اصلاح خطاهای متن در کد خط
@@ -44,6 +49,8 @@ class TextNormalizer:
return text
def normalize_qanon_test(self, text):
if not text :
return ""
text = self.space_correction(text)
text = self.heha_correction(text)
@@ -52,6 +59,9 @@ class TextNormalizer:
def normalize_text(self, text):
if not text :
return ""
text = text.strip()
# اصلاح خطاهای متن در کد خط
if self.options.get("errorLine", False):
@@ -86,6 +96,9 @@ class TextNormalizer:
return text
def replace_alphabets(self, text):
if not text :
return ""
text = re.sub(r"\u00AD|\u00AC", "\u200C", text) # نیم اسپیس خاص
text = re.sub(r"(\u002C)+", "\u200C", text) # نیم اسپیس تکراری
text = re.sub(r"ﺁ|آ", "آ", text)