3 ms·
I wrote this as well as submitting it. Any suggestions, thoughts, etc. would be greatly appreciated.
by jackowayed 18y ago
I wrote this as well as submitting it.
Any suggestions, thoughts, etc. would be greatly appreciated.
- boucher 18y agoWhy sentences and not words?
- jackowayed 18y agohmmm It might sort of drown you (a 15-word sentence totally changed to a different 15-word sentence would take up 30 lines. My default terminal size holds 36 lines. But really because I never thought of it. Might give it a try and see if it's better.
- anewaccountname 18y agoMaybe he didn't design this for phonologists? I doubt anyone else has too much use for intra-word diffs.
- jrockway 18y agoI think it would be useful. Consider this example. The original sentence is: "He went to the stoar." Person A sends this to person B for review. While Person B is reviewing this, Person A changes the sentence to "Bill went to the stoar.". Then, Person B sends back the spelling correction; "He went to the store.". If the sentence translated to one line for `diff` to work on, this would be a merge conflict. If each word was its own line, this would merge cleanly.
- keenerd 18y agoYou've just described dwdiff. Not the smartest diff algo, though its strong point is producing diffs of prose that are human readable. I used it as the core of a wiki with 'perfect' collision resolution. Two people could edit at the same time, and the 2nd to hit save would have their work merged in with dwdiff instead of having their work automatically discarded.
- socmoth 18y agoi like this and needed it about a week ago. i eventually had to write my own script. i also found dwdiff, which you may like because it is very similar and very unixy http://www.linux.com/feature/114176 http://www.linux.com/feature/114176
- ntoshev 18y agoI would approach this problem differently: tokenize the text and diff the stream of tokens (as opposed to a stream of characters).
- akkartik 18y agoOh my eyes.. :) I suggest replacing main with def file_with_split_sentences(old) contents = File.read(old).split_keep_after(/[\.!\?] *[A-Z\n]/, 2) begin newname = "#{old}-sdiff-#{random_chars 5}"; end while File.exists?(newname) File.open(newname, "w") { |file| file.write contents.join("\n")} newname end fnames = ARGV[-2..-1].collect{|f| file_with_split_sentences f.chomp} system "diff #{ARGV[0...-2].join " "} #{fnames.join " "}" "rm #{fnames.join " "}"