question about maps

i have a question about maps, im working on a spell check i have load dictionary which is going to be a set, and i have that correct, but for the map part im confused, so what i what to do for my spellcheck function to see if there any misspelling.
example.txt
My nam
output.txt
My name

so my function should go like this

i want to read in the file
i want to check the file if there any errors
if there is any errors i want to fix those error like in output.txt.txt
if there no errors i just want to print the file out

i dont know which std::map function to use
and im also using ostream and istream
 
std::map<std::string, std::string> example

please need some type of advice or example
I'm not sure if a map would be the best option for a spell-checker, I'm not exactly sure what you're mapping there. The problem with mapping "nam" to "name" is that there's almost an infinite amount of ways to misspell something, so I don't see how a map would be helpful.

I've never programmed a spell-checker, but this StackOverflow thread gives a good idea of how to do it.
https://stackoverflow.com/questions/2294915/what-algorithm-gives-suggestions-in-a-spell-checker

The brute-force way would be to look at the word, and if it's not in the dictionary, loop through the dictionary and change it to the word with the smallest Damerau-Levenshtein distance.
https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance

But using other data structures as described in the StackOverflow link can be more efficient.
Last edited on
Topic archived. No new replies allowed.