great-ai/example/preprocess.py
András Schmelczer c01d55d291 Format
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
2022-04-02 21:59:09 +02:00

8 lines
213 B
Python

import re
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)