pub fn mkgrams(s: &str, depth: usize) -> HashSet<String> {
    let mut gs = HashSet::<String>::new();
    let norm: Vec<char> = s.nfd().collect();
    let len: usize = norm.len();
    for i in 0..len {
        for j in 0..cmp::min(depth, len - i) {
            if let Some(slicette) = norm.get(i..=(i + j + 1)) {
                gs.insert(slicette.into_iter().collect::<String>());
            }
        }
    }
    gs
}
/// Make a set of char n-grams from a string, to a given depth.
///
/// # Example
/// ```rust
/// # use indexrs::mkgrams;
/// let foo = mkgrams("foobarbazfoobar", 6);
/// let bar = mkgrams("barbazfoobarbaz", 6);
/// assert_eq!(foo, bar);
/// ```
Make a set of char n-grams from a string, to a given depth.
Make a set of char n - grams from a string to a given depth .
pub fn mkgrams(s: &str, depth: usize) -> HashSet<String> {
    let mut gs = HashSet::<String>::new();
    let norm: Vec<char> = s.nfd().collect();
    let len: usize = norm.len();
    for i in 0..len {
        for j in 0..cmp::min(depth, len - i) {
            if let Some(slicette) = norm.get(i..=(i + j + 1)) {
                gs.insert(slicette.into_iter().collect::<String>());
            }
        }
    }
    gs
}
pub fn mkgrams ( s : & str , depth : usize ) -> HashSet < String > { let mut gs = HashSet :: < String > :: new ( ) ; let norm : Vec < char > = s . nfd ( ) . collect ( ) ; let len : usize = norm . len ( ) ; for i in 0 .. len { for j in 0 .. cmp :: min ( depth , len - i ) { if let Some ( slicette ) = norm . get ( i ..= ( i + j + 1 ) ) { gs . insert ( slicette . into_iter ( ) . collect :: < String > ( ) ) ; } } } gs }
Make a set of char n-grams from a string, to a given depth.
Make a set of char n - grams from a string to a given depth .
s
&str
depth
usize
example
None
use indexrs::mkgrams;
let foo = mkgrams("foobarbazfoobar", 6);
let bar = mkgrams("barbazfoobarbaz", 6);
assert_eq!(foo, bar);
```
let foo = mkgrams ( " foobarbazfoobar " 6 ) ; let bar = mkgrams ( " barbazfoobarbaz " 6 ) ; assert_eq! ( foo bar ) ; ` ` `