Diff of Text

GZ zyzhu2000 at gmail.com
Sat Jun 5 22:35:53 EDT 2010


On Jun 5, 8:42 pm, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
> GZ <zyzhu2... at gmail.com> writes:
> > Let me think of a better way to express what I mean by a "smaller
> >diff." After Idiffthe two strings, I will have something like this:
>
> >   AAA
> > - BBB
> > + CCC
> > + DDD
> > - EEE
>
> > It means the first line does not change, the second line is replaced
> > by the third line, the forth line is new, and the fifth line is
> > deleted.
>
> Are you drawing a distinction between:
>
>   * “line FOO is replaced by line BAR”
>   * “line FOO is deleted, line BAR is added”
>
> Your wording seems to make that distinction, but I don't see how it's
> useful or meaningful in a discussion aboutdiff. Are they not exactly
> the same?
>
> --
>  \     “Injustice is relatively easy to bear; what stings is justice.” |
>   `\                                                 —Henry L. Mencken |
> _o__)                                                                  |
> Ben Finney

I should distinguish between modifications and additions. In my above
example, one line is modified/replaced, one line is added and one line
is deleted. There are a total of 3 edits. I am looking for an
alternative python library other than difflib that minimizes this
number (edit distance).



More information about the Python-list mailing list