word-diff

Is there a way to diff files sentence-by-sentence instead of line-by-line?

谁说我不能喝 提交于 2019-12-05 20:22:47
问题 Just trying to get diff to work better for certain kinds of documents. With LaTeX, for example, I might have a long paragraph that is strictly just one line, but I don't want to see that entire paragraph if just a sentence is changed. Particularly if I'm running some kind of version control and a co-author edits the same paragraph (but not the same sentence) as me. I wouldn't want that to show up as a conflict. That's a secondary question. The main question is whether I can use diff to look

Are there java libraries to do a word-based diff?

耗尽温柔 提交于 2019-12-05 08:48:23
I have two pieces of text. I would like to make a word-based diff between them (like whe unix utility wdiff does) but with more information in the output (I mean, the character's posizion where the added/delited word starts). I need to do this in Java, so a simple output of the differences (like wdiff ) doesn't suite for me: I would like to manipulate objects representing differences. There's Diff,Match,Patch - available in Java, and a demo is avilable - it seems to do word differences. 来源: https://stackoverflow.com/questions/2898612/are-there-java-libraries-to-do-a-word-based-diff

Word by word diff comparison of two strings in .NET

社会主义新天地 提交于 2019-12-04 09:42:23
I need to do Word by word comparison of two strings. Something like diff, but for words, not for lines. Like it is done in wikipedia http://en.wikipedia.org/w/index.php?title=Horapollo&action=historysubmit&diff=21895647&oldid=21893459 In result I want return the two arrays of indexes of words, which are different in two string. Are there any libraries/frameworks/standalone_methods for .NET which can do this? P.S. I want to compare several kilobytes of text Actually, you probably want to implement a variation of the Local Alignment/Global Alignment algorithms we use in DNA sequence alignments .

How to display word differences using c#?

橙三吉。 提交于 2019-12-03 06:40:02
问题 I would like to show differences between two blocks of text. Rather than comparing lines of text or individual characters, I would like to just compare words separated by specified characters ('\n', ' ', '\t' for example). My main reasoning for this is that the block of text that I'll be comparing generally doesn't have many line breaks in it and letter comparisons can be hard to follow. I've come across the following O(ND) logic in C# for comparing lines and characters, but I'm sort of at a

How can I optimize this Python code to generate all words with word-distance 1?

和自甴很熟 提交于 2019-12-03 03:55:09
问题 Profiling shows this is the slowest segment of my code for a little word game I wrote: def distance(word1, word2): difference = 0 for i in range(len(word1)): if word1[i] != word2[i]: difference += 1 return difference def getchildren(word, wordlist): return [ w for w in wordlist if distance(word, w) == 1 ] Notes: distance() is called over 5 million times, majority of which is from getchildren, which is supposed to get all words in the wordlist that differ from word by exactly 1 letter.

showing differences within a line in diff output

喜夏-厌秋 提交于 2019-12-03 01:41:45
This StackOverflow answer has an image of KDiff3 highlighting intra-line differences. Does someone know of a tool which can show the same (ex, via color) on the command line? Another way to think of this is wanting to diff each difference in a patch file. ire_and_curses I don't know if this is sufficiently command line for your purpose, but vimdiff can do this (even does colour). See for example the image in this related question . I tried all the tools I found: wdiff, dwdiff, kdiff3, vimdiff to show the difference between two long and slightly different lines. My favourite is diff-highlight

How to display word differences using c#?

自作多情 提交于 2019-12-02 19:13:46
I would like to show differences between two blocks of text. Rather than comparing lines of text or individual characters, I would like to just compare words separated by specified characters ('\n', ' ', '\t' for example). My main reasoning for this is that the block of text that I'll be comparing generally doesn't have many line breaks in it and letter comparisons can be hard to follow. I've come across the following O(ND) logic in C# for comparing lines and characters, but I'm sort of at a loss for how to modify it to compare words. In addition, I would like to keep track of the separators

How can I use `git diff --color-words` outside a Git repository?

一世执手 提交于 2019-12-02 17:50:36
How can I get output like in git diff --color-words , but outside Git? Closest thing is wdiff -t , but it underlines/inverts things instead of using green/red colours and does not allow specifying my whitespace regex. git diff --color-words --no-index According to a comment from Jefromi you can just use git diff --color-words file1 file2 outside of git repositories too. Git version 1.9.1: git diff --word-diff=color fileA fileB you can say git diff --color=always --color-words , which will give you the color escape codes in the output. you are going to have some shell to interpret the color

How can I optimize this Python code to generate all words with word-distance 1?

穿精又带淫゛_ 提交于 2019-12-02 16:14:21
Profiling shows this is the slowest segment of my code for a little word game I wrote: def distance(word1, word2): difference = 0 for i in range(len(word1)): if word1[i] != word2[i]: difference += 1 return difference def getchildren(word, wordlist): return [ w for w in wordlist if distance(word, w) == 1 ] Notes: distance() is called over 5 million times, majority of which is from getchildren, which is supposed to get all words in the wordlist that differ from word by exactly 1 letter. wordlist is pre-filtered to only have words containing the same number of letters as word so it's guaranteed

How to find difference between two strings?

梦想与她 提交于 2019-11-27 18:22:53
I have two strings and would like to display the difference between them. For example, if I have the strings "I am from Mars" and "I am from Venus", the output could be "I am from Venus ". (Typically used to show what changed in an audit log, etc.) Is there a simple algorithm for this? I am using C# but I guess a generic algorithm could be adapted from any programming language. Or is there a framework class/third-party library that will do this sort of thing? Check this out: http://en.wikipedia.org/wiki/Diff#Algorithm Also: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem There