Method: BLEU.best_match_length
- Defined in:
- lib/zipf/bleu.rb
.best_match_length(hypothesis, references) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/zipf/bleu.rb', line 65 def BLEU::best_match_length hypothesis, references hyp_len = hypothesis.strip.split.size ref_lens = references.map { |r| r.strip.split.size } min = Integer::MAX min_idx = -1 ref_lens.each_with_index { |l,i| min_idx = i if (hyp_len-l).abs < min } return hyp_len, ref_lens[min_idx] end |