1 if __name__ == "__main__":
2 # these are not Real rules, just testing the classes. todo: make
3 # a rule-set to test inner() on.
5 s = DMV_Rule((LRBAR,0), (NOBAR,1),(NOBAR,2), 1.0, 0.0) # s->np vp
6 np = DMV_Rule((NOBAR,1), (NOBAR,3),(NOBAR,4), 0.3, 0.0) # np->n p
7 b[(NOBAR,1), 'n'] = 0.7 # np->'n'
8 b[(NOBAR,3), 'n'] = 1.0 # n->'n'
9 b[(NOBAR,4), 'p'] = 1.0 # p->'p'
10 vp = DMV_Rule((NOBAR,2), (NOBAR,5),(NOBAR,1), 0.1, 0.0) # vp->v np (two parses use this rule)
11 vp2 = DMV_Rule((NOBAR,2), (NOBAR,2),(NOBAR,4), 0.9, 0.0) # vp->vp p
12 b[(NOBAR,5), 'v'] = 1.0 # v->'v'
14 g = DMV_Grammar([s,np,vp,vp2], b, "todo","todo", "todo")
17 test1 = io.inner(0,0, (NOBAR,1), g, ['n'], {})
19 print "should be 0.70 : %.2f" % test1[0]
22 test2 = io.inner(0,2, (NOBAR,2), g, ['v','n','p'], {})
23 if "%.2f" % test2[0] != "0.09": # 0.092999 etc, don't care about that
24 print "should be 0.09 if the io.py-test is right : %.2f" % test2[0]
25 # the following should manage to look stuff up in the chart:
26 test2 = io.inner(0,2, (NOBAR,2), g, ['v','n','p'], test2[1])
27 if "%.2f" % test2[0] != "0.09":
28 print "should be 0.09 if the io.py-test is right : %.2f" % test2[0]