I found 293 “words” that are also proper nouns:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// load the list of words into a string
NSString *wordsData = [NSString stringWithContentsOfFile:@"/usr/share/dict/words" encoding:NSUTF8StringEncoding error:NULL];
// Break words into an array of strings
NSArray *words = [wordsData componentsSeparatedByString:@"\n"];
// load the list of proper names into a string
NSString *namesData = [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames" encoding:NSUTF8StringEncoding error:NULL];
// Break names into an array of strings
NSArray *names = [namesData componentsSeparatedByString:@"\n"];
// Establish indexes and limits for both lists
NSUInteger nextName = 0, nextWord = 0, numNames = [names count], numWords = [words count];
// Create a place to store comparison results and the total number of matching names
NSComparisonResult res;
NSUInteger found = 0;
// While there are still more words and names to check
// (note that this algorithm depends on both lists being sorted)
while (nextName < numNames && nextWord < numWords) {
// Compare the next word with the next name
res = [words[nextWord] localizedCaseInsensitiveCompare:names[nextName]];
switch(res) {
case NSOrderedAscending: // the next word sorts before the next name
nextWord++;
break;
case NSOrderedSame: // match found
// Determine if the two words do not have the same capitalization
if ([words[nextWord] localizedCompare:names[nextName]] != NSOrderedSame) {
NSLog(@"%@[%ld] == %@[%ld]",words[nextWord],nextWord,names[nextName],nextName);
found++;
nextName++;
}
nextWord++;
break;
case NSOrderedDescending: // the next word sorts after the next name
nextName++;
break;
default:
NSLog(@"NSComparisonResult out of range: %ld",(NSUInteger)res);
}
}
NSLog(@"%ld Proper nouns are also words.",found);
}
return 0;