Re: return string that is the difference between two other strings
Re: return string that is the difference between two other strings
- Subject: Re: return string that is the difference between two other strings
- From: Diederik Meijer | Ten Horses <email@hidden>
- Date: Sun, 21 Sep 2014 08:38:22 +0200
Meaning I would compare words and their index in an array of words created from the two strings. The first mismatch is easily found, but the tricky part is finding the last one. Here a context driven comparison may help. Instead of comparing word N in both strings, you compare words N and N-1, taking into consideration the number of extra words found in previous iterations. I have not tested this specific case, but can tell you context driven may help. All depends on whether you need the actual difference returned. If not, life is easy :-)
Verstuurd vanaf mijn iPhone
> Op 21 sep. 2014 om 08:24 heeft Diederik Meijer | Ten Horses <email@hidden> het volgende geschreven:
>
> I do a lot of text data mining and need similar functions a lot. I would start on a word by word level, to have whatever it returns be more meaningfull
>
> Verstuurd vanaf mijn iPhone
>
>>> Op 20 sep. 2014 om 19:43 heeft Scott Ribe <email@hidden> het volgende geschreven:
>>>
>>> On Sep 20, 2014, at 11:13 AM, 2551 <email@hidden> wrote:
>>>
>>> For example:
>>>
>>> NSString *mary = @"mary had a little lamb, a little lamb she had";
>>> NSString *scary = @"mary had a little lamb, a little naughty fella of a lamb she had for sure";
>>> NSString *isDifferent = [self getDifference:mary and: scary];
>>> NSLog(@"%@", isDifferent);
>>>
>>> The method I posted below produces the difference that I want ("naughty fella of a for sure"). But I want to know if there's a more orthodox and robust solution.
>>
>> That's not even remotely close to a definition of what you mean. What about:
>>
>> @"mary had a little lamb, a little naughty lamb she had"
>>
>> vs
>>
>> @"mary had a little lamb, a little fella of a lamb she had for sure"
>>
>> ?
>>
>> Or:
>>
>> @"mary had a little lamb, a naughty little lamb she had"
>>
>> vs
>>
>> @"mary had a big lamb, a little fella of a lamb she had for sure"
>>
>> There is no simple definition of "the difference between two strings", and I don't think it's a basic need at all.
>>
>> --
>> Scott Ribe
>> email@hidden
>> http://www.elevated-dev.com/
>> (303) 722-0567 voice
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden