sudachi::analysis::morpheme

Struct Morpheme

source
pub struct Morpheme<'a, T> { /* private fields */ }
Expand description

A morpheme (basic semantic unit of language)

Implementations§

source§

impl<T: DictionaryAccess> Morpheme<'_, T>

source

pub fn part_of_speech(&self) -> &[String]

Returns the part of speech

source§

impl<T: DictionaryAccess + Clone> Morpheme<'_, T>

source

pub fn split(&self, mode: Mode) -> SudachiResult<MorphemeList<T>>

👎Deprecated since 0.6.1: use split_into

Returns new morpheme list splitting the morpheme with given mode.

source§

impl<'a, T: DictionaryAccess> Morpheme<'a, T>

source

pub fn begin(&self) -> usize

Returns the begin index in bytes of the morpheme in the original text

source

pub fn end(&self) -> usize

Returns the end index in bytes of the morpheme in the original text

source

pub fn begin_c(&self) -> usize

Returns the codepoint offset of the morpheme begin in the original text

source

pub fn end_c(&self) -> usize

Returns the codepoint offset of the morpheme begin in the original text

source

pub fn surface(&self) -> Ref<'_, str>

Returns a substring of the original text which corresponds to the morpheme

source

pub fn part_of_speech_id(&self) -> u16

source

pub fn dictionary_form(&self) -> &str

Returns the dictionary form of morpheme

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

source

pub fn normalized_form(&self) -> &str

Returns the normalized form of morpheme

This method returns the form normalizing inconsistent spellings and inflected forms

source

pub fn reading_form(&self) -> &str

Returns the reading form of morpheme.

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

source

pub fn is_oov(&self) -> bool

Returns if this morpheme is out of vocabulary

source

pub fn word_id(&self) -> WordId

Returns the word id of morpheme

source

pub fn dictionary_id(&self) -> i32

Returns the dictionary id where the morpheme belongs

Returns -1 if the morpheme is oov

source

pub fn synonym_group_ids(&self) -> &[u32]

source

pub fn get_word_info(&self) -> &WordInfo

source

pub fn index(&self) -> usize

Returns the index of this morpheme

source

pub fn split_into( &self, mode: Mode, out: &mut MorphemeList<T>, ) -> SudachiResult<bool>

Splits morpheme and writes sub-morphemes into the provided list. The resulting list is not cleared before that. Returns true if split has produced any elements.

source

pub fn total_cost(&self) -> i32

Returns total cost from the beginning of the path

Trait Implementations§

source§

impl<T: DictionaryAccess> Debug for Morpheme<'_, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for Morpheme<'a, T>

§

impl<'a, T> !RefUnwindSafe for Morpheme<'a, T>

§

impl<'a, T> !Send for Morpheme<'a, T>

§

impl<'a, T> !Sync for Morpheme<'a, T>

§

impl<'a, T> Unpin for Morpheme<'a, T>

§

impl<'a, T> !UnwindSafe for Morpheme<'a, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.