4 releases

0.0.5 Nov 26, 2023
0.0.4 Nov 23, 2023
0.0.3 Nov 22, 2023
0.0.2 Nov 22, 2023
0.0.1 Nov 19, 2023

#802 in Algorithms

34 downloads per month

MIT/Apache

39KB
726 lines

DAWG (Directed Acyclic Word Graph)

References

  1. Incremental Construction of Minimal Acyclic Finite-State Automata
  2. Compressing Dictionaries with a DAWG
  3. Lecture 25 | Programming Abstractions (Stanford) [Video]

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

NOTE:

  1. THIS CRATE IS NOT PRODUCTION READY YET (Use at your own risk)
  2. Contributions are welcome

lib.rs:

Implementation of Directed Acyclic Word Graph (DAWG) in Rust (pronounced "DAWG") as described by Steve Hanov Compressing Dictionaries with a DAWG (thank you!!)

Add the following to your Cargo.toml

[depedencies.dawg]
version = "x"
features = ["threading" ]

[threading] - Support Send + Sync

use dawg::Dawg;

let mut dawgie = Dawg::new();
let mut words = vec!["BAM", "BAT", "BATH", "CATH", "BATHE", "CAR", "CARS", "CAREERS, "SILENT", "LIST", "LISTEN", "AYÒ", "ÒYÀ"].iter().map(|w| w.to_string().to_uppercase()).collect::<Vec<_>>();

words.sort();

for word in words {
    dawgie.insert(word.to_string());
}

// to avoid unintended behaviours always remember to close (.finish) after building the dawg

dawgie.finish();


assert!(dawgie.lookup("BATH").is_some());
assert!(dawgie.is_some());

Dependencies

~0.7–1.3MB
~26K SLoC