From 27bc315543a4e3002e5d4ec0e37be3dcc2e3114e Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 12 Feb 2014 17:44:06 +0100 Subject: per sentence bleu, spawn with timeout --- lib/nlp_ruby/ttable.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/nlp_ruby/ttable.rb') diff --git a/lib/nlp_ruby/ttable.rb b/lib/nlp_ruby/ttable.rb index 598e318..14d6c5d 100644 --- a/lib/nlp_ruby/ttable.rb +++ b/lib/nlp_ruby/ttable.rb @@ -15,18 +15,21 @@ def read_phrase_table fn return table end +# FIXME class Translation - attr_accessor :id, :s, :raw, :f, :score + attr_accessor :id, :s, :raw, :f, :score, :rank, :other_score - def initialize id=nil, raw=nil, s=nil, f=nil, score=nil + def initialize id=nil, raw=nil, s=nil, f=nil, score=nil, rank=nil, other_score=nil @id = id @raw = raw @s = s @f = f @score = score + @rank = rank + @other_score = other_score end - def from_s t, strip_alignment=true + def from_s t, strip_alignment=true, rank=nil id, raw, features, score = splitpipe(t, 3) raw.strip! @raw = raw @@ -39,10 +42,16 @@ class Translation @id = id.to_i @f = read_feature_string features @score = score.to_f + @rank = rank + @other_score = nil end def to_s - [id, s, f.to_kv, score].join ' ||| ' + [@id, @s, @f.to_kv, @score].join ' ||| ' + end + + def to_s2 + [@rank, @s, @f.to_kv, @score, @other_score].join ' ||| ' end end -- cgit v1.2.3