in [Python]

From: GZ on 3 Jun 2010 22:54 Hi All, I am looking for an algorithm that can compare to source code files line by line and find the minimum diff. I have looked at the difflib included in python. The problem is that it is designed to make the diff results easier for humans to read, instead of minimize the size of the output differencial. I would like an algorithm implementation that gives the absolute minimum difference between the two files. Can you help me? Thanks, gz
From: Patrick Maupin on 4 Jun 2010 15:55 On Jun 3, 9:54 pm, GZ <zyzhu2... (a)gmail.com> wrote:> Hi All, > > I am looking for an algorithm that can compare to source code files > line by line and find the minimum diff. I have looked at the difflib > included in python. The problem is that it is designed to make the > diff results easier for humans to read, instead of minimize the size > of the output differencial. I would like an algorithm implementation > that gives the absolute minimum difference between the two files. > > Can you help me? > > Thanks, > gz There's an "rsync.py" module in pypi -- one would think that would have to solve that same problem... Regards, Pat
From: GZ on 4 Jun 2010 17:51 Hi Pat, On Jun 4, 2:55 pm, Patrick Maupin <pmau... (a)gmail.com> wrote:> On Jun 3, 9:54 pm, GZ <zyzhu2... (a)gmail.com> wrote:> > > Hi All, > > > I am looking for an algorithm that can compare to source code files > > line by line and find the minimum diff. I have looked at the difflib > > included in python. The problem is that it is designed to make the > > diff results easier for humans to read, instead of minimize the size > > of the output differencial. I would like an algorithm implementation > > that gives the absolute minimum difference between the two files. > > > Can you help me? > > > Thanks, > > gz > > There's an "rsync.py" module in pypi -- one would think that would > have to solve that same problem... > > Regards, > Pat No, rsync does not solve my problem. I want a library that does unix 'diff' like function, i.e. compare two strings line by line and output the difference. Python's difflib does not work perfectly for me, because the resulting differences are pretty big. I would like an algorithm that generates the smallest differences.
From: Lie Ryan on 4 Jun 2010 21:37 On 06/05/10 07:51, GZ wrote: > Hi Pat, > > On Jun 4, 2:55 pm, Patrick Maupin <pmau... (a)gmail.com> wrote:>> On Jun 3, 9:54 pm, GZ <zyzhu2... (a)gmail.com> wrote:>> >>> Hi All, >> >>> I am looking for an algorithm that can compare to source code files >>> line by line and find the minimum diff. I have looked at the difflib >>> included in python. The problem is that it is designed to make the >>> diff results easier for humans to read, instead of minimize the size >>> of the output differencial. I would like an algorithm implementation >>> that gives the absolute minimum difference between the two files. >> >>> Can you help me? >> >>> Thanks, >>> gz >> >> There's an "rsync.py" module in pypi -- one would think that would >> have to solve that same problem... >> >> Regards, >> Pat > > No, rsync does not solve my problem. > > I want a library that does unix 'diff' like function, i.e. compare two > strings line by line and output the difference. Python's difflib does > not work perfectly for me, because the resulting differences are > pretty big. I would like an algorithm that generates the smallest > differences. is n=0 not short enough? pprint.pprint(list(difflib.context_diff(s, t, n=0)))
From: GZ on 5 Jun 2010 01:43
On Jun 4, 8:37 pm, Lie Ryan <lie.1... (a)gmail.com> wrote:> On06/05/10 07:51, GZ wrote: > > > > > > > Hi Pat, > > > On Jun 4, 2:55 pm, Patrick Maupin <pmau... (a)gmail.com> wrote:> >> On Jun 3, 9:54 pm, GZ <zyzhu2... (a)gmail.com> wrote:> > >>> Hi All, > > >>> I am looking for an algorithm that can compare to source code files > >>> line by line and find the minimum diff. I have looked at the difflib > >>> included in python. The problem is that it is designed to make the > >>> diff results easier for humans to read, instead of minimize the size > >>> of the output differencial. I would like an algorithm implementation > >>> that gives the absolute minimum difference between the two files. > > >>> Can you help me? > > >>> Thanks, > >>> gz > > >> There's an "rsync.py" module in pypi -- one would think that would > >> have to solve that same problem... > > >> Regards, > >> Pat > > > No, rsync does not solve my problem. > > > I want a library that does unix 'diff' like function, i.e. compare two > > strings line by line and output the difference. Python's difflib does > > not work perfectly for me, because the resulting differences are > > pretty big. I would like an algorithm that generates the smallest > > differences. > > is n=0 not short enough? > > pprint.pprint(list(difflib.context_diff(s, t, n=0))) This still does not do what I want it to do. It only displays the diff results in a different format. I want a different algorithm to generate a smaller diff -- in other words less differences |