Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list.
(tokens)
| 74 | #--- ENGLISH PARSER -------------------------------------------------------------------------------- |
| 75 | |
| 76 | def find_lemmata(tokens): |
| 77 | """ Annotates the tokens with lemmata for plural nouns and conjugated verbs, |
| 78 | where each token is a [word, part-of-speech] list. |
| 79 | """ |
| 80 | for token in tokens: |
| 81 | word, pos, lemma = token[0], token[1], token[0] |
| 82 | # cats => cat |
| 83 | if pos == "NNS": |
| 84 | lemma = singularize(word) |
| 85 | # sat => sit |
| 86 | if pos.startswith(("VB", "MD")): |
| 87 | lemma = conjugate(word, INFINITIVE) or word |
| 88 | token.append(lemma.lower()) |
| 89 | return tokens |
| 90 | |
| 91 | class Parser(_Parser): |
| 92 |
no test coverage detected
searching dependent graphs…