Skip to main content

SingleMorpheme

Struct SingleMorpheme 

Source
pub struct SingleMorpheme<D> { /* private fields */ }
Expand description

A standalone morpheme materialized from a single dictionary entry.

Implementations§

Source§

impl<D: DictionaryAccess> SingleMorpheme<D>

Source

pub fn from_word_id( dict: D, word_id: WordId, subset: InfoSubset, ) -> SudachiResult<Self>

Creates a standalone morpheme for the exact dictionary entry.

The entry is resolved by WordId, not by surface lookup, so homograph identity is preserved. HEADWORD is always loaded because standalone offsets and surface are based on the dictionary headword.

Source

pub fn oov( dict: D, pos_id: u16, surface: String, reading: String, normalized_form: String, dictionary_form: String, ) -> SudachiResult<Self>

Source

pub fn begin(&self) -> usize

Returns the begin index in bytes of this standalone morpheme.

Source

pub fn end(&self) -> usize

Returns the end index in bytes of this standalone morpheme.

Source

pub fn begin_c(&self) -> usize

Returns the codepoint offset of this standalone morpheme begin.

Source

pub fn end_c(&self) -> usize

Returns the codepoint offset of this standalone morpheme end.

Source

pub fn surface(&self) -> &str

Returns the dictionary headword surface.

Source

pub fn word_id(&self) -> WordId

Returns the word id of morpheme.

Source

pub fn get_word_info(&self) -> &WordInfo

Source§

impl<D: DictionaryAccess + Clone> SingleMorpheme<D>

Source

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

Returns the part of speech.

Source

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

Returns standalone sub-morphemes for the requested split mode.

When the dictionary entry has no splits for the mode, returns a clone of this morpheme. Offsets match Java’s standalone morpheme behavior: a single replacement split preserves this morpheme’s span, while multi-splits advance over each split surface.

Source

pub fn part_of_speech_id(&self) -> u16

Source

pub fn dictionary_form(&self) -> &str

Returns the dictionary form of morpheme.

Source

pub fn dictionary_form_morpheme(&self) -> SudachiResult<MorphemeRef<'_, D>>

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

Source

pub fn normalized_form(&self) -> &str

Returns the normalized form of morpheme.

Source

pub fn normalized_form_morpheme(&self) -> SudachiResult<MorphemeRef<'_, D>>

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

Source

pub fn reading_form(&self) -> &str

Returns the reading form of morpheme.

Source

pub fn is_oov(&self) -> bool

Returns if this morpheme is out of vocabulary.

Source

pub fn dictionary_id(&self) -> i32

Returns the dictionary id where the morpheme belongs.

Source

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

Source

pub fn user_data(&self) -> &str

Returns user-defined data associated with this morpheme.

Trait Implementations§

Source§

impl<D: Clone> Clone for SingleMorpheme<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: DictionaryAccess + Clone> Debug for SingleMorpheme<D>

Source§

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

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

impl<D: DictionaryAccess + Clone> MorphemeView for SingleMorpheme<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<D> !Freeze for SingleMorpheme<D>

§

impl<D> RefUnwindSafe for SingleMorpheme<D>
where D: RefUnwindSafe,

§

impl<D> Send for SingleMorpheme<D>
where D: Send,

§

impl<D> Sync for SingleMorpheme<D>
where D: Sync,

§

impl<D> Unpin for SingleMorpheme<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for SingleMorpheme<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for SingleMorpheme<D>
where D: UnwindSafe,

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.