I am a beginner to the C++ language and I don't understand how to make a program that acts as a spell-checker. ie the person inputs a word and if the word is not found in some big dictionary list of words, then the program outputs a list of several "close" words. Could someone please give me some psuedocode to work with? I am totally lost. Thanks!
C++ programming help?
First, you'll want to load the dictionary into an array of strings in alphabetical order.
Then, run a simple binary search on the array of strings. If the binary search returns positive, the word is in the dictionary. If it returns negative, it is not. But you can take that return value (let's call it "ret") and do:
int ip = (ret + 1) * -1
This will give you the Insertion Point, or the point at where the word would be if it WERE in the array (even though it's not). Knowing the insertion point, you can print out values in the array around it like
cout %26lt;%26lt; dict[ip];
cout %26lt;%26lt; dict[ip+1];
cout %26lt;%26lt; dict[ip+2];
A binary search algorithm that will work for you can be found at:
http://www.fredosaurus.com/notes-cpp/alg...
Simply modify it so instead of searching arrays of ints, it searches arrays of strings.
Good luck!
Reply:Hello, Yahoo Member. Don't stress about this topic too much. It can worry you and may even have an outcome on the quality of your program. First, you need to know that if you are willing to take the time to make such a large program, you should find the right tools, like a C/C++ IDE, C++ User Library (may contain the a program with a list of the entire Webster's Collegeate Dictionary array), and proper tutorials. First, you should learn a lot about strings and how to utilize their editing optimization. You can a find a C++ string tutorial here:
http://www.cppreference.com/cppstring/in...
http://www.cppreference.com/cppstring/al...
And most importantly, here:
http://www.cprogramming.com/tutorial/les...
You must also know that if you do not find a proper C++ library created by other programmers, you may have to spend time creating your own C++ library, meaning you would have to copy every entry in the dictionary. If you are willing to do the aforesaid, then you should follow the following steps:
1. Create a prototype (.exe, or .bat prototype file)
2. Learn Windows-based C++ Application programming.
(http://www.codeproject.com/KB/dialog/sdi...
Thank you, and remember to BA this answer!
- Digital Enigma
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment