Skip to content

Commit

Permalink
Merge pull request #86 from terraphim/replacer
Browse files Browse the repository at this point in the history
Replacer
  • Loading branch information
AlexMikhalev authored May 11, 2024
2 parents 4788519 + a0dc4b3 commit 8bd8085
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Docker Login
run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN"
- name: Run build
run: earthly --org applied-knowledge-systems --sat registry-satellite --ci --push +pipeline
run: earthly --org applied-knowledge-systems --sat registry-satellite --ci --push +pipeline
32 changes: 17 additions & 15 deletions crates/terraphim_automata/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ pub fn find_matches(
}

// // This function replacing instead of matching patterns
// pub fn replace_matches(text: &str, thesaurus: Thesaurus) -> Result<Vec<u8>> {
// let mut patterns: Vec<String> = Vec::new();
// let mut replace_with: Vec<String> = Vec::new();
// for (key, value) in thesaurus.iter() {
// patterns.push(key.to_string());
// replace_with.push(value.clone().id.clone().to_string());
// }
// let ac = AhoCorasick::builder()
// .match_kind(MatchKind::LeftmostLongest)
// .ascii_case_insensitive(true)
// .build(patterns)?;

// let result = ac.replace_all_bytes(text.as_bytes(), &replace_with);
// Ok(result)
// }
pub fn replace_matches(text: &str, thesaurus: Thesaurus) -> Result<Vec<u8>> {
let mut patterns: Vec<String> = Vec::new();
let mut replace_with: Vec<String> = Vec::new();
for (key, value) in thesaurus.into_iter() {
patterns.push(key.to_string());
replace_with.push(value.clone().id.clone().to_string());
}
let ac = AhoCorasick::builder()
.match_kind(MatchKind::LeftmostLongest)
.ascii_case_insensitive(true)
.build(patterns)?;

let result = ac.replace_all_bytes(text.as_bytes(), &replace_with);
Ok(result)
}

// tests
2 changes: 1 addition & 1 deletion crates/terraphim_config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ ulid = { version = "1.0.0", features = ["serde", "uuid"] }
thiserror = "1.0.53"

[dev-dependencies]
tempfile = "3.10.1"
tempfile = "3.10.1"
1 change: 1 addition & 0 deletions desktop/src-tauri/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,4 @@ pub async fn update_config(
let terraphim_service = TerraphimService::new(config_state.inner().clone());
Ok(terraphim_service.update_config(config_new).await?)
}

1 change: 1 addition & 0 deletions docs/src/Docs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Documentation generation
This repository uses mdbook-typest to generate nice looking pdf


3 changes: 1 addition & 2 deletions terraphim_server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use terraphim_rolegraph::RoleGraph;
use terraphim_service::TerraphimService;
use terraphim_types::{Document, IndexedDocument, SearchQuery};

use crate::error::{Result, Status};

use crate::error::{Result, Status};
pub type SearchResultsStream = Sender<IndexedDocument>;

/// Health check endpoint
Expand Down

0 comments on commit 8bd8085

Please sign in to comment.