1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// SymSpellComplete, a typo-tolerant autocomplete library in Rust.
//
// Copyright (C) 2025 Wolf Garbe
// Version: 0.0.1
// Author: Wolf Garbe wolf.garbe@seekstorm.com
// Maintainer: Wolf Garbe wolf.garbe@seekstorm.com
// URL: https://github.com/wolfgarbe/symspell
// Description: https://seekstorm.com/blog/1000x-spelling-correction/
//
// MIT License
// Copyright (c) 2026 Wolf Garbe
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// https://opensource.org/licenses/MIT
/*!
#### Usage of SymSpellComplete library
Auto-complete with pruning radix trie
```rust
use symspell_complete_rs::PruningRadixTrie;
use std::path::Path;
let mut pruning_radix_trie=PruningRadixTrie::new();
let _= pruning_radix_trie.load_completions(Path::new("./data/frequency_dictionary_en_82_765.txt"), 0, 1, " ");
let input = "predic";
let expected_completion = "prediction";
let completions=pruning_radix_trie.lookup_completions(input, None);
```
Single word spelling correction
```rust
use symspell_complete_rs::{SymSpell, Verbosity};
use std::path::Path;
let max_edit_distance_dictionary = 2; //maximum edit distance per dictionary precalculation
let mut symspell: SymSpell = SymSpell::new(max_edit_distance_dictionary,None, 7, 1);
// single term dictionary
let term_index = 0; //column of the term in the dictionary text file
let count_index = 1; //column of the term frequency in the dictionary text file
symspell.load_dictionary(Path::new("data/frequency_dictionary_en_82_765.txt"), term_index, count_index, " ");
//lookup suggestions for single-word input strings
let input_term = "hous";
let suggestion_verbosity = Verbosity::Closest;//Top, Closest, All
let max_edit_distance_lookup = 1; //max edit distance per lookup (maxEditDistanceLookup<=maxEditDistanceDictionary)
let suggestions = symspell.lookup(input_term, suggestion_verbosity, max_edit_distance_lookup,&None,None,false);
//display suggestions, edit distance and term frequency
println!("{:?}", suggestions);
```
Compound aware multi-word spelling correction
```rust
use symspell_complete_rs::{SymSpell, Verbosity};
use std::path::Path;
let max_edit_distance_dictionary = 2; //maximum edit distance per dictionary precalculation
let mut symspell = SymSpell::new(max_edit_distance_dictionary, None,7, 1);
// single term dictionary
let term_index = 0; //column of the term in the dictionary text file
let count_index = 1; //column of the term frequency in the dictionary text file
symspell.load_dictionary(Path::new("data/frequency_dictionary_en_82_765.txt"), term_index, count_index, " ");
// bigram dictionary
symspell.load_bigram_dictionary(Path::new("data/frequency_bigramdictionary_en_243_342.txt"),0,2, " ",
);
//lookup suggestions for multi-word input strings (supports compound splitting & merging)
let input_sentence = "whereis th elove hehad dated forImuch of thepast who couqdn'tread in sixtgrade and ins pired him";
let max_edit_distance_lookup = 2; //max edit distance per lookup (per single word, not per whole input string)
let compound_suggestions = symspell.lookup_compound(input_sentence, max_edit_distance_lookup,&None,false);
//display suggestions, edit distance and term frequency
println!("{:?}", compound_suggestions);
```
Word Segmentation of noisy text
```rust
use symspell_complete_rs::{SymSpell, Verbosity};
use std::path::Path;
let max_edit_distance_dictionary = 0; //maximum edit distance per dictionary precalculation
let mut symspell = SymSpell::new(max_edit_distance_dictionary, None,7, 1);
// single term dictionary
let term_index = 0; //column of the term in the dictionary text file
let count_index = 1; //column of the term frequency in the dictionary text file
symspell.load_dictionary(Path::new("data/frequency_dictionary_en_82_765.txt"), term_index, count_index, " ");
//word segmentation and correction for multi-word input strings with/without spaces
let input_sentence = "thequickbrownfoxjumpsoverthelazydog";
let max_edit_distance_lookup = 0;
let result = symspell.word_segmentation(input_sentence, max_edit_distance_lookup);
//display term and edit distance
println!("{:?}", result.segmented_string);
```
Word Segmentation of Chinese text
```rust
use symspell_complete_rs::{SymSpell, Verbosity};
use std::path::Path;
let max_edit_distance_dictionary = 0; //maximum edit distance per dictionary precalculation
let mut symspell = SymSpell::new(max_edit_distance_dictionary,None, 7, 1);
// single term dictionary
let term_index = 0; //column of the term in the dictionary text file
let count_index = 1; //column of the term frequency in the dictionary text file
symspell.load_dictionary(Path::new("data/frequency_dictionary_zh_cn_349_045.txt"), term_index, count_index, " ");
//word segmentation and correction for multi-word input strings with/without spaces
let input_sentence = "部分居民生活水平";
let max_edit_distance_lookup = 0;
let result = symspell.word_segmentation(input_sentence, max_edit_distance_lookup);
//display term and edit distance
println!("{:?}", result.segmented_string);
```
*/
;
pub use ;
pub use ;