私は、次の文があるとします。Rubyで3つのセンテンスにデルタを使用するには?
s1 = "The red dog jumped over the hill, followed by the crazy clown."
s2 = "The green fox jumped over the hill, followed by the crazy clown."
s3 = "The red dog jumped over the hill, followed by the dumb dolphin."
私はいくつかの圧縮形式でS2-S1とS3-S1のデルタを格納できるようにしたい、のように:s2_d_s1 = - 「赤犬」+ "グリーンfox "
次に、私はこれらのデルタをとり、s2_d_s1またはs3_d_s1のいずれかを最初から順番に適用できます。次のように等しい:
apply_delta(apply_delta(s1, s2_d_s1), s3_d_s1) ==
apply_delta(apply_delta(s1, s3_d_s1), s2_d_s1)
apply_delta(s1, s2_d_s1) == "The green fox jumped over the hill, followed by the crazy clown."
私はこれをRubyでどうやって行いますか?それを行うライブラリはありますか?
(実際のコンテンツは、文章よりも複雑になるだろう。それは文書です。)
私はfossilizeを試してみたが、変化する文のサイズを処理する方法を見つけ出すことはできません(最初のデルタを適用する文を変更サイズは2番目のデルタを適用してねじ込みます)。
s1 = "The red dog jumped over the hill, followed by the crazy clown."
s2 = "The green fox jumped over the hill, followed by the crazy clown."
s3 = "The red dog jumped over the hill, followed by the dumb dolphin."
s2_d_s1 = Fossilize.create(s1, s2)
s3_d_s1 = Fossilize.create(s1, s3)
Fossilize.apply(Fossilize.apply(s1, s2_d_s1), s3_d_s1)
DeltaApplicationError: Output was -1, but I expected 63!
from /Users/me/.rvm/gems/ruby-2.2.1/gems/fossilize-1.1.1/lib/fossilize.rb:107:in `apply'
from (irb):14
from /Users/me/.rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'
[ruby-git](https://github.com/schacon/ruby-git)はあなたを助けますか? –
Gitはデルタだけでなく、ファイルの状態全体を記録しているので、探しているものではありません。 gitが差分を保持するのはよくある誤解です。 –