This commit is contained in:
Joshua Peek
2013-06-10 10:37:55 -05:00
parent 9822b153eb
commit 490afdddd1

View File

@@ -155,7 +155,7 @@ module Linguist
arr = languages.map { |lang| [lang, token_probability(tok, lang)] } arr = languages.map { |lang| [lang, token_probability(tok, lang)] }
min = arr.map { |a,b| b }.min min = arr.map { |a,b| b }.min
minlog = Math.log(min) minlog = Math.log(min)
if !arr.inject(true) {|result, n| result && n[1] == arr[0][1]} # if not all the same if !arr.inject(true) { |result, n| result && n[1] == arr[0][1] }
printf "%#{maxlen}s%5d", tok, count printf "%#{maxlen}s%5d", tok, count
puts arr.map { |ent| puts arr.map { |ent|
ent[1] == min ? " -" : sprintf("%10.3f", count * (Math.log(ent[1]) - minlog)) ent[1] == min ? " -" : sprintf("%10.3f", count * (Math.log(ent[1]) - minlog))