aboutsummaryrefslogtreecommitdiff
path: root/nerv/examples/lmptb/lmptb/lmutil.lua
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2016-02-17 20:14:06 +0800
committerDeterminant <ted.sybil@gmail.com>2016-02-17 20:14:06 +0800
commit0ee43c21af4fcd3aed070b1f5ad1eb9feb2ad159 (patch)
treeceb1d38328767fb657bc0d37ec6e513b08a86277 /nerv/examples/lmptb/lmptb/lmutil.lua
parent490a10c2130773bd022f05513fa2905b6a6c6e91 (diff)
try to merge manually
Diffstat (limited to 'nerv/examples/lmptb/lmptb/lmutil.lua')
-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