Move packages
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
This commit is contained in:
parent
5890bbc3d5
commit
876e0f3082
1 changed files with 123 additions and 27 deletions
20
good_ai/src/good_ai/utilities/lemmatize_token.py
Normal file
20
good_ai/src/good_ai/utilities/lemmatize_token.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from spacy.tokens import Token
|
||||
|
||||
from .data import american_spellings
|
||||
|
||||
|
||||
def lemmatize_token(
|
||||
token: Token,
|
||||
add_negation: bool = False,
|
||||
add_part_of_speech: bool = False,
|
||||
) -> str:
|
||||
lemma = token.lemma_.lower()
|
||||
|
||||
lemma = american_spellings.get(lemma, lemma)
|
||||
|
||||
if add_part_of_speech:
|
||||
lemma = f"{lemma}_{token.pos_}"
|
||||
if add_negation and token._.negex:
|
||||
lemma = f"NOT_{lemma}"
|
||||
|
||||
return lemma
|
||||
Loading…
Reference in a new issue