FunctionLemmatizer#

class scikitplot.corpus.FunctionLemmatizer(fn, name='custom')[source]#

Wrap any Callable[[str, Optional[str]], str] as a LemmatizerProtocol.

Parameters:
fnCallable[[str], str] or Callable[[str, Optional[str]], str]

Lemmatization function. May accept an optional pos argument. If the function accepts only one argument the pos parameter is silently dropped.

namestr, optional

Human-readable name.

Parameters:
  • fn (Callable[..., str])

  • name (str)

Examples

>>> lm = FunctionLemmatizer(lambda w: w.lower(), pos=None)
>>> lm.lemmatize("Running", pos="v")
'running'
lemmatize(word, pos=None)[source]#

Lemmatize word with optional POS hint.

Parameters:
wordstr

Input word.

posstr, optional

Part-of-speech tag.

Returns:
str

Lemma form.

Parameters:
Return type:

str