Search code examples
iosdictionarynsstringuitextchecker

Identify word is plural or singular in iOS


I am checking words typed by users. I want to get unique words. For checking if the word is valid or not I am using following code:

UITextChecker *checker = [[UITextChecker alloc] init];
NSLocale *currentLocale = [NSLocale currentLocale];
NSString *currentLanguage = [currentLocale objectForKey:NSLocaleLanguageCode];
NSRange searchRange = NSMakeRange(0, [word length]);

NSRange misspelledRange = [checker rangeOfMisspelledWordInString:word range: searchRange startingAt:0 wrap:NO language: currentLanguage];
if (misspelledRange.location == NSNotFound) // valid word
else // Invalid word

This is working well but the problem is it Identifies Hand and Hands as a different words as both are different in spell. I want to get only one which occurs first. I can't check with the s as the last character as I and Is are really different.

Is there any way to get identify the singular or plural words?

If I have any word can I get it's plural and singular word?

Thanks.


Solution

  • All plural word doesn't suffice s or es to their singular part.

    So the answer is NO.