Chat on IRC |
string
Posted by aquaman [send private reply] at October 08, 2001, 08:24:02 PM
#ifndef WORDUTILS_H
#define WORDUTILS_H #include std::string lowercase (const std::string& s); // Converts all upper-case alphabetic characters in s to the // corresponding lowercase characters. // Example: lowercase("ABcdE?") should return "abcde?" std::string stem (const std::string& word); // Tries to guess the stem form of an English word by applying // the following rules: (# and % stand for any consonant, and // @ for any vowel [aeiou]. // // If word ends in: replace it by: example: // ies y flies => fly // ied y carried => carry // ier y merrier => merry // iest y merriest => merry // ##ed # hitted => hit // ##ing # hitting => hit // ##er # hitter => hit // ##est # hottest => hot // %@#ed %@#e glided => glide // %@#ing %@#e gliding => glide // %@#er %@#e glider => glide // %@#est %@#e palest => pale // #ed # barked => bark // #ing # boiling => boil // #er # colder => cold // #est # coldest => cold // #s # things => thing // If none of the above rules apply, then the word is assumed to be already // in its stem form. This function returns the stem that it guesses. // [Note that these really are guesses - it isn't hard to find words on which // these rules fail. E.g., "pies"] // #endif //New functions collectMisspelledWords (/* inputs */ targetFile, dictionaryFile, /* outputs */ misspellings) { read dictionaryFile into dictionary; open targetFile; misspellings = empty; while more words in targetFile { read word w from targetFile; w = LOWERCASE(w); if ((w is not in dictionary) && (STEM(w) is not in dictionary)) { add w to misspellings; } } close targetFile; } The two functions capitalized are new. I am trying to write the bodies for the two string manipulation functions, as declared in the wordutils.h. The two functions should work entirely through the std::string interfaceI think I can do it with character arrays but I do not thing the prof wants that. Any help would be great. Thanks Aquaman
Posted by Psion [send private reply] at October 08, 2001, 08:41:42 PM
I hope no one just writes it for you. Try asking specific questions if you are stuck on something. If you are completely lost, then the thing to do is have a talk with an instructor of this course, not try to get us to make a special web course for you. :-)
Posted by RedX [send private reply] at October 09, 2001, 01:39:29 PM
It might be handy to read your books about the string class.
To quote Stroustrup (The C++ programming language 3th edition p584) "Individual characters of a string can be accessed through subscripting." (string means the class "string") So anything you can do with a character array, you can do with a string object. RedX
Register as a new user | |||||