about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--malaprop.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/malaprop.cpp b/malaprop.cpp index 7fbdb6c..c308d34 100644 --- a/malaprop.cpp +++ b/malaprop.cpp
@@ -117,6 +117,12 @@ 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 // Not sure why this can even happen but it is happenining????
123 return word;
124 }
125
120 int opt = rand() % opts.size(); 126 int opt = rand() % opts.size();
121 for (std::set<std::string>::iterator it = opts.begin(); it != opts.end(); it++) 127 for (std::set<std::string>::iterator it = opts.begin(); it != opts.end(); it++)
122 { 128 {