run_codes_extract_directory
This commit is contained in:
@@ -57,6 +57,10 @@ class TextNormalizer:
|
||||
def normalize_qanon(self, text, error_state=False):
|
||||
if not text:
|
||||
return ""
|
||||
|
||||
#چون NaN تنها مقداری است که خودش با خودش برابر نیست
|
||||
if text != text : # True اگر NaN باشد:
|
||||
return ""
|
||||
|
||||
text = text.strip()
|
||||
# اصلاح خطاهای متن در کد خط
|
||||
@@ -315,7 +319,7 @@ class TextNormalizer:
|
||||
return text
|
||||
|
||||
|
||||
def date_correction(self, text):
|
||||
def date_correction(self, text, day_to_year=True):
|
||||
|
||||
text = re.sub(r"(\d+?)ر(\d+?)ر(\d+?)", r"\1/\2/\3", text)
|
||||
text = re.sub(r"(\d+?)ر(\d+?)", r"\1/\2", text)
|
||||
@@ -326,11 +330,21 @@ class TextNormalizer:
|
||||
# # فرمت 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)
|
||||
|
||||
# فرمت DD/MM/YYYY یا DD-MM-YYYY ---> YYYY/MM/DD
|
||||
text = re.sub(r"(\d{4})[\/\-](\d{1,2})[\/\-](\d{1,2})", r"\3/\2/\1", text)
|
||||
text = re.sub(r" (\d{1})[\/\-](\d{1})[\/\-](\d{4})", r" 0\1/0\2/\3", text)
|
||||
text = re.sub(r" (\d{1})[\/\-](\d{2})[\/\-](\d{4})", r" 0\1/\2/\3", text)
|
||||
text = re.sub(r" (\d{2})[\/\-](\d{1})[\/\-](\d{4})", r" \1/0\2/\3", text)
|
||||
if not day_to_year :
|
||||
# فرمت DD/MM/YYYY یا DD-MM-YYYY ---> YYYY/MM/DD
|
||||
text = re.sub(r"^(\d{4})[\/\-](\d{1,2})[\/\-](\d{1,2})", r"\1/\2/\3", text)
|
||||
text = re.sub(r"^(\d{2})[\/\-](\d{2})[\/\-](\d{4})", r"\3/\2/\1", text)
|
||||
text = re.sub(r"^(\d{1})[\/\-](\d{1})[\/\-](\d{4})", r"\3/0\2/0\1", text)
|
||||
text = re.sub(r"^(\d{1})[\/\-](\d{2})[\/\-](\d{4})", r"\3/\2/0\1", text)
|
||||
text = re.sub(r"^(\d{2})[\/\-](\d{1})[\/\-](\d{4})", r"\3/0\2/\1", text)
|
||||
else :
|
||||
# فرمت DD/MM/YYYY یا DD-MM-YYYY ---> YYYY/MM/DD
|
||||
text = re.sub(r"^(\d{4})[\/\-](\d{1,2})[\/\-](\d{1,2})", r"\3/\2/\1", text)
|
||||
text = re.sub(r"^(\d{2})[\/\-](\d{2})[\/\-](\d{4})", r"\1/\2/\3", text)
|
||||
text = re.sub(r"^(\d{1})[\/\-](\d{1})[\/\-](\d{4})", r"0\1/0\2/\3", text)
|
||||
text = re.sub(r"^(\d{1})[\/\-](\d{2})[\/\-](\d{4})", r"0\1/\2/\3", text)
|
||||
text = re.sub(r"^(\d{2})[\/\-](\d{1})[\/\-](\d{4})", r"\1/0\2/\3", text)
|
||||
|
||||
return text
|
||||
|
||||
def space_correction(self, text):
|
||||
|
||||
Reference in New Issue
Block a user