refactor auto import
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user