pub struct FreqMap(/* private fields */);Expand description
A word→frequency lookup table backed by the Thai National Corpus (TNC).
Frequencies are raw TNC occurrence counts. Words absent from the table return 0, which is a safe default (the DP scorer simply ignores them).
The built-in table is loaded with FreqMap::builtin. Custom tables can
be constructed from any tab-separated word\tcount text via FreqMap::from_tsv.
Implementations§
Source§impl FreqMap
impl FreqMap
Sourcepub fn from_tsv(data: &str) -> Self
pub fn from_tsv(data: &str) -> Self
Parse a tab-separated word\tcount text (one entry per line).
Sourcepub fn max_freq(&self) -> u32
pub fn max_freq(&self) -> u32
Return the maximum frequency value in the table, or 0 if the table is empty.
Used by KeyExtractor to compute the
IDF numerator for TF-IDF scoring.
§Examples
use kham_core::freq::FreqMap;
let m = FreqMap::from_tsv("กิน\t100\nข้าว\t500\nที่\t9999\n");
assert_eq!(m.max_freq(), 9999);
let empty = FreqMap::from_tsv("");
assert_eq!(empty.max_freq(), 0);Auto Trait Implementations§
impl Freeze for FreqMap
impl RefUnwindSafe for FreqMap
impl Send for FreqMap
impl Sync for FreqMap
impl Unpin for FreqMap
impl UnsafeUnpin for FreqMap
impl UnwindSafe for FreqMap
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