4
votes

I have two files (f1 and f2) containing some text (or binary data).
How can I quickly find common blocks?

e.g.
f1: ABC DEF
f2: XXABC XEF

output:

common blocks:
length 4: "ABC " in f1@0 and f2@2 length 2: "EF" in f1@5 and f2@8

3
You seem to group items ('ABC', then 'DEF'), the common parts are in the same groups. Is this on purpose? - Xavier Nodet

3 Answers

2
votes

This is a great tool for such purposes.: http://sourceforge.net/projects/duplo/

1
votes

Wikipedia has some pseudocode for finding the longest common substring between two sequences of data. In your case, you simply extract all common substring from the table that are not prefixes of other common substrings (i.e. maximal common substrings).

1
votes

The open-source PMD project has a cut-and-paste detector module which is mentioned on this page: http://pmd.sourceforge.net/integrations.html.