pub struct Table {}Expand description
The spam filter, folded (see the module’s documentation).
Fields§
§tokenizer: u32The tokenizer’s version it was trained with (tokenize::TOKENIZER).
features: u32The header features’ version (features::FEATURES).
dim: u32The language model’s dimension, for the record.
minn: u32fastText’s character n-grams: shortest, longest, and how many buckets they hash into.
maxn: u32§bucket: u32§words: Vec<(u64, f32)>Each vocabulary word’s score, under its hash (word_hash), ascending:
scoring looks words up by halves. A table read from its file is so; one
made in memory is once sorted (writing sorts it too).
buckets: Vec<f32>Each n-gram bucket’s score, bucket of them.
weights: Vec<f32>Each header feature’s weight, over its deviation, and its mean
(features::NAMES’ order); none in the classifier’s table, which
reads the header facts as words: that is how its kind is told (kind).
means: Vec<f32>§bias: f32The SVM’s intercept; the classifier’s: the end of the line’s scalar.
text_mean: f32The score of the mean message’s text (u · μ); the classifier’s: 0.
platt_a: f32Platt’s A and B.
platt_b: f32§meta: MetaImplementations§
Source§impl Table
impl Table
Sourcepub fn lexicon(&self) -> Arc<Lexicon> ⓘ
pub fn lexicon(&self) -> Arc<Lexicon> ⓘ
The words it reads every message with (tokenize::tokens_with): its
own, or the packs built in when it keeps none (made before 8 October 2026).
Sourcepub fn kind(&self) -> Kind
pub fn kind(&self) -> Kind
Its kind: no header weights, the classifier’s, which reads the header facts as words; else the centroid’s.
Sourcefn rows_of(&self, word: &str) -> (f64, usize)
fn rows_of(&self, word: &str) -> (f64, usize)
A word’s rows in the classifier’s table: the sum of their scalars and how many they are. Known: its own row and its n-grams’; else its n-grams’ alone (none without n-grams: nothing).
Sourcepub fn word_score(&self, word: &str) -> f32
pub fn word_score(&self, word: &str) -> f32
A word’s score in the centroid’s table: its own, else the mean of its n-grams’ buckets; 0 when it has none.
Sourcepub fn score(&self, words: &[String], features: &[f32]) -> Score
pub fn score(&self, words: &[String], features: &[f32]) -> Score
A message’s score from its words (tokenize::tokens) and its header
features (features::features), with what made it. The table’s words
must be sorted (sort): one read from its file is. A header feature
that is missing (f32::NAN) weighs nothing: the classifier reads no
word for it; the centroid stands it at the training’s mean, which is
over the messages that had it.
Sourcefn score_rows(&self, words: &[String], features: &[f32]) -> Score
fn score_rows(&self, words: &[String], features: &[f32]) -> Score
The classifier’s score: the mean of the rows’ scalars of its words, its header facts’ words and the end of the line. Each word’s share is its rows’ sum over every row; a header fact’s, its word’s.
Sourcefn score_centroid(&self, words: &[String], features: &[f32]) -> Score
fn score_centroid(&self, words: &[String], features: &[f32]) -> Score
The centroid’s score (see the module’s documentation).
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
The table as its file holds it, words sorted (sort), checksummed.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Table, String>
pub fn from_bytes(bytes: &[u8]) -> Result<Table, String>
Reads a table, refusing one that is damaged, made by another tokenizer or with other header features than this Sioul’s: its scores would mean nothing.
Sourcepub fn write(&self, path: &Path) -> Result<(), String>
pub fn write(&self, path: &Path) -> Result<(), String>
Writes the table where it goes, whole or not at all (written beside,
flushed, then moved); the one it replaces, when this Sioul can use it,
is kept as table.prev.bin (keep_previous).
Sourcepub fn cached(path: &Path) -> Option<Arc<Table>>
pub fn cached(path: &Path) -> Option<Arc<Table>>
The table at path, read once per process and again only when its
file changes (its size and time); none when there is none. One this
Sioul refuses (read says why: made by a newer Sioul, damaged) leaves
the one before it in use (table.prev.bin), when there is one it
reads. The phone’s background process reads it once, then keeps it.
Trait Implementations§
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.