inline string stem(string word){
if((word[word.length()-3] == 'i' || word[word.length()-3] == 'I') && (word[word.length()-2] == 'n' || word[word.length()-2] == 'N') && (word[word.length()-1] == 'g' || word[word.length()-1] == 'G'))
word.erase(word.length()-3, 3);
return word;}
Why are you using code like this when the run time libraries already provide optimised functions for comparing strings without regard to cas? Read the documentation, either for the
string
class, or the
strXXX
functions. Similarly the
isXXX
functions will determine if a string contains control characters, is all digits etc.