pub struct Cosine;Implementations§
Source§impl Cosine
impl Cosine
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/basic_usage.rs (line 6)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() {
let _cs = Cosine::new();
let feature_extractor = CharacterNGrams {
n: 3,
padder: " ".to_string(),
};
let mut db = HashDB::new(feature_extractor);
db.insert("hello".to_string());
db.insert("help".to_string());
db.insert("halo".to_string());
db.insert("world".to_string());
let (total_collection, avg_size_ngrams, total_ngrams) = db.describe_collection();
println!(
"Database contains {} strings, average n-gram size {:.2}, total n-grams {}.",
total_collection, avg_size_ngrams, total_ngrams
);
//println!("Complete DB State: {:?}", db); # FIX: db needs a fmt.debug implementation
let query = "prepress";
let query_features = db.feature_extractor.extract(query);
let query_size = query_features.len();
println!("Query size: {}", query_size);
println!("Extracted features from query '{}':", query);
for (feature, count) in &query_features {
println!(" - Feature: '{}', Count: {}", feature, count);
}
}Trait Implementations§
Source§impl SimilarityMeasure for Cosine
impl SimilarityMeasure for Cosine
fn minimum_feature_size(&self, query_size: i64, alpha: f64) -> i64
fn maximum_feature_size( &self, _db: &impl SimStringDB, query_size: i64, alpha: f64, ) -> i64
fn similarity_score(&self, x: &[i64], y: &[i64]) -> f64
fn minimum_overlap( &self, query_size: i64, candidate_size: i64, alpha: f64, ) -> i64
Auto Trait Implementations§
impl Freeze for Cosine
impl RefUnwindSafe for Cosine
impl Send for Cosine
impl Sync for Cosine
impl Unpin for Cosine
impl UnwindSafe for Cosine
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