From f38c9bb8db75804923d33a2339f6a29ead35f7bf Mon Sep 17 00:00:00 2001 From: Kevin Brubeck Unhammer Date: Wed, 20 Aug 2008 14:31:47 +0200 Subject: [PATCH] first attempt at fixing the w-bug, todo: test --- src/loc_h_dmv.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/loc_h_dmv.py b/src/loc_h_dmv.py index 35ea49d..52620fd 100644 --- a/src/loc_h_dmv.py +++ b/src/loc_h_dmv.py @@ -394,6 +394,7 @@ def reest_freq(g, corpus): if not p_sent > 0.0: return h = POS(x) + a_k = {} for k in xtween(i, j): p_out = f(i,j, x,loc_h, sent) if not p_out > 0.0: @@ -406,10 +407,12 @@ def reest_freq(g, corpus): p_rule = g.p_GO_AT_or0(a, h, RIGHT, adj(k, loc_h)) p_R = e(k,j, (SEAL,a),loc_a, sent) p = p_L * p_out * p_R * p_rule - try: - fr['hat_a','num',a,x] += p - except: - fr['hat_a','num',a,x] = p + try: a_k[a] += p + except: a_k[a] = p + + for a,p in a_k.iteritems(): + try: fr['hat_a','num',a,x] += p / p_sent + except: fr['hat_a','num',a,x] = p / p_sent # end reest_freq.w_right() # in reest_freq: -- 2.11.4.GIT