Verified Commit 54819b62 authored by nagayama15's avatar nagayama15

calculate extraction rate using levenshtein distance

parent 3c4c6c0f
#!/usr/bin/env ruby
require_relative './common'
require 'amatch'
watermark = WATERMARK
......@@ -10,7 +11,14 @@ METHODS.each do |method|
OPT_PASSES.each do |pass|
b = a.to_s.end_with?(".wasm.txt") ? a.sub(".wasm.txt", "-#{pass}.wasm.txt") : a.sub(".txt", "-#{pass}.txt")
puts "#{a.basename} - #{b.basename}: #{method[:name]}, #{pass}, #{FileUtils.cmp(a, b) ? "○" : "☓"}"
a_lines = File.readlines(a)
b_lines = File.readlines(b)
a_bits = a_lines[0].to_i
b_bits = b_lines[0].to_i
a_wm = [a_lines[1]].pack("H*").unpack("B*")[0][0, a_bits]
b_wm = [b_lines[1]].pack("H*").unpack("B*")[0][0, b_bits]
puts "#{a.basename}, #{b.basename}, #{method[:name]}, #{pass}, #{a_bits}, #{b_bits}, #{a_wm.levenshtein_similar(b_wm)}"
end
end if method[:name] != "null"
end
......@@ -77,7 +77,7 @@ OPT_PASSES = [
WATERMARK = "N7AStlK2gioIqeRi"
def copy(file, out)
FileUtils.copy(file, out, {:verbose => true})
FileUtils.copy(file, out)
end
def embed(file, out, method, watermark, chunk_size = 20)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment