diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2014-02-16 00:05:48 +0100 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2014-02-16 00:05:48 +0100 |
commit | 0023defd7a3c2ecde219f1364ed06668ec59186a (patch) | |
tree | 27b6e901aa1043e3ff85982ffec9a7986a28369d /hopefear.rb | |
parent | cbafa90cb1a6b363b797c0f889c1c35749dee874 (diff) |
proper
Diffstat (limited to 'hopefear.rb')
-rw-r--r-- | hopefear.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/hopefear.rb b/hopefear.rb index 0423d26..918b71f 100644 --- a/hopefear.rb +++ b/hopefear.rb @@ -1,12 +1,12 @@ def hope_and_fear kbest, action max = -1.0/0 max_idx = -1 - kbest.each_with_index { |i,j| - if action=='hope' && i.score + i.other_score > max - max_idx = j; max = i.score + i.other_score + kbest.each_with_index { |k,i| + if action=='hope' && k.scores[:decoder] + k.scores[:psb] > max + max_idx = i; max = k.scores[:decoder] + k.scores[:psb] end - if action=='fear' && i.score - i.other_score > max - max_idx = j; max = i.score - i.other_score + if action=='fear' && k.scores[:decoder] - k.scores[:psb] > max + max_idx = i; max = k.scores[:decoder] - k.scores[:psb] end } return kbest[max_idx] @@ -36,7 +36,7 @@ def gethopefear_fear_no_exec kbest, feedback, gold, max hope = hope_and_fear(kbest, 'hope') type2 = true end - kbest.sort{|x,y|(y.score+y.other_score)<=>(x.score+x.other_score)}.each_with_index { |k,i| + kbest.sort{|x,y|(y.scores[:decoder]+y.scores[:psb])<=>(x.scores[:decoder]+x.scores[:psb])}.each_with_index { |k,i| break if i==max if !exec(k.s, gold, true)[0] fear = k @@ -65,7 +65,7 @@ end def gethopefear_fear_no_exec_hope_exec kbest, feedback, gold, max hope = fear = nil; hope_idx = 0 type1 = type2 = false - sorted_kbest = kbest.sort{|x,y|(y.score+y.other_score)<=>(x.score+x.other_score)} + sorted_kbest = kbest.sort{|x,y|(y.scores[:decoder]+y.scores[:psb])<=>(x.scores[:decoder]+x.scores[:psb])} if feedback == true hope = kbest[0] type1 = true |