*.o
*.pyc
*.swp
+*.pyc
dist/
examples/*.d
examples/*.hist
examples/*.plan
+examples/*.planc
examples/*.plan.py
examples/*.out
if isinstance(xs, basestring):
return xs
else:
- assert len(xs) > 1
- if len(xs) == 2:
+ if len(xs) == 1:
+# [sym] = map(t, xs)
+# return node(sym, ())
+ return t(xs[0]) # doesn't have a label.
+ elif len(xs) == 2:
[sym, a] = map(t, xs)
return node(sym, a)
elif len(xs) == 3:
contents = file(filename).read()
- for i, [x] in enumerate(parse_sexpr(contents)):
+ for i, x in enumerate(parse_sexpr(contents)):
interp.emit(obj(i),
t(x),
ruleix=None,
--- /dev/null
+0 S NP VP
+1.58 ROOT S .
+1.58 ROOT S !
+1.58 ROOT VP !
+3.81 VP V
+3.81 VP V NP
+1.49 VP V VP
+3.81 VP V NP VP
+3.81 VP V SBAR
+3.81 VP V N
+3.81 VP V Adj
+0 SBAR that S
+3.7 NP Det N
+3.7 N Adj N
+0 PP P NP
+3.81 VP VP PP
+3.7 N N PP
+3.81 VP Modal VP
+3 Modal will
+3 Modal would
+3 Modal should
+3 Modal could
+3 Modal can
+3 Modal might
+3 Modal may
+3 Modal must
+4.09 V V -ed
+5.09 V V -ing
+5.09 V V -s
+5.09 V V -0
+5.09 V to V
+4.09 V have
+4.09 V had
+5.09 V having
+5.09 V has
+5.09 V be
+5.09 V was
+5.09 V were
+5.09 V been
+5.09 V being
+5.09 V is
+5.09 V are
+5.09 V go
+5.09 V sleep
+5.09 V kiss
+5.09 V love
+5.09 V spoon
+4.09 V eat
+3.5 V want
+5.09 V say
+4.09 V understand
+4.09 V entice
+3.7 NP Papa
+3.7 NP George
+3.7 NP Laura
+3.7 NP her
+3.7 NP she
+3.7 NP him
+3.7 NP he
+2.7 NP it
+3.7 NP they
+3.7 NP them
+3.7 N N -s
+3.7 N bonbon
+3.7 N spoon
+3.7 N president
+3.7 N pickle
+3.7 N sandwich
+3.7 N floor
+3.7 N chief of staff
+3.7 N chiefs of staff
+3.7 N man
+3.7 N woman
+4.09 Det a
+4.09 Det all
+4.09 Det every
+4.09 Det each
+4.09 Det two
+3.09 Det some
+3.09 Det the
+3.09 Det his
+3.09 Det her
+3.09 Det its
+3.09 Det their
+2.81 Adj fine
+2.81 Adj blue
+2.81 Adj delicious
+2.81 Adj perplexed
+2.81 Adj pickled
+2.81 Adj very Adj
+2.32 P with
+2.32 P on
+2.32 P onto
+2.32 P under
+2.32 P in
+2.81 Adj Adj and Adj
+3.7 NP NP and NP
+3.81 VP VP and VP
--- /dev/null
+(ROOT (S (NP George) (VP (V (V love) -s) (NP Laura))) .)
+(ROOT (S (NP he) (VP (V (V love) -s) (NP her))) .)
+(ROOT (S (NP him) (VP (V (V love) -s) (NP she))) .)
+(ROOT (S (NP Papa) (VP (VP (V (V sleep) -s)) (PP (P with) (NP (Det a) (N spoon))))) .)
+(ROOT (S (NP Papa) (VP (VP (V (V eat) -ed)) (PP (P with) (NP (Det a) (N spoon))))) .)
+(ROOT (S (NP Papa) (VP (V (V sleep) -s) (NP (Det every) (N (N bonbon) (PP (P with) (NP (Det a) (N spoon))))))) .)
+(ROOT (S (NP Papa) (VP (V (V eat) -ed) (NP (Det every) (N (N bonbon) (PP (P with) (NP (Det a) (N spoon))))))) .)
+(ROOT (VP (V have) (NP (Det a) (N bonbon))) !)
+(ROOT (S (NP (Det a) (N (N bonbon) (PP (P on) (NP (Det the) (N spoon))))) (VP (V (V entice) -s))) .)
+(ROOT (S (NP (Det a) (N (N bonbon) (PP (P on) (NP (Det the) (N spoon))))) (VP (V (V entice) -0))) .)
+(ROOT (S (NP (Det the) (N (N (N bonbon) -s) (PP (P on) (NP (Det the) (N spoon))))) (VP (V (V entice) -0))) .)
+(ROOT (S (NP George) (VP (V (V kiss) -ed) (NP (Det every) (N chief of staff)))) .)
+(ROOT (S (NP Laura) (VP (V (V say) -s) (SBAR that (S (NP George) (VP (VP (Modal might) (VP (V sleep))) (PP (P on) (NP (Det the) (N floor)))))))) !)
+(ROOT (S (NP (Det the) (N (Adj perplexed) (N president))) (VP (V (V eat) -ed) (NP (Det a) (N pickle)))) .)
+(ROOT (S (NP Papa) (VP (V is) (Adj perplexed))) .)
+(ROOT (S (NP Papa) (VP (V is) (N chief of staff))) .)
+(ROOT (S (NP Papa) (VP (V (V want) -ed) (NP (Det a) (N sandwich)))) .)
+(ROOT (S (NP Papa) (VP (V (V want) -ed) (VP (V to (V eat)) (NP (Det a) (N sandwich))))) .)
+(ROOT (S (NP Papa) (VP (V (V want) -ed) (NP George) (VP (V to (V eat)) (NP (Det a) (N pickle))))) .)
+(ROOT (S (NP Papa) (VP (Modal would) (VP (V have) (VP (V (V eat) -ed) (NP (Det his) (N (N sandwich) -s)))))) .)
+(ROOT (S (NP (Det every) (N sandwich)) (VP (V was) (VP (V (V go) -ing) (VP (V to (V have)) (VP (V been) (Adj delicious)))))) .)
+(ROOT (S (NP (NP (Det the) (N (Adj (Adj fine) and (Adj blue)) (N woman))) and (NP (Det every) (N man))) (VP (VP (Modal must) (VP (V have) (VP (VP (V (V eat) -ed) (NP (Det two) (N (N sandwich) -s))) and (VP (V (V sleep) -ed))))) (PP (P on) (NP (Det the) (N floor))))) .)
--- /dev/null
+George love -s Laura .
+he love -s her .
+him love -s she .
+Papa sleep -s with a spoon .
+Papa eat -ed with a spoon .
+Papa sleep -s every bonbon with a spoon .
+Papa eat -ed every bonbon with a spoon .
+have a bonbon !
+a bonbon on the spoon entice -s .
+a bonbon on the spoon entice -0 .
+the bonbon -s on the spoon entice -0 .
+George kiss -ed every chief of staff .
+Laura say -s that George might sleep on the floor !
+the perplexed president eat -ed a pickle .
+Papa is perplexed .
+Papa is chief of staff .
+Papa want -ed a sandwich .
+Papa want -ed to eat a sandwich .
+Papa want -ed George to eat a pickle .
+Papa would have eat -ed his sandwich -s .
+every sandwich was go -ing to have been delicious .
+the fine and blue woman and every man must have eat -ed two sandwich -s and sleep -ed on the floor .
# The example shows off some of the REPL's data loading commands.
./dyna test/repl/load.dyna \
- --load 'rules_tsv = tsv("test/repl/papa.gr")' \
- 'token = matrix("test/repl/sentences.txt", astype=str)' \
- 'tree = sexpr("test/repl/trees.txt")' \
- --post 'dump_chart()'
+ --load 'rules_tsv = tsv("test/repl/english.gr")' \
+ 'token = matrix("test/repl/english.sen", astype=str)' \
+ 'tree = sexpr("test/repl/english.par")' \
+ --post 'dump_chart()' \
+ "$@"
\ No newline at end of file
phrase(S,W,I,I+1) += W is token(S,I), 0.
sentence_length(S) max= token(S,I), I+1.
-goal(S) += phrase(S, "S", 0, sentence_length(S)).
+goal(S) += phrase(S, "ROOT", 0, sentence_length(S)).
+++ /dev/null
-1 S S .
-1 S NP VP
-1 NP Det N
-1 NP NP PP
-1 VP V NP
-1 VP VP PP
-1 PP P NP
-1 NP Papa
-1 N caviar
-1 N spoon
-1 V ate
-1 P with
-1 Det the
-1 Det a
+++ /dev/null
-Papa ate the caviar .
-
-Papa ate the caviar with the spoon .