Hi,
I’m trying to visualize DMRS with py-delphin.
First, I had DMRS(simple) files that I managed to generate a pdf using delphin.codecs.dmrstikz and pdflatex. Now, I’m working with DMRSjson files and try to visualize them.
I tried:
with open(sys.argv[1]) as json_file:
json_data = delphin.codecs.dmrsjson.load(json_file)
tex = [delphin.codecs.dmrstikz.dumps(json_data)]
byte_tex = tex[0].encode('utf-8')
pdfl = pdflatex.PDFLaTeX.from_binarystring(byte_tex, "output_pdf")
pdf, log, cp = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=False)
But it doesn’t work. Error:
$ python3 grew_to_pdf.py input.json
Traceback (most recent call last):
File “grew_to_pdf.py”, line 24, in
json_data = delphin.codecs.dmrsjson.load(json_f)
File “/…/dmrsjson.py”, line 43, in load
return [from_dict(d) for d in data]
File “/…/dmrsjson.py”, line 43, in
return [from_dict(d) for d in data]
File “/…/dmrsjson.py”, line 188, in from_dict
for node in d.get(‘nodes’, ):
AttributeError: ‘str’ object has no attribute ‘get’
The error appears during the line: delphin.codecs.dmrsjson.load(json_file)
It’s strange because the same code portion works well with DMRX input:
with open(sys.argv[1]) as xml_file:
xml_data = delphin.codecs.dmrx.load(xml_file)
tex = [delphin.codecs.dmrstikz.dumps(xml_data)]
byte_tex = tex[0].encode('utf-8')
pdfl = pdflatex.PDFLaTeX.from_binarystring(byte_tex, "output_pdf")
pdf, log, cp = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=False)
and create the pdf file.
So I’m thinking the problem might be caused by json input file but it was generated with py-delphin. I tried creating another file that contains example of dmrsjson that we can find on py-delphin docs [delphin.codecs.dmrsjson — PyDelphin 1.9.1 documentation] and I got the same issues.
I share the input json file I’m using: WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free
Do you have any idea where the problem could come from?
I have a second question. Is it possible to print the sentence represented by the DMRSjson file? Is there a command to do this with py-delphin?
Thanks