diff options
Diffstat (limited to 'malaprop.cpp')
-rw-r--r-- | malaprop.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/malaprop.cpp b/malaprop.cpp index 7fbdb6c..ccdd4c4 100644 --- a/malaprop.cpp +++ b/malaprop.cpp | |||
@@ -117,6 +117,11 @@ std::string malaprop::alternate(std::string word) | |||
117 | { | 117 | { |
118 | soundex ex = soundify(word); | 118 | soundex ex = soundify(word); |
119 | std::set<std::string>& opts = dict[ex]; | 119 | std::set<std::string>& opts = dict[ex]; |
120 | if (opts.size() == 0) | ||
121 | { | ||
122 | return word; | ||
123 | } | ||
124 | |||
120 | int opt = rand() % opts.size(); | 125 | int opt = rand() % opts.size(); |
121 | for (std::set<std::string>::iterator it = opts.begin(); it != opts.end(); it++) | 126 | for (std::set<std::string>::iterator it = opts.begin(); it != opts.end(); it++) |
122 | { | 127 | { |