Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Created March 16, 2015 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanfb/c9bd9a1ce0f6f7cb2a45 to your computer and use it in GitHub Desktop.
Save ryanfb/c9bd9a1ce0f6f7cb2a45 to your computer and use it in GitHub Desktop.
#!/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