Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list.
(tokens)
| 158 | )) |
| 159 | |
| 160 | def find_lemmata(tokens): |
| 161 | """ Annotates the tokens with lemmata for plural nouns and conjugated verbs, |
| 162 | where each token is a [word, part-of-speech] list. |
| 163 | """ |
| 164 | for token in tokens: |
| 165 | word, pos, lemma = token[0], token[1], token[0] |
| 166 | if pos.startswith(("DT",)): |
| 167 | lemma = singularize(word, pos="DT") |
| 168 | if pos.startswith(("JJ",)): |
| 169 | lemma = predicative(word) |
| 170 | if pos == "NNS": |
| 171 | lemma = singularize(word) |
| 172 | if pos.startswith(("VB", "MD")): |
| 173 | lemma = conjugate(word, INFINITIVE) or word |
| 174 | token.append(lemma.lower()) |
| 175 | return tokens |
| 176 | |
| 177 | class Parser(_Parser): |
| 178 |
no test coverage detected
searching dependent graphs…