Skip to main content

Morpheme

Struct Morpheme 

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

A morpheme as a part of an analysis result.

Implementations§

Source§

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

Source

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

👎Deprecated since 0.6.1:

use split_into

Returns new morpheme list splitting the morpheme with given mode.

Source§

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

Source

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

Returns the part of speech.

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 end 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 dictionary_form_morpheme(&self) -> SudachiResult<MorphemeRef<'_, D>>
where D: Clone,

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

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 normalized_form_morpheme(&self) -> SudachiResult<MorphemeRef<'_, D>>
where D: Clone,

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

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) -> &[i32]

Source

pub fn user_data(&self) -> &str

Returns user-defined data associated with this morpheme.

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<D>, ) -> 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<D> Clone for Morpheme<'_, D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D> Copy for Morpheme<'_, D>

Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<D: DictionaryAccess> MorphemeView for Morpheme<'_, D>

Source§

type Dictionary = D

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<'_, D>

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. Read more
Source§

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

Returns the morpheme corresponding to this morpheme’s dictionary form. Read more
Source§

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

Returns the normalized form of morpheme. Read more
Source§

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

Returns the morpheme corresponding to this morpheme’s normalized form. Read more
Source§

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

Returns the reading form of morpheme. Read more
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. Read more
Source§

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

Source§

fn user_data(&self) -> &str

Returns user-defined data associated with this morpheme.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<'a, D> UnsafeUnpin for Morpheme<'a, D>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.