From 454057bf39686323eba83b56c04f5a8063b99e58 Mon Sep 17 00:00:00 2001 From: timv Date: Wed, 12 Dec 2012 23:10:44 -0500 Subject: [PATCH] tweaks. --- bin/defn.py | 1 + bin/stdlib.py | 7 +++++-- examples/papa2.dyna | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bin/defn.py b/bin/defn.py index 89eed96..48bb3b8 100644 --- a/bin/defn.py +++ b/bin/defn.py @@ -92,6 +92,7 @@ def agg_bind(agg_decl, table): '*=': times_equals, '&=': and_equals, '|=': or_equals, + ':-': or_equals, } # commit functors to an aggregator definition to avoid unnecessary lookups. diff --git a/bin/stdlib.py b/bin/stdlib.py index a72275e..4c714b9 100644 --- a/bin/stdlib.py +++ b/bin/stdlib.py @@ -352,9 +352,12 @@ class UserChart(object): #constructor_names = {''.join(functor.split('/')[:-1]) for functor in chart} for _fn in chart: - exec '%s = UserChart(chart[%r])' % (_fn.replace('/', ''), _fn) + try: + exec '%s = UserChart(chart[%r])' % (_fn.replace('/', ''), _fn) + except: + pass #def phrase(A,I,K): # return chart['phrase/3'] -from debug import ip; ip() +from IPython import embed; embed() diff --git a/examples/papa2.dyna b/examples/papa2.dyna index 42a4bfb..a9c8140 100644 --- a/examples/papa2.dyna +++ b/examples/papa2.dyna @@ -1,8 +1,8 @@ % Parsing a simple sentence. % CKY-like parsing -phrase(X,I,K,t(X,TY)) += phrase(Y,I,K,TY) * rewrite(X,Y). -phrase(X,I,K,t(X,TY,TZ)) += phrase(Y,I,J,TY) * phrase(Z,J,K,TZ) * rewrite(X,Y,Z). +phrase(X,I,K,t(X,TY)) max= phrase(Y,I,K,TY) * rewrite(X,Y). +phrase(X,I,K,t(X,TY,TZ)) max= phrase(Y,I,J,TY) * phrase(Z,J,K,TZ) * rewrite(X,Y,Z). goal(P) += phrase("S", 0, *length, P). @@ -27,15 +27,15 @@ rewrite("Det", "a") += 1. % sentence % "Papa at the caviar with the spoon ." -word( "Papa", 0) += 1. -word( "ate", 1) += 1. -word( "the", 2) += 1. -word("caviar", 3) += 1. -word( "with", 4) += 1. -word( "a", 5) += 1. -word( "spoon", 6) += 1. -word( ".", 7) += 1. +word( "Papa", 0). +word( "ate", 1). +word( "the", 2). +word("caviar", 3). +word( "with", 4). +word( "a", 5). +word( "spoon", 6). +word( ".", 7). % for fun, try making the above words facts instead of +=1's. -phrase(W, I, I+1, W) += (word(W, I) > 0) & 1. +phrase(W, I, I+1, W) max= (word(W, I) > 0) & 1. -- 2.50.1