mirror of
https://github.com/mii443/esaxx-rs.git
synced 2025-08-22 15:05:33 +00:00
26 lines
854 B
Markdown
26 lines
854 B
Markdown

|
|
|
|
# esaxx-rs
|
|
|
|
This code implements a fast suffix tree / suffix array.
|
|
|
|
This code is taken from 
|
|
and to be used by .
|
|
|
|
|
|
Small wrapper around sentencepiece's esaxx suffix array C++ library.
|
|
Usage
|
|
|
|
```rust
|
|
let string = "abracadabra";
|
|
let suffix = esaxx_rs::suffix(string).unwrap();
|
|
let chars: Vec<_> = string.chars().collect();
|
|
let mut iter = suffix.iter();
|
|
assert_eq!(iter.next().unwrap(), (&chars[..4], 2)); // abra
|
|
assert_eq!(iter.next(), Some((&chars[..1], 5))); // a
|
|
assert_eq!(iter.next(), Some((&chars[1..4], 2))); // bra
|
|
assert_eq!(iter.next(), Some((&chars[2..4], 2))); // ra
|
|
assert_eq!(iter.next(), Some((&chars[..0], 11))); // ''
|
|
assert_eq!(iter.next(), None);
|
|
```
|