#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()
% 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).
% 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.