blitztext 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {blitztext-0.2.0 → blitztext-0.2.1}/Cargo.lock +1 -1
  2. {blitztext-0.2.0 → blitztext-0.2.1}/Cargo.toml +1 -1
  3. {blitztext-0.2.0 → blitztext-0.2.1}/PKG-INFO +1 -1
  4. {blitztext-0.2.0 → blitztext-0.2.1}/src/keyword_processor.rs +13 -2
  5. {blitztext-0.2.0 → blitztext-0.2.1}/.github/workflows/CI.yml +0 -0
  6. {blitztext-0.2.0 → blitztext-0.2.1}/.gitignore +0 -0
  7. {blitztext-0.2.0 → blitztext-0.2.1}/LICENSE +0 -0
  8. {blitztext-0.2.0 → blitztext-0.2.1}/README.md +0 -0
  9. {blitztext-0.2.0 → blitztext-0.2.1}/benches/benchmark.py +0 -0
  10. {blitztext-0.2.0 → blitztext-0.2.1}/benches/benchmark.rs +0 -0
  11. {blitztext-0.2.0 → blitztext-0.2.1}/benches/benchmark_full.py +0 -0
  12. {blitztext-0.2.0 → blitztext-0.2.1}/benches/benchmark_results.md +0 -0
  13. {blitztext-0.2.0 → blitztext-0.2.1}/benches/benchmark_results_multi.png +0 -0
  14. {blitztext-0.2.0 → blitztext-0.2.1}/benches/benchmark_results_single.png +0 -0
  15. {blitztext-0.2.0 → blitztext-0.2.1}/blitztext.pyi +0 -0
  16. {blitztext-0.2.0 → blitztext-0.2.1}/examples/basic_usage.py +0 -0
  17. {blitztext-0.2.0 → blitztext-0.2.1}/examples/basic_usage.rs +0 -0
  18. {blitztext-0.2.0 → blitztext-0.2.1}/pyproject.toml +0 -0
  19. {blitztext-0.2.0 → blitztext-0.2.1}/src/bin/manual_benchmark.rs +0 -0
  20. {blitztext-0.2.0 → blitztext-0.2.1}/src/char_set.rs +0 -0
  21. {blitztext-0.2.0 → blitztext-0.2.1}/src/compiled_trie.rs +0 -0
  22. {blitztext-0.2.0 → blitztext-0.2.1}/src/fuzzy.rs +0 -0
  23. {blitztext-0.2.0 → blitztext-0.2.1}/src/lib.rs +0 -0
  24. {blitztext-0.2.0 → blitztext-0.2.1}/src/trie.rs +0 -0
  25. {blitztext-0.2.0 → blitztext-0.2.1}/src/utils.rs +0 -0
  26. {blitztext-0.2.0 → blitztext-0.2.1}/tests/integration_test.rs +0 -0
  27. {blitztext-0.2.0 → blitztext-0.2.1}/tests/test_python_api.py +0 -0
@@ -49,7 +49,7 @@ dependencies = [
49
49
 
50
50
  [[package]]
51
51
  name = "blitztext"
52
- version = "0.2.0"
52
+ version = "0.2.1"
53
53
  dependencies = [
54
54
  "bincode",
55
55
  "criterion",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "blitztext"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  edition = "2021"
5
5
  authors = ["Praise Oketola <oketola.praise@gmail.com>"]
6
6
  description = "A library for fast keyword extraction and replacement in strings."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blitztext
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -26,7 +26,7 @@ pub struct KeywordProcessor {
26
26
  /// Faster read-only copy of `root`, dropped when keywords change.
27
27
  #[serde(skip)]
28
28
  compiled: OnceLock<CompiledTrie>,
29
- /// Number of nodes in `root`; counted on first use after deserializing.
29
+ /// Number of nodes in `root`, kept current by add and remove; counted once after deserializing.
30
30
  #[serde(skip)]
31
31
  node_count: OnceLock<usize>,
32
32
  /// Matching work done with `root` since keywords last changed, in text bytes.
@@ -84,7 +84,7 @@ impl KeywordProcessor {
84
84
  case_sensitive,
85
85
  allow_overlaps,
86
86
  compiled: OnceLock::new(),
87
- node_count: OnceLock::new(),
87
+ node_count: OnceLock::from(1),
88
88
  work_since_change: AtomicUsize::new(0),
89
89
  }
90
90
  }
@@ -1594,6 +1594,17 @@ mod tests {
1594
1594
  assert_eq!(kp.replace_keywords("İstanbul istanbul", None), "İstanbul IST");
1595
1595
  }
1596
1596
 
1597
+ #[test]
1598
+ fn node_count_stays_exact_through_adds_and_removes() {
1599
+ let mut kp = KeywordProcessor::new();
1600
+ for keyword in ["rust", "rusty", "go", "café"] {
1601
+ kp.add_keyword(keyword, None);
1602
+ }
1603
+ kp.remove_keyword("rusty");
1604
+ kp.remove_keyword("go");
1605
+ assert_eq!(kp.node_count.get(), Some(&kp.root.count_nodes()));
1606
+ }
1607
+
1597
1608
  #[test]
1598
1609
  fn non_ascii_keywords_can_be_listed_looked_up_and_removed() {
1599
1610
  let mut kp = KeywordProcessor::new();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes