Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions crates/terraphim_automata/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ fn index_inner(name: String, messages: Vec<Message>) -> Thesaurus {
let concept_with_display = match current_concept {
Some(ref cwd) => {
// Create NormalizedTerm with display_value preserving original case
let nterm =
NormalizedTerm::new(cwd.concept.id.clone(), cwd.concept.value.clone())
.with_display_value(cwd.display_name.clone());
let nterm = NormalizedTerm::new(cwd.concept.id, cwd.concept.value.clone())
.with_display_value(cwd.display_name.clone());
thesaurus.insert(cwd.concept.value.clone(), nterm.clone());
cwd
}
Expand All @@ -173,7 +172,7 @@ fn index_inner(name: String, messages: Vec<Message>) -> Thesaurus {
for synonym in synonyms {
// Synonyms also get the same display_value (the concept's original name)
let nterm = NormalizedTerm::new(
concept_with_display.concept.id.clone(),
concept_with_display.concept.id,
concept_with_display.concept.value.clone(),
)
.with_display_value(concept_with_display.display_name.clone());
Expand Down
2 changes: 2 additions & 0 deletions crates/terraphim_automata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ fn parse_thesaurus_json(contents: &str) -> Result<Thesaurus> {
}

#[derive(Deserialize)]
#[allow(dead_code)]
struct LegacyTerm {
#[allow(dead_code)]
id: u64,
nterm: String,
#[serde(default)]
Expand Down
2 changes: 1 addition & 1 deletion crates/terraphim_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ async fn handle_thesaurus(
let thesaurus = service.get_thesaurus(&role_name).await?;

let mut entries: Vec<_> = thesaurus.into_iter().collect();
entries.sort_by_key(|(_, term)| term.id.clone());
entries.sort_by_key(|(_, term)| term.id);

let total_count = entries.len();
let terms: Vec<ThesaurusTerm> = entries
Expand Down
2 changes: 1 addition & 1 deletion crates/terraphim_mcp_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl McpService {
candidates.push(AutocompleteResult {
term: meta.original_term.clone(),
normalized_term: meta.normalized_term.clone(),
id: meta.id.clone(),
id: meta.id,
url: meta.url.clone(),
score: 0.0,
});
Expand Down
32 changes: 16 additions & 16 deletions crates/terraphim_rolegraph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl TriggerIndex {
for token in &unique {
*doc_freq.entry(token.to_string()).or_insert(0) += 1;
}
self.triggers.insert(node_id.clone(), tokens);
self.triggers.insert(*node_id, tokens);
}

// Compute IDF: log((N + 1) / (df + 1)) + 1 (smoothed)
Expand Down Expand Up @@ -175,7 +175,7 @@ impl TriggerIndex {
let similarity = dot / (query_norm * doc_norm);

if similarity >= self.threshold {
results.push((node_id.clone(), similarity));
results.push((*node_id, similarity));
}
}

Expand Down Expand Up @@ -242,7 +242,7 @@ impl TriggerIndex {
pub fn get_trigger_descriptions(&self) -> AHashMap<u64, String> {
self.triggers
.iter()
.map(|(node_id, tokens)| (node_id.clone(), tokens.join(" ")))
.map(|(node_id, tokens)| (*node_id, tokens.join(" ")))
.collect()
}
}
Expand Down Expand Up @@ -434,7 +434,7 @@ impl RoleGraph {
log::trace!("Finding matching node IDs for text: '{text}'");
self.ac
.find_iter(text)
.map(|mat| self.aho_corasick_values[mat.pattern()].clone())
.map(|mat| self.aho_corasick_values[mat.pattern()])
.collect()
}

Expand Down Expand Up @@ -669,7 +669,7 @@ impl RoleGraph {
matched_edges: vec![edge.clone()],
rank: total_rank,
tags: vec![normalized_term.to_string()],
nodes: vec![node_id.clone()],
nodes: vec![node_id],
quality_score: None,
});
}
Expand All @@ -678,7 +678,7 @@ impl RoleGraph {
doc.rank += total_rank; // Adjust to correctly aggregate the rank
doc.matched_edges.push(edge.clone());
// Remove duplicate edges based on unique IDs
doc.matched_edges.dedup_by_key(|e| e.id.clone());
doc.matched_edges.dedup_by_key(|e| e.id);
}
}
}
Expand Down Expand Up @@ -769,7 +769,7 @@ impl RoleGraph {
matched_edges: vec![edge.clone()],
rank: total_rank,
tags: vec![normalized_term.to_string()],
nodes: vec![node_id.clone()],
nodes: vec![node_id],
quality_score: None,
});
}
Expand All @@ -778,7 +778,7 @@ impl RoleGraph {
doc.rank += total_rank; // Adjust to correctly aggregate the rank
doc.matched_edges.push(edge.clone());
// Remove duplicate edges based on unique IDs
doc.matched_edges.dedup_by_key(|e| e.id.clone());
doc.matched_edges.dedup_by_key(|e| e.id);
}
}
}
Expand Down Expand Up @@ -873,21 +873,21 @@ impl RoleGraph {
matched_edges: vec![edge.clone()],
rank: total_rank,
tags: vec![normalized_term.to_string()],
nodes: vec![node_id.clone()],
nodes: vec![node_id],
quality_score: None,
});
}
Entry::Occupied(mut e) => {
let doc = e.get_mut();
doc.rank += total_rank;
doc.matched_edges.push(edge.clone());
doc.matched_edges.dedup_by_key(|e| e.id.clone());
doc.matched_edges.dedup_by_key(|e| e.id);
// Add the tag if not already present
if !doc.tags.contains(&normalized_term.to_string()) {
doc.tags.push(normalized_term.to_string());
}
if !doc.nodes.contains(&node_id) {
doc.nodes.push(node_id.clone());
doc.nodes.push(node_id);
}
}
}
Expand Down Expand Up @@ -977,7 +977,7 @@ impl RoleGraph {
matched_edges: vec![edge.clone()],
rank: total_rank,
tags: vec![normalized_term.to_string()],
nodes: vec![node_id.clone()],
nodes: vec![node_id],
quality_score: None,
},
vec![term.to_string()],
Expand All @@ -987,12 +987,12 @@ impl RoleGraph {
let (doc, terms) = e.get_mut();
doc.rank += total_rank;
doc.matched_edges.push(edge.clone());
doc.matched_edges.dedup_by_key(|e| e.id.clone());
doc.matched_edges.dedup_by_key(|e| e.id);
if !doc.tags.contains(&normalized_term.to_string()) {
doc.tags.push(normalized_term.to_string());
}
if !doc.nodes.contains(&node_id) {
doc.nodes.push(node_id.clone());
doc.nodes.push(node_id);
}
if !terms.contains(&term.to_string()) {
terms.push(term.to_string());
Expand Down Expand Up @@ -1026,7 +1026,7 @@ impl RoleGraph {
combined_doc
.matched_edges
.extend(term_doc.matched_edges.clone());
combined_doc.matched_edges.dedup_by_key(|e| e.id.clone());
combined_doc.matched_edges.dedup_by_key(|e| e.id);

for tag in &term_doc.tags {
if !combined_doc.tags.contains(tag) {
Expand All @@ -1036,7 +1036,7 @@ impl RoleGraph {

for node in &term_doc.nodes {
if !combined_doc.nodes.contains(node) {
combined_doc.nodes.push(node.clone());
combined_doc.nodes.push(*node);
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/terraphim_rolegraph/src/medical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ impl MedicalRoleGraph {
for &condition_id in conditions {
let is_contraindicated =
// drug -> condition
self.outgoing_edges.get(&drug_id).map_or(false, |edges| {
self.outgoing_edges.get(&drug_id).is_some_and(|edges| {
edges
.iter()
.any(|&(t, et)| t == condition_id && et == MedicalEdgeType::Contraindicates)
})
||
// condition -> drug
self.outgoing_edges.get(&condition_id).map_or(false, |edges| {
self.outgoing_edges.get(&condition_id).is_some_and(|edges| {
edges
.iter()
.any(|&(t, et)| t == drug_id && et == MedicalEdgeType::Contraindicates)
Expand Down
3 changes: 2 additions & 1 deletion crates/terraphim_usage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ which = "6.0"
terraphim_persistence = { path = "../terraphim_persistence", optional = true }
terraphim_types = { path = "../terraphim_types" }
terraphim_settings = { path = "../terraphim_settings" }
opendal = { version = "0.54", optional = true }

[features]
default = ["persistence", "providers"]
persistence = ["dep:terraphim_persistence"] # Enable storage via terraphim_persistence
persistence = ["dep:terraphim_persistence", "dep:opendal"] # Enable storage via terraphim_persistence
cli = ["dep:clap", "dep:colored", "dep:indicatif"] # Enable CLI commands
providers = ["dep:reqwest"] # Enable external provider API fetchers
Loading
Loading