MCPcopy Create free account
hub / github.com/clips/pattern / find_lemmata

Function find_lemmata

pattern/text/en/__init__.py:76–89  ·  view source on GitHub ↗

Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list.

(tokens)

Source from the content-addressed store, hash-verified

74#--- ENGLISH PARSER --------------------------------------------------------------------------------
75
76def 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
91class Parser(_Parser):
92

Callers 1

find_lemmataMethod · 0.70

Calls 3

singularizeFunction · 0.90
conjugateFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…