Re: return string that is the difference between two other strings

2014-09-21 Thread Kyle Sluder
On Sep 20, 2014, at 9:08 PM, 2551 2551p...@gmail.com wrote: As I've been saying all along, this is such a common operation, I'd have thought there must be a common cocoa method or API for doing it. So the question is, can anyone tell me what that is? No, it is nowhere near a common

Re: return string that is the difference between two other strings

2014-09-21 Thread Diederik Meijer | Ten Horses
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 scott_r...@elevated-dev.com het volgende geschreven: On Sep 20,

Re: return string that is the difference between two other strings

2014-09-21 Thread Diederik Meijer | Ten Horses
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,

Re: return string that is the difference between two other strings

2014-09-21 Thread 2551
On 21 Sep 2014, at 13:38, Diederik Meijer | Ten Horses diede...@tenhorses.com wrote: Meaning I would compare words and their index in an array of words created from the two strings. Thanks, Diederik. That's exactly the approach I took by using NSMutableArray's -removeObject.

Re: return string that is the difference between two other strings

2014-09-21 Thread 2551
On 21 Sep 2014, at 13:03, Kyle Sluder k...@ksluder.com wrote: No, it is nowhere near a common operation to perform on strings. I stand corrected on that front, then (apparently...). Doesn't change the fact that I need to know how to do it, unless someone is willing to point me in the

Re: return string that is the difference between two other strings

2014-09-21 Thread Allan Odgaard
On 21 Sep 2014, at 6:08, 2551 wrote: As I've been saying all along, this is such a common operation, I'd have thought there must be a common cocoa method or API for doing it. So the question is, can anyone tell me what that is? The general problem you’re dealing with is that of finding the

Re: return string that is the difference between two other strings

2014-09-21 Thread 2551
On 21 Sep 2014, at 13:45, Allan Odgaard lists+cocoa-...@simplit.com wrote: One solution is the UNIX diff command x-man-page://1/diff which, as Jens previously mentioned, works on lines and is commonly used by version control systems and programmers. You can call out to this command from Cocoa

Re: return string that is the difference between two other strings

2014-09-21 Thread Diederik Meijer | Ten Horses
Note that there are two differences, I would want to know: where string A says this, string B says that. So you have both this and 'that for a difference. A lot of times, pre-optimizing your strings helps, meaning you first take out punctuation (mostly comma's) and remember where to put them

Re: return string that is the difference between two other strings

2014-09-21 Thread Jens Alfke
On Sep 20, 2014, at 11:45 PM, Allan Odgaard lists+cocoa-...@simplit.com wrote: If you need a C API then have a look at https://code.google.com/p/google-diff-match-patch/ https://code.google.com/p/google-diff-match-patch/ This^^ looks like exactly what you want, 2551. The online demo is

RE: return string that is the difference between two other strings

2014-09-21 Thread Lee Ann Rucker
On 21 Sep 2014, at 13:03, Kyle Sluder k...@ksluder.com wrote: No, it is nowhere near a common operation to perform on strings. I stand corrected on that front, then (apparently...). Doesn't change the fact that I need to know how to do it, unless someone is willing to point me in the

return string that is the difference between two other strings

2014-09-20 Thread 2551
I've searched high and low (or roundabouts in circles) for a built in method that will return the difference between two strings as a string. I hacked up this solution below, but it feels cludgy and isn't very robust (punctuation will mess it up a little); worse, I can't help feeling I must be

Re: return string that is the difference between two other strings

2014-09-20 Thread SevenBits
On Sep 20, 2014, at 1:01 PM, 2551 2551p...@gmail.com wrote: I've searched high and low (or roundabouts in circles) for a built in method that will return the difference between two strings as a string. I hacked up this solution below, but it feels cludgy and isn't very robust

Re: return string that is the difference between two other strings

2014-09-20 Thread 2551
Really? OK. On 21 Sep 2014, at 00:05, SevenBits sevenbitst...@gmail.com wrote: On Sep 20, 2014, at 1:01 PM, 2551 2551p...@gmail.com wrote: I've searched high and low (or roundabouts in circles) for a built in method that will return the difference between two strings as a string. I

Re: return string that is the difference between two other strings

2014-09-20 Thread Keary Suska
On Sep 20, 2014, at 11:13 AM, 2551 2551p...@gmail.com 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

Re: return string that is the difference between two other strings

2014-09-20 Thread Scott Ribe
On Sep 20, 2014, at 11:13 AM, 2551 2551p...@gmail.com 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

Re: return string that is the difference between two other strings

2014-09-20 Thread Jens Alfke
On Sep 20, 2014, at 10:43 AM, Scott Ribe scott_r...@elevated-dev.com wrote: There is no simple definition of the difference between two strings, and I don't think it's a basic need at all. Usually when programmers talk about differences they're referring to something like what a 'diff'

Re: return string that is the difference between two other strings

2014-09-20 Thread SevenBits
On Sep 20, 2014, at 1:43 PM, Scott Ribe scott_r...@elevated-dev.com wrote: On Sep 20, 2014, at 11:13 AM, 2551 2551p...@gmail.com 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

Re: return string that is the difference between two other strings

2014-09-20 Thread 2551
Definition: On 21 Sep 2014, at 00:53, Jens Alfke j...@mooseyard.com wrote: a set of the words that are in the second string but not in the first That's close. Any words that are in one string but not in the other. Yup, that is what I'm after. I'll pass if people start asking me what I mean

Re: return string that is the difference between two other strings

2014-09-20 Thread Kyle Sluder
On Sep 20, 2014, at 11:54 AM, 2551 2551p...@gmail.com wrote: I'll pass if people start asking me what I mean by a 'word', though I'm well aware that that is a genuine question at certain levels and across different localisations. Take it that for the purpose of the inquiry I mean any

Re: return string that is the difference between two other strings

2014-09-20 Thread Gerd Knops
NSLinguisticTagger might be worth a look. And if you don't care about word counts, NSMutableSet -minusSet: or -intersectSet: could be of help as well. Gerd On Sep 20, 2014, at 1:54 PM, 2551 2551p...@gmail.com wrote: Definition: On 21 Sep 2014, at 00:53, Jens Alfke j...@mooseyard.com

Re: return string that is the difference between two other strings

2014-09-20 Thread 2551
On 21 Sep 2014, at 02:56, Ludovic Nicolle lnico...@chezludo.com wrote: Once we (and maybe yourself? :p ) know what you truly want OK, I should have presented the problem, rather than a solution that needed improving. If you have two text files written out at different times, how do you guys

Re: return string that is the difference between two other strings

2014-09-20 Thread Jens Alfke
On Sep 20, 2014, at 7:54 PM, 2551 2551p...@gmail.com wrote: OK, I should have presented the problem, rather than a solution that needed improving. If you have two text files written out at different times, how do you guys determine the difference between their contents to produce a third

Re: return string that is the difference between two other strings

2014-09-20 Thread 2551
On 21 Sep 2014, at 10:58, Jens Alfke j...@mooseyard.com wrote: What I'd want is something that shows the combined text with the deleted words crossed out and the new words highlighted. Thanks, Jens. You've hit the nail on the head. That's exactly what I want to achieve. I said order didn't