Create a gist now

Instantly share code, notes, and snippets.

@ryanfb /ocrquality.rb Secret
Created Mar 16, 2015

What would you like to do?
#!/usr/bin/env ruby
total_lines = 0
total_score = 0
ARGF.each do |line|
langid, text = line.split("\t")
/\('(?<lang>..)', (?<score>.+)\)/ =~ langid
score = score.to_f
text.strip!
if text.length != 0
total_lines += 1
total_score += score
end
end
puts 1.0 - (total_score / total_lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment