pub struct NgramsFile {
pub ngrams: FxHashMap<Bytes, usize>,
pub ftype: FileType,
pub n: u16,
pub s: u16,
}Expand description
N-grams as read from a file
Fields§
§ngrams: FxHashMap<Bytes, usize>N-grams and their index position
Keyed with crate::hash::FxHasher: this map is probed once per byte of every sample
during featurization, where SipHash costs more than the lookup itself.
ftype: FileTypeFile type represented by the n-grams
n: u16Convenience: keep track of the size of the n-grams (value of n)
s: u16Stride
Implementations§
Source§impl NgramsFile
impl NgramsFile
Sourcepub fn load<P: AsRef<Path>>(ngrams_file: P) -> Result<Self>
pub fn load<P: AsRef<Path>>(ngrams_file: P) -> Result<Self>
Load the n-grams from an existing model or from a plain text file.
§Errors
An error results if:
- The file cannot be read
- The file type is not specified
- The n-grams aren’t hexidecimal
- The n-grams are different sizes
Trait Implementations§
Source§impl Clone for NgramsFile
impl Clone for NgramsFile
Source§impl From<LogisticRegression> for NgramsFile
impl From<LogisticRegression> for NgramsFile
Source§fn from(l: LogisticRegression) -> Self
fn from(l: LogisticRegression) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for NgramsFile
impl RefUnwindSafe for NgramsFile
impl Send for NgramsFile
impl Sync for NgramsFile
impl Unpin for NgramsFile
impl UnsafeUnpin for NgramsFile
impl UnwindSafe for NgramsFile
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,
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