0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 22:18:23 -05:00

enable non-static-synonyms features

This commit is contained in:
Spencerjibz 2024-03-24 01:03:40 +00:00
parent 8c7ab9ba98
commit e61ead3f31
3 changed files with 14 additions and 12 deletions

7
Cargo.lock generated
View File

@ -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]]

View File

@ -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"]

View File

@ -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);