I'm trying to write a function which would modify a tagged word depending on the tags present in the word, so basically a lemmatizer, but for words in Swedish.
For example if the word was tagged with A it would remove ending X from the word, and if the word also was tagged with B it would remove ending Y from the word etc. In total there are seven different endings that might be present in the word depending on the tag combinations and which I in that case want to remove.
What I've tried so far is to use several if statements after one another which would modify the word if it was tagged with one tag combination and then check if it was tagged with another tag combination and then modify it based on that and so on.
if tag1 == 'A':
word = word.rstrip('x')
if tag2 == 'B' and tag3 == 'C' and tag4 == 'D':
word = word.rstrip('y')
if tag3 == 'B' and tag4 == 'D':
word = word.rstrip('z')
I'm having problems with understanding how I should phrase the if statements so that they would each check for a tag combination, modify the word if the statement is true and then pass the modified word along to the next statement. How would I do this?
Aucun commentaire:
Enregistrer un commentaire