aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nerv/examples/lmptb/lmptb/lmutil.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/nerv/examples/lmptb/lmptb/lmutil.lua b/nerv/examples/lmptb/lmptb/lmutil.lua
index 6d66d6e..13a5c45 100644
--- a/nerv/examples/lmptb/lmptb/lmutil.lua
+++ b/nerv/examples/lmptb/lmptb/lmutil.lua
@@ -112,10 +112,17 @@ end
--cla:string
--w:string
--prob:float, the probability
-function Result:add(cla, w, prob)
- self[cla].logp_all = self[cla].logp_all + math.log10(prob)
+function Result:add(cla, w, prob, log10ed)
+ local lp
+ if log10ed == true then
+ lp = prob
+ else
+ lp = math.log10(prob)
+ end
+
+ self[cla].logp_all = self[cla].logp_all + lp
if (self.vocab:is_unk_str(w)) then
- self[cla].logp_unk = self[cla].logp_unk + math.log10(prob)
+ self[cla].logp_unk = self[cla].logp_unk + lp
self[cla].cn_unk = self[cla].cn_unk + 1
end
if (w == self.vocab.sen_end_token) then