pub struct Lexicon<'a> { /* private fields */ }Expand description
Dictionary lexicon
Contains trie, word_id, word_param, word_info
Implementations§
Source§impl<'a> Lexicon<'a>
impl<'a> Lexicon<'a>
pub fn from_binary(binary_lexicon: BinaryLexicon<'a>) -> Self
pub fn entry_ids_in_order(&self) -> Vec<EntryId>
Sourcepub fn set_dic_id(&mut self, id: u8)
pub fn set_dic_id(&mut self, id: u8)
Assign lexicon id to the current Lexicon
Sourcepub fn lookup(
&'a self,
input: &'a [u8],
offset: usize,
) -> impl Iterator<Item = LexiconEntry> + 'a
pub fn lookup( &'a self, input: &'a [u8], offset: usize, ) -> impl Iterator<Item = LexiconEntry> + 'a
Returns an iterator of word_id and end of words that matches given input
Sourcepub fn lookup_batch<F: FnMut(usize, LexiconEntry)>(
&self,
input: &[u8],
starts: &[usize],
emit: F,
)
pub fn lookup_batch<F: FnMut(usize, LexiconEntry)>( &self, input: &[u8], starts: &[usize], emit: F, )
Pipelined + prefetched batch form of Lexicon::lookup.
Calls emit(bucket, entry) for every match; bucket indexes starts.
Within a bucket the order matches Lexicon::lookup, so grouping by
bucket reproduces the scalar result.
Sourcepub fn get_word_info(
&self,
entry_id: EntryId,
subset: InfoSubset,
) -> SudachiResult<WordInfoRefData>
pub fn get_word_info( &self, entry_id: EntryId, subset: InfoSubset, ) -> SudachiResult<WordInfoRefData>
Returns WordInfo for given word_id
WordInfo will contain only fields included in InfoSubset
Sourcepub fn get_word_param(&self, entry_id: EntryId) -> (i16, i16, i16)
pub fn get_word_param(&self, entry_id: EntryId) -> (i16, i16, i16)
Returns word_param for given word_id. Params are (left_id, right_id, cost).
pub fn get_word_param_checked( &self, entry_id: EntryId, ) -> Option<(i16, i16, i16)>
pub fn get_string(&self, strptr: StringPointer) -> SudachiResult<String>
Sourcepub fn update_cost<D: DictionaryAccess>(
&mut self,
dict: &D,
) -> SudachiResult<()>
pub fn update_cost<D: DictionaryAccess>( &mut self, dict: &D, ) -> SudachiResult<()>
update word_param cost based on current tokenizer
Auto Trait Implementations§
impl<'a> Freeze for Lexicon<'a>
impl<'a> RefUnwindSafe for Lexicon<'a>
impl<'a> Send for Lexicon<'a>
impl<'a> Sync for Lexicon<'a>
impl<'a> Unpin for Lexicon<'a>
impl<'a> UnsafeUnpin for Lexicon<'a>
impl<'a> UnwindSafe for Lexicon<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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