great-ai/example/preprocess.py
András Schmelczer acbdd96883 Move packages
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
2022-04-02 21:55:48 +02:00

9 lines
255 B
Python

import re
from good_ai.utilities.clean import clean
from good_ai.utilities.lemmatize_text import lemmatize_text
def preprocess(text: str) -> str:
lemmas = [re.sub(r"\d+", "NUM", lemma) for lemma in lemmatize_text(text)]
return " ".join(lemmas)