Is there a way to diff files sentence-by-sentence

2019-04-05 12:01发布

问题:

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 sentence-by-sentence. Thanks.

Edit

wdiff is almost perfect. But is there a merge equivalent, as diff has with diff3?

回答1:

wdiff will give you a word-by-word diff instead of line-by-line. I'm not aware of any sentence-by-sentence diff programs.



回答2:

Preprocess the files before diffing them. Write a script to write one sentence per line and any line by line diff program will work.

I have done this on a C token level for diffing C code in order to make absolutely sure my CVS merge was correct.