sudachipy.morpheme package

Note

  • Import from sudachipy.morpheme is deprecated.
    • Use from sudachipy import Morpheme instead.

Module contents

class sudachipy.morpheme.Morpheme

A morpheme (basic semantic unit of language).

begin(self, /) → int

–

Returns the begin index of this in the input text.

dictionary_form(self, /) → str

–

Returns the dictionary form.

dictionary_form_morpheme(self, /) → Morpheme

–

Returns the morpheme corresponding to this morpheme’s dictionary form.

For out-of-vocabulary morphemes, invalid references, and references to the same dictionary entry, returns a morpheme equivalent to self. For a distinct referenced entry, returns a standalone morpheme whose begin/end offsets are 0..len(surface).

dictionary_id(self, /) → int

–

Returns the dictionary id which this word belongs.

end(self, /) → int

–

Returns the end index of this in the input text.

is_oov(self, /) → bool

–

Returns whether if this is out of vocabulary word.

normalized_form(self, /) → str

–

Returns the normalized form.

normalized_form_morpheme(self, /) → Morpheme

–

Returns the morpheme corresponding to this morpheme’s normalized form.

For out-of-vocabulary morphemes, invalid references, and references to the same dictionary entry, returns a morpheme equivalent to self. For a distinct referenced entry, returns a standalone morpheme whose begin/end offsets are 0..len(surface).

part_of_speech(self, /) → tuple[str, str, str, str, str, str]

–

Returns the part of speech as a six-element tuple. Tuple elements are four POS levels, conjugation type and conjugation form.

part_of_speech_id(self, /) → int

–

Returns the id of the part of speech in the dictionary.

raw_surface(self, /) → str

–

Returns the substring of input text corresponding to the morpheme regardless the configured projection.

See Config.projection.

reading_form(self, /) → str

–

Returns the reading form.

split(self, /, mode, out=None, add_single=False) → MorphemeList

–

Returns sub-morphemes in the provided split mode.

Parameters:
  • mode (SplitMode | None) – mode of new split.

  • out (MorphemeList | None) – write results to this MorphemeList instead of creating new one. See https://worksapplications.github.io/sudachi.rs/python/topics/out_param.html for more information on output parameters. Returned MorphemeList will be invalidated if this MorphemeList is used as an output parameter.

  • add_single (bool) – return lists with the current morpheme if the split hasn’t produced any elements. When False is passed, empty lists are returned instead.

surface(self, /) → str

–

Returns the substring of input text corresponding to the morpheme, or a projection if one is configured.

See Config.projection.

synonym_group_ids(self, /) → List[int]

–

Returns the list of synonym group ids.

user_data(self, /) → str

–

Returns user-defined data associated with this morpheme.

word_id(self, /) → int

–

Returns word id of this word in the dictionary.