before removing sum_hat_a from p_ATTACH
authorKevin Brubeck Unhammer <pixiemotion@gmail.com>
Wed, 3 Sep 2008 13:41:33 +0000 (3 15:41 +0200)
committerKevin Brubeck Unhammer <pixiemotion@gmail.com>
Wed, 3 Sep 2008 13:41:33 +0000 (3 15:41 +0200)
src/loc_h_dmv.py
src/loc_h_dmv.pyc

index a23fa9a..6f34f9b 100644 (file)
@@ -750,9 +750,13 @@ def reest_head2(h, g, corpus, p_ROOT, p_STOP, p_ATTACH):
     def hat_d(xbar,x,xi,xj): return hat_d2(xbar,x,xi,xj, g, corpus)
     def hat_a(a, x, dir  ): return hat_a2(a, x, dir,   g, corpus)
     def div(num,den):
-#        return num # todo: test without division by sum_hat_a
+        if not ("0.0"=="%s"%den or "1.0"=="%s"%den):
+            print "in reest_head2:div, got den=%s"%den
+#         return num # todo: test without division by sum_hat_a
         if den > 0.0: return num / den
-        else: return den
+        else:
+            if num > 0.0: raise ValueError
+            return den
     
     p_STOP[h, LEFT,NON] = \
         hat_d((SEAL,h),(RGOL,h),xlt,  xgteq) + \
@@ -1101,7 +1105,7 @@ if __name__ == "__main__":
     pprint.pprint(q_tree)
     pprint.pprint(f_T_q)
     print sum([f for f in f_T_q.values()])
-
+    
     def treediv(num,den):
         return sum([f_T_q[i] for i in num ]) / \
         sum([f_T_q[i] for i in den ])
@@ -1129,6 +1133,13 @@ if __name__ == "__main__":
     vrtrees = (1,2,3,4,5,6,7,
                7,2)
     g2['v> --> v> _n_'] = treediv( (2,7), vrtrees )
+
+    g2[' v|n,R '] = treediv( (1,  2,  6),
+                             (1,1,2,3,6) )
+    g2[' n|n,R '] = treediv( (1,    3),
+                             (1,1,2,3,6) )
     
     pprint.pprint(g2)
+    g3 = reestimate2(g, ['n v n'.split()])
+    print g3
     
index 1da9ac8..e0854ad 100644 (file)
Binary files a/src/loc_h_dmv.pyc and b/src/loc_h_dmv.pyc differ