Struct vibrato::dictionary::Dictionary
source · [−]pub struct Dictionary { /* private fields */ }
Expand description
Dictionary for tokenization.
Implementations
sourceimpl Dictionary
impl Dictionary
sourcepub fn from_readers<S, C, P, U>(
system_lexicon_rdr: S,
connector_rdr: C,
char_prop_rdr: P,
unk_handler_rdr: U
) -> Result<Self>where
S: Read,
C: Read,
P: Read,
U: Read,
pub fn from_readers<S, C, P, U>(
system_lexicon_rdr: S,
connector_rdr: C,
char_prop_rdr: P,
unk_handler_rdr: U
) -> Result<Self>where
S: Read,
C: Read,
P: Read,
U: Read,
Creates a new instance from readers in the MeCab format.
Arguments
system_lexicon_rdr
: A reader of a lexicon file*.csv
.connector_rdr
: A reader of matrix filematrix.def
.char_prop_rdr
: A reader of character definition filechar.def
.unk_handler
: A reader of unknown definition fileunk.def
.
Errors
VibratoError
is returned when an input format is invalid.
sourcepub fn user_lexicon_from_reader<R>(
self,
user_lexicon_rdr: Option<R>
) -> Result<Self>where
R: Read,
pub fn user_lexicon_from_reader<R>(
self,
user_lexicon_rdr: Option<R>
) -> Result<Self>where
R: Read,
Resets the user dictionary from a reader.
Arguments
user_lexicon_rdr
: A reader of a lexicon file*.csv
in the MeCab format. IfNone
, clear the current user dictionary.
Errors
VibratoError
is returned when an input format is invalid.
sourcepub fn mapping_from_iter<L, R>(self, lmap: L, rmap: R) -> Result<Self>where
L: IntoIterator<Item = u16>,
R: IntoIterator<Item = u16>,
pub fn mapping_from_iter<L, R>(self, lmap: L, rmap: R) -> Result<Self>where
L: IntoIterator<Item = u16>,
R: IntoIterator<Item = u16>,
Edits connection ids with the given mappings.
Arguments
lmap/rmap
: An iterator of mappings of left/right ids, where thei
-th item (1-origin) indicates a new id mapped from idi
.
Errors
VibratoError
is returned when
- a new id of
BOS_EOS_CONNECTION_ID
is included, - new ids are duplicated, or
- the set of new ids are not same as that of old ids.
sourceimpl Dictionary
impl Dictionary
sourcepub fn read<R>(rdr: R) -> Result<Self>where
R: Read,
pub fn read<R>(rdr: R) -> Result<Self>where
R: Read,
Creates a dictionary from a reader.
Errors
When bincode generates an error, it will be returned as is.
sourcepub unsafe fn read_unchecked<R>(rdr: R) -> Result<Self>where
R: Read,
pub unsafe fn read_unchecked<R>(rdr: R) -> Result<Self>where
R: Read,
Creates a dictionary from a reader.
Safety
The given reader must be a correct file exported by
Dictionary::write()
.
Errors
When bincode generates an error, it will be returned as is.
Auto Trait Implementations
impl RefUnwindSafe for Dictionary
impl Send for Dictionary
impl Sync for Dictionary
impl Unpin for Dictionary
impl UnwindSafe for Dictionary
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more