depccg
depccg copied to clipboard
Prolog printer
For me the prolog printer is not working while other printers are fine.
When I run the parser programmatically I find that Tree.prolog()
inserts numbers instead of tokens in the f-string.
ccg({0},
rp(s:dcl,
ba(s:dcl,
t(np, 'This', '{32766.lemma}', '{32766.pos}', '{32766.chunk}', '{32766.entity}'),
fa((s:dcl\np),
t(((s:dcl\np)/(s:adj\np)), 'is', '{32767.lemma}', '{32767.pos}', '{32767.chunk}', '{32767.entity}'),
t((s:adj\np), 'second', '{32768.lemma}', '{32768.pos}', '{32768.chunk}', '{32768.entity}'))),
t(period, '.', '{32769.lemma}', '{32769.pos}', '{32769.chunk}', '{32769.entity}'))).
The following shows that other formats work while prolog doesn't.
$ echo "Prolog printer inserts numbers" | python3 -m depccg en "$@" -f deriv --silent
ID=1, log probability=-0.32995718717575073
N/N N (S[dcl]\NP)/NP N
Prolog printer inserts numbers
----------------->
N
-----------------<un>
NP
---------<un>
NP
------------------------->
S[dcl]\NP
------------------------------------------<
S[dcl]
$ echo "Prolog printer inserts numbers" | python3 -m depccg en "$@" -f prolog --silent
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/depccg-1.0.7-py3.6-linux-x86_64.egg/depccg/__main__.py", line 259, in <module>
args.func(args)
File "/usr/local/lib/python3.6/dist-packages/depccg-1.0.7-py3.6-linux-x86_64.egg/depccg/__main__.py", line 125, in main
semantic_templates=semantic_templates)
File "/usr/local/lib/python3.6/dist-packages/depccg-1.0.7-py3.6-linux-x86_64.egg/depccg/printer.py", line 299, in print_
print(to_prolog_en(nbest_trees, tagged_doc), end='', file=file)
File "/usr/local/lib/python3.6/dist-packages/depccg-1.0.7-py3.6-linux-x86_64.egg/depccg/printer.py", line 46, in to_prolog_en
print(t.prolog().format(i, *tokens), file=output)
AttributeError: 'int' object has no attribute 'lemma'