Skip to main content

MorphemeView

Trait MorphemeView 

Source
pub trait MorphemeView: Sealed {
    type Dictionary: DictionaryAccess;

Show 20 methods // Required methods fn begin(&self) -> usize; fn end(&self) -> usize; fn begin_c(&self) -> usize; fn end_c(&self) -> usize; fn surface(&self) -> MorphemeSurface<'_>; fn word_id(&self) -> WordId; fn get_word_info(&self) -> &WordInfo; fn self_morpheme(&self) -> MorphemeRef<'_, Self::Dictionary>; // Provided methods fn part_of_speech_id(&self) -> u16 { ... } fn resolver<'a>(&'a self) -> &'a dyn WordInfoResolver where Self::Dictionary: 'a { ... } fn part_of_speech<'a>(&'a self) -> &'a [String] where Self::Dictionary: 'a { ... } fn dictionary_form<'a>(&'a self) -> &'a str where Self::Dictionary: 'a { ... } fn dictionary_form_morpheme( &self, ) -> SudachiResult<MorphemeRef<'_, Self::Dictionary>> where Self::Dictionary: Clone { ... } fn normalized_form<'a>(&'a self) -> &'a str where Self::Dictionary: 'a { ... } fn normalized_form_morpheme( &self, ) -> SudachiResult<MorphemeRef<'_, Self::Dictionary>> where Self::Dictionary: Clone { ... } fn reading_form<'a>(&'a self) -> &'a str where Self::Dictionary: 'a { ... } fn is_oov(&self) -> bool { ... } fn dictionary_id(&self) -> i32 { ... } fn synonym_group_ids(&self) -> &[i32] { ... } fn user_data(&self) -> &str { ... }
}
Expand description

Common accessor interface for morphemes.

This trait is implemented by morphemes that are part of an analysis result (Morpheme) and by standalone morphemes materialized from a dictionary entry (SingleMorpheme).

Required Associated Types§

Required Methods§

Source

fn begin(&self) -> usize

Returns the begin index in bytes of the morpheme.

Source

fn end(&self) -> usize

Returns the end index in bytes of the morpheme.

Source

fn begin_c(&self) -> usize

Returns the codepoint offset of the morpheme begin.

Source

fn end_c(&self) -> usize

Returns the codepoint offset of the morpheme end.

Source

fn surface(&self) -> MorphemeSurface<'_>

Returns text corresponding to the morpheme.

Source

fn word_id(&self) -> WordId

Returns the word id of morpheme.

Source

fn get_word_info(&self) -> &WordInfo

Returns the dictionary information for this morpheme.

Source

fn self_morpheme(&self) -> MorphemeRef<'_, Self::Dictionary>

Provided Methods§

Source

fn part_of_speech_id(&self) -> u16

Returns the ID of part of speech of the morpheme.

Source

fn resolver<'a>(&'a self) -> &'a dyn WordInfoResolver
where Self::Dictionary: 'a,

Source

fn part_of_speech<'a>(&'a self) -> &'a [String]
where Self::Dictionary: 'a,

Returns the part of speech.

Source

fn dictionary_form<'a>(&'a self) -> &'a str
where Self::Dictionary: 'a,

Returns the dictionary form of morpheme.

“Dictionary form” means a word’s lemma and “終止形” in Japanese.

Source

fn dictionary_form_morpheme( &self, ) -> SudachiResult<MorphemeRef<'_, Self::Dictionary>>
where Self::Dictionary: Clone,

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

For OOV 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 offsets are 0..surface.len() in bytes and 0..surface.chars().count() in codepoints.

Source

fn normalized_form<'a>(&'a self) -> &'a str
where Self::Dictionary: 'a,

Returns the normalized form of morpheme.

This method returns the form normalizing inconsistent spellings and inflected forms.

Source

fn normalized_form_morpheme( &self, ) -> SudachiResult<MorphemeRef<'_, Self::Dictionary>>
where Self::Dictionary: Clone,

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

For OOV 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 offsets are 0..surface.len() in bytes and 0..surface.chars().count() in codepoints.

Source

fn reading_form<'a>(&'a self) -> &'a str
where Self::Dictionary: 'a,

Returns the reading form of morpheme.

Returns Japanese syllabaries ‘フリガナ’ in katakana.

Source

fn is_oov(&self) -> bool

Returns if this morpheme is out of vocabulary.

Source

fn dictionary_id(&self) -> i32

Returns the dictionary id where the morpheme belongs.

Returns -1 if the morpheme is oov.

Source

fn synonym_group_ids(&self) -> &[i32]

Source

fn user_data(&self) -> &str

Returns user-defined data associated with this morpheme.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§