From e61ead3f31bf3aacc886a374dcdfb074e8d333d3 Mon Sep 17 00:00:00 2001 From: Spencerjibz Date: Sun, 24 Mar 2024 01:03:40 +0000 Subject: [PATCH] enable non-static-synonyms features --- Cargo.lock | 7 +++---- Cargo.toml | 9 +++------ src/models/aggregation_models.rs | 10 ++++++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d063020..faa6084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3665,17 +3665,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e33ea271e53da683cd3439c04ff3b734f3d6052ea33a65ec9e0fa89a4f96369" dependencies = [ "lazy_static", - "thesaurus-wordnet", + "thesaurus-moby", ] [[package]] -name = "thesaurus-wordnet" +name = "thesaurus-moby" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0b5b98479fc7554a0cedad4c03264b1caeecc7af51b4e44945c759bab43e35" +checksum = "28f7806d5dbe7d9b627e332f88269a014a6a1d40ec411d4ea66cb702aabce4cf" dependencies = [ "libflate", - "serde_json", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 1d3411d..fd6e873 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,12 +85,9 @@ keyword_extraction = { version = "1.3.0", default-features = false, features = [ ] } -stop-words = { version = "0.8.0", default-features = false, features = [ - "iso", -]} +stop-words = { version = "0.8.0", default-features = false, features = ["iso"] } thesaurus = { version = "0.5.2", default-features = false, optional = true, features = [ "moby", - "static", ] } [dev-dependencies] @@ -131,6 +128,7 @@ rpath = false strip = "symbols" [features] +use-synonyms-search = ["thesaurus/static"] default = ["memory-cache"] dhat-heap = ["dep:dhat"] memory-cache = ["dep:mini-moka"] @@ -139,5 +137,4 @@ compress-cache-results = ["dep:async-compression", "dep:cfg-if"] encrypt-cache-results = ["dep:chacha20poly1305", "dep:chacha20"] cec-cache-results = ["compress-cache-results", "encrypt-cache-results"] experimental-io-uring = ["actix-web/experimental-io-uring"] -use-synonyms-search = ["dep:thesaurus\static"] -use-non-static-synonyms-search = ["dep:thesaurus"] +use-non-static-synonyms-search = ["thesaurus"] diff --git a/src/models/aggregation_models.rs b/src/models/aggregation_models.rs index b0973d2..c046b1c 100644 --- a/src/models/aggregation_models.rs +++ b/src/models/aggregation_models.rs @@ -4,7 +4,10 @@ use super::engine_models::EngineError; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; -#[cfg(feature = "use-synonyms-search")] +#[cfg(any( + feature = "use-synonyms-search", + feature = "use-non-static-synonyms-search" +))] use thesaurus::synonyms; /// A named struct to store the raw scraped search results scraped search results from the /// upstream search engines before aggregating it.It derives the Clone trait which is needed @@ -254,7 +257,10 @@ fn calculate_tf_idf( let mut search_tokens = vec![]; for token in query_tokens { - #[cfg(feature = "use-synonyms-search")] + #[cfg(any( + feature = "use-synonyms-search", + feature = "use-non-static-synonyms-search" + ))] { // find some synonyms and add them to the search (from wordnet or moby if feature is enabled) let synonyms = synonyms(&token);