Display parse trees with ACE generation

I would like to display both the MRS and parse trees when generating sentences with ACE (version 0.9.30).

Eg. 
1. i sleep
   Parse tree:
     (S (NP (N ('I'))) (VP ('sleep')))
   MRS:
     < h1,e2:PROP-OR-QUES:TENSE:ASPECT:MOOD,
     {h3:exist_q(x4:BOOL:COG-ST:1ST:SG, h5, h6),
     h7:_pronoun_n(x4),
     h8:_sleep_v(e2, x4)},
     {h5 qeq h7}>

According to the Ace Options documentation, I should be able to use the --report-labels flag to display the parse tree but this does not seem to work for generation (Example command & output below)

ace -g grammars/eng/eng.dat -e ace_mrs_file --disable-subsumption-test --report-labels
==================
I sleep
NOTE: 7 passive, 16 active edges in final generation chart; built 7 passives total. [1 results]


NOTE: generated 1 / 1 sentences, avg 414k, time 0.02590s
NOTE: transfer did 0 successful unifies and 0 failed ones

This does work for parsing though.

echo "i sleep" | ace -g eng.dat --report-labels
=================
SENT: i sleep
[ LTOP: h0 INDEX: e2 [ e SF: prop-or-ques E.TENSE: tense E.ASPECT: aspect E.MOOD: mood ] RELS: < [ "exist_q_rel"<-1:-1> LBL: h4 ARG0: x3 [ x SPECI: bool COG-ST: cog-st PNG.PER: 1st PNG.NUM: sg ] RSTR: h5 BODY: h6 ]  [ "_pronoun_n_rel"<-1:-1> LBL: h7 ARG0: x3 ]  [ "_sleep_v_rel"<-1:-1> LBL: h1 ARG0: e2 ARG1: x3 ] > HCONS: < h0 qeq h1 h5 qeq h7 > ICONS: < > ] ;  ("S" ("NP" ("N" ("i"))) ("VP" ("VP" ("sleep"))))
NOTE: 1 readings, added 14 / 6 edges to chart (6 fully instantiated, 2 actives used, 3 passives used)	RAM: 94k


NOTE: parsed 1 / 1 sentences, avg 94k, time 0.01269s

Is there no way to report the labels in the parse tree with generation?

Also as an aside I found that --show-realization-mrses gets me the MRS in generation.

There isn’t a way to get the labeled trees for generation results to come out with the ordinary terminal output. There are, however, a couple of ways to get at them. ACE only has a way of reporting those labeled trees through its [incr tsdb()] interface, so you need to either (1) use [incr tsdb()] to drive ACE, (2) use pydelphin to drive ACE, which uses the same API, or (3) tell ACE to output results in the format it uses when talking to [incr tsdb()], and parse those results yourself. Option (3) is easy to get started with:

$ ace -g erg.dat -e --report-labels --tsdb-stdout the-dog-sleeps.mrs
NOTE: tsdb run: (:application . "answer") (:platform . "gcc 4.2") (:grammar . "ERG (trunk)") (:avms . 11110) (:lexicon . 43474) (:lrules . 99) (:rules . 265)
(:results . (((:result-id . 0)(:surface . "The dog slept.")  (:derivation ." (265 sb-hd_mc_c 1.600789 0 3 (262 sp-hd_n_c 1.369233 0 2 (2 the_1 0.000000 0 1 (\"the\" -1 \"token [ +FORM string +FROM string +TO string +ID *diff-list* [ LIST *list* LAST *list* ] +TNT tnt [ +TAGS *list* +PRBS *list* +MAIN tnt_main [ +TAG string +PRB string ] ] +CLASS token_class +TRAIT token_trait [ +UW - +IT italics +LB bracket_list [ LIST *list* LAST *list* ] +RB bracket_list [ LIST *list* LAST *list* ] +LD bracket_list [ LIST *list* LAST *list* ] +RD bracket_list [ LIST *list* LAST *list* ] +HD token_head [ +TI string +LL ctype [ -CTYPE- string ] +TG string ] ] +PRED predsort +CARG string +TICK bool +ONSET c-or-v-onset ]\")) (261 n_sg_ilr 0.777296 1 2 (3 dog_n1 0.000000 1 2 (\"dog\" -1 \"token [ +FORM string +FROM string +TO string +ID *diff-list* [ LIST *list* LAST *list* ] +TNT tnt [ +TAGS *list* +PRBS *list* +MAIN tnt_main [ +TAG string +PRB string ] ] +CLASS token_class +TRAIT token_trait [ +UW - +IT italics +LB bracket_list [ LIST *list* LAST *list* ] +RB bracket_list [ LIST *list* LAST *list* ] +LD bracket_list [ LIST *list* LAST *list* ] +RD bracket_list [ LIST *list* LAST *list* ] +HD token_head [ +TI string +LL ctype [ -CTYPE- string ] +TG string ] ] +PRED predsort +CARG string +TICK bool +ONSET c-or-v-onset ]\")))) (264 w_period_plr 0.231556 2 3 (263 v_pst_olr 0.231556 2 3 (4 sleep_v1 0.000000 2 3 (\"slept.\" -1 \"token [ +FORM string +FROM string +TO string +ID *diff-list* [ LIST *list* LAST *list* ] +TNT tnt [ +TAGS *list* +PRBS *list* +MAIN tnt_main [ +TAG string +PRB string ] ] +CLASS token_class +TRAIT token_trait [ +UW - +IT italics +LB bracket_list [ LIST *list* LAST *list* ] +RB bracket_list [ LIST *list* LAST *list* ] +LD bracket_list [ LIST *list* LAST *list* ] +RD bracket_list [ LIST *list* LAST *list* ] +HD token_head [ +TI string +LL ctype [ -CTYPE- string ] +TG string ] ] +PRED predsort +CARG string +TICK bool +ONSET c-or-v-onset ]\")))))") (:mrs ."[ LTOP: h0 INDEX: e2 [ e SF: prop TENSE: past MOOD: indicative PROG: - PERF: - ] RELS: < [ _the_q<-1:-1> LBL: h4 ARG0: x3 [ x PERS: 3 NUM: sg IND: + ] RSTR: h5 BODY: h6 ]  [ _dog_n_1<-1:-1> LBL: h7 ARG0: x3 ]  [ _sleep_v_1<-1:-1> LBL: h1 ARG0: e2 ARG1: x3 ] > HCONS: < h0 qeq h1 h5 qeq h7 > ICONS: < > ]") (:tree ." (\"S\" (\"NP\" (\"DET\" (\"the\")) (\"N\" (\"N\" (\"dog\")))) (\"VP\" (\"VP\" (\"V\" (\"slept.\")))))")(:score . 1.600789)) )) (:readings . 1) (:pedges . 65) (:aedges . 42) (:tgc . 0) (:copies . 144) (:unifications . 40433)   (:total . 13) (:treal . 13) (:tcpu . 13) (:others . 877184)
NOTE: 65 passive, 191 active edges in final generation chart; built 69 passives total. [1 results]

NOTE: generated 1 / 1 sentences, avg 856k, time 0.01375s
NOTE: transfer did 194 successful unifies and 174 failed ones

The string you get out of that is a kind of lisp s-expression. The data you are looking for is located at :result[0]/:tree

Pydelphin knows how to parse it, and how to invoke ACE in the right way to get it too (option 2). You can also either use pydelphin or [incr tsdb()] to invoke ACE and record these results into a tsdb profile, and read the ‘tree’ field out of there after the fact.

2 Likes