4 releases
0.0.5 | Nov 26, 2023 |
---|---|
0.0.4 | Nov 23, 2023 |
0.0.3 | Nov 22, 2023 |
0.0.2 |
|
0.0.1 | Nov 19, 2023 |
#802 in Algorithms
34 downloads per month
39KB
726 lines
DAWG (Directed Acyclic Word Graph)
References
- Incremental Construction of Minimal Acyclic Finite-State Automata
- Compressing Dictionaries with a DAWG
- Lecture 25 | Programming Abstractions (Stanford) [Video]
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.NOTE:
- THIS CRATE IS NOT PRODUCTION READY YET (Use at your own risk)
- 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