This commit is contained in:
Andras Schmelczer 2022-05-26 21:23:04 +02:00
parent 8016660276
commit 73db6a31f6
8 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,16 @@
import re
from great_ai.utilities.clean import clean
from great_ai.utilities.lemmatize_text import lemmatize_text
def preprocess(text: str) -> str:
text = clean(text, convert_to_ascii=True)
text = re.sub(r"[^a-zA-Z0-9]", " ", text)
return text
def lemmatize(text: str) -> str:
lemmatized = lemmatize_text(text)
clean_lemmas = [re.sub(r"\d[\d.,]*", "NUM", lemma) for lemma in lemmatized]
return " ".join(clean_lemmas)