Imrpove examples

This commit is contained in:
Andras Schmelczer 2022-05-26 13:33:27 +02:00
parent a0017c4e1d
commit 911c4f64f7
No known key found for this signature in database
GPG key ID: 39260B5B0614A13E
7 changed files with 308 additions and 28 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)