diff options
Diffstat (limited to 'lib/nlp_ruby/Translation.rb')
-rw-r--r-- | lib/nlp_ruby/Translation.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/nlp_ruby/Translation.rb b/lib/nlp_ruby/Translation.rb index 0c346a4..34effe0 100644 --- a/lib/nlp_ruby/Translation.rb +++ b/lib/nlp_ruby/Translation.rb @@ -1,5 +1,5 @@ class Translation - attr_accessor :id, :s, :raw, :f, :score, :rank, :other_score + attr_accessor :id, :s, :raw, :f, :scores, :rank def initialize id=nil, raw=nil, s=nil, f=nil, scores={}, rank=nil @id = id @@ -21,11 +21,17 @@ class Translation @s = raw end @id = id.to_i - @f = read_feature_string features + @f = SparseVector.from_kv features @scores['decoder'] = score.to_f @rank = rank end + def self.from_s s + t = self.new + t.from_s s + return t + end + def to_s include_features=true [@id, @s, @f.to_kv('=', ' '), @scores['decoder']].join(' ||| ') if include_features [@id, @s, @scores['decoder']].join(' ||| ') if !include_features |