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

Function find_lemmata

pattern/text/it/__init__.py:107–122  ·  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

105replacements = dict((k+"'", k+"' ") for k in replacements)
106
107def find_lemmata(tokens):
108 """ Annotates the tokens with lemmata for plural nouns and conjugated verbs,
109 where each token is a [word, part-of-speech] list.
110 """
111 for token in tokens:
112 word, pos, lemma = token[0], token[1], token[0]
113 if pos.startswith(("DT",)):
114 lemma = singularize(word, pos="DT")
115 if pos.startswith("JJ"):
116 lemma = predicative(word)
117 if pos == "NNS":
118 lemma = singularize(word)
119 if pos.startswith(("VB", "MD")):
120 lemma = conjugate(word, INFINITIVE) or word
121 token.append(lemma.lower())
122 return tokens
123
124class Parser(_Parser):
125

Callers 1

find_lemmataMethod · 0.70

Calls 4

singularizeFunction · 0.90
predicativeFunction · 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…