pub struct WordLevel { /* private fields */ }Expand description
WordLevel model.
§Example
use std::collections::HashMap;
use morpheme::models::WordLevel;
use morpheme::Model;
let vocab: HashMap<String, u32> = [("<unk>", 0), ("hello", 1)].map(|(t, i)| (t.to_string(), i)).into();
let wl = WordLevel::builder().vocab(vocab).unk_token("<unk>").build()?;
assert_eq!(wl.tokenize("hello")?[0].id, 1);
assert_eq!(wl.tokenize("goodbye")?[0].id, 0);Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for WordLevel
impl<'de> Deserialize<'de> for WordLevel
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for WordLevel
Source§impl From<WordLevel> for ModelWrapper
impl From<WordLevel> for ModelWrapper
Source§impl Model for WordLevel
impl Model for WordLevel
impl StructuralPartialEq for WordLevel
Auto Trait Implementations§
impl Freeze for WordLevel
impl RefUnwindSafe for WordLevel
impl Send for WordLevel
impl Sync for WordLevel
impl Unpin for WordLevel
impl UnsafeUnpin for WordLevel
impl UnwindSafe for WordLevel
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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