Class: ONPDiff
- Inherits:
-
Object
- Object
- ONPDiff
- Defined in:
- lib/onpdiff.rb
Overview
Use “An O(NP) Sequence Comparison Algorithm” as described by Sun Wu, Udi Manber and Gene Myers in publications.mpi-cbg.de/Wu_1990_6334.pdf
Instance Method Summary collapse
- #diff ⇒ Object
-
#initialize(a, b) ⇒ ONPDiff
constructor
A new instance of ONPDiff.
- #paragraph_diff ⇒ Object
- #short_diff ⇒ Object
Constructor Details
#initialize(a, b) ⇒ ONPDiff
Returns a new instance of ONPDiff.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/onpdiff.rb', line 7 def initialize(a, b) @a, @b = a, b @m, @n = a.size, b.size @backtrack = [] if @reverse = @m > @n @a, @b = @b, @a @m, @n = @n, @m end @offset = @m + 1 @delta = @n - @m end |
Instance Method Details
#diff ⇒ Object
19 20 21 |
# File 'lib/onpdiff.rb', line 19 def diff @diff ||= build_edit_script(compose) end |
#paragraph_diff ⇒ Object
27 28 29 |
# File 'lib/onpdiff.rb', line 27 def paragraph_diff @paragraph_diff ||= build_paragraph_edit_script(diff) end |
#short_diff ⇒ Object
23 24 25 |
# File 'lib/onpdiff.rb', line 23 def short_diff @short_diff ||= build_short_edit_script(compose) end |