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

Function find_lemmata

pattern/text/fr/__init__.py:111–128  ·  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

109replacements.update(((k.upper(), v.upper()) for k, v in replacements.items()))
110
111def find_lemmata(tokens):
112 """ Annotates the tokens with lemmata for plural nouns and conjugated verbs,
113 where each token is a [word, part-of-speech] list.
114 """
115 for token in tokens:
116 word, pos, lemma = token[0], token[1], token[0]
117 if pos.startswith(("DT", "PR", "WP")):
118 lemma = singularize(word, pos=pos)
119 if pos.startswith(("RB", "IN")) and (word.endswith(("'", u"’")) or word == "du"):
120 lemma = singularize(word, pos=pos)
121 if pos.startswith(("JJ",)):
122 lemma = predicative(word)
123 if pos == "NNS":
124 lemma = singularize(word)
125 if pos.startswith(("VB", "MD")):
126 lemma = conjugate(word, INFINITIVE) or word
127 token.append(lemma.lower())
128 return tokens
129
130class Parser(_Parser):
131

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…