first attempt at fixing the w-bug, todo: test
authorKevin Brubeck Unhammer <pixiemotion@gmail.com>
Wed, 20 Aug 2008 12:31:47 +0000 (20 14:31 +0200)
committerKevin Brubeck Unhammer <pixiemotion@gmail.com>
Wed, 20 Aug 2008 12:31:47 +0000 (20 14:31 +0200)
src/loc_h_dmv.py

index 35ea49d..52620fd 100644 (file)
@@ -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: