pub struct TextVector { /* private fields */ }Expand description
Simple TF-IDF vector for text similarity.
Tokenizes text into terms, computes normalized term frequency, and supports cosine similarity comparison. No external embedding model needed — language-agnostic.
Implementations§
Source§impl TextVector
impl TextVector
Sourcepub fn from_text(text: &str) -> TextVector
pub fn from_text(text: &str) -> TextVector
Create a text vector from input text.
Sourcepub fn tokenize(text: &str) -> Vec<String>
pub fn tokenize(text: &str) -> Vec<String>
Tokenize text into terms (language-agnostic). Splits on whitespace and punctuation, lowercases. Preserves non-ASCII alphanumeric runs (CJK, Hangul, etc.) within tokens.
Sourcepub fn cosine_similarity(&self, other: &TextVector) -> f64
pub fn cosine_similarity(&self, other: &TextVector) -> f64
Compute cosine similarity between two vectors.
Trait Implementations§
Source§impl Clone for TextVector
impl Clone for TextVector
Source§fn clone(&self) -> TextVector
fn clone(&self) -> TextVector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextVector
impl Debug for TextVector
Source§impl<'de> Deserialize<'de> for TextVector
impl<'de> Deserialize<'de> for TextVector
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextVector, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextVector, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for TextVector
impl Serialize for TextVector
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for TextVector
impl RefUnwindSafe for TextVector
impl Send for TextVector
impl Sync for TextVector
impl Unpin for TextVector
impl UnsafeUnpin for TextVector
impl UnwindSafe for TextVector
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