I need to do the intelligence Sentence comparison in Objective C.
The Detail’s are explained below.
I have one main string. I named it as “OriginalString”
NSString *OriginalString = @""HOW DID STUDENT EMILY DO TODAY";
Then I have many strings, that i need to compare with the Original String.They are
NSString *CompareString1 = @"HOW DID EMILY DO "
NSString *CompareSting = @"HOW DID YOUR FATHER"
NSString *CompareString2 = @"WHAT IS YOUR EMILY"
NSString *CompareString3 = @"THIS IS THE FAST DO ONE"
NSString *CompareString4 = @"THIS SEARCH EMILY EXAMPLE DO"
From these 5 CompareStrings ,i need to get the string “HOW DID EMILY DO” which is highest relative to the Original string(HOW DID STUDENT EMILY DO TODAY) .
Let me tell you one thing.
If i have an additional string in the group of CompareStrings As “HOW DID STUDENT DO TODAY”
So now i have the CompareStrings are
NSString *CompareString1 = @"HOW DID EMILY DO "
NSString *CompareSting = @"HOW DID YOUR FATHER"
NSString *CompareString2 = @"WHAT IS YOUR EMILY"
NSString *CompareString3 = @"THIS IS THE FAST DO ONE"
NSString *CompareString4 = @"THIS SEARCH EMILY EXAMPLE DO"
NSString *CompareString4 = @"HOW DID STUDENT DO TODAY"
From these 6 CompareStrings ,i need to get the string “HOW DID STUDENT DO TODAY” which is highest relative to the Original string (HOW DID STUDENT EMILY DO TODAY)
I have looked the NSPredicate “comparison and like” methods. However i didn’t found any way to do the process
Any help on figuring out this concept is appreciated.
Thanks.
Sounds like comp-sci homework. It’s sloppy and inefficient as hell, but it will work. I’m sure somebody on here has a better idea to improve performance.
Break down your phrases that you want to search for into arrays of individual words:
Now myWords is an array of each word (no spaces). Then, build a predicate looking for each of the words:
When you are done, you’ll end up with a
foundyou can compare for each of the different phrases. The one that is greatest matched the most words.In this case, you’d end up counting like this:
HOW DID STUDENT EMILY DO TODAY