sudachipy.morpheme package

Note

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

  • Method Morpheme.get_word_info(self) -> WordInfo is deprecated.

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_id(self, /) int

Returns the dictionary id which this word belongs.

end(self, /) int

Returns the end index of this in the input text.

get_word_info(self, /) WordInfo

Returns the word info.

..deprecated:: v0.6.0

Users should not touch the raw WordInfo.

is_oov(self, /) bool

Returns whether if this is out of vocabulary word.

normalized_form(self, /) str

Returns the normalized form.

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 MorhpemeList 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.

word_id(self, /) int

Returns word id of this word in the dictionary.