[developers] pyDelphin and JACY

Tuấn Anh Lê tuananh.ke at gmail.com
Wed Dec 20 02:31:40 CET 2017


Hi everyone,

I found this bug while using pyDelphin to process MRS output from JACY. Can
someone shed some light on this for me?

The original sentence was "猫を見ていた。"

Source code
---------------------------------------
import io
from delphin.mrs import simplemrs
from delphin.mrs import dmrx

m = '''[ TOP: h0
  INDEX: e2 [ e TENSE: past MOOD: indicative PROG: - PERF: - ASPECT:
default_aspect PASS: - SF: prop ]
  RELS: < [ udef_q_rel<0:1> LBL: h4 ARG0: x5 [ x PERS: 3 ] RSTR: h6 BODY:
h7 ]
          [ "_neko_n_rel"<0:1> LBL: h8 ARG0: x5 ]
          [ "_miru_v_1_rel"<4:5> LBL: h9 ARG0: e10 [ e TENSE: tense MOOD:
indicative PROG: - PERF: - ASPECT: default_aspect PASS: - SF: prop ] ARG1:
i11 ARG2: x5 ]
          [ "_te_adjunct_rel"<-1:-1> LBL: h1 ARG0: e12 [ e TENSE: tense
MOOD: indicative PROG: - PERF: - ASPECT: default_aspect PASS: - SF: prop ]
L-HNDL: h13 R-HNDL: h14 ]
          [ "_iru_v_be_rel"<8:9> LBL: h15 ARG0: e2 ARG1: i3 ] >
  HCONS: < h0 qeq h1 h6 qeq h8 h13 qeq h9 h14 qeq h15 > ]'''

# MRS string to pyDelphin
obj = simplemrs.loads_one(m)
print(obj)

# pyDelphin to XML
x = dmrx.etree_tostring(dmrx._encode_dmrs(obj)).decode('utf-8')
print(x)

# XML back to pyDelphin
dmrses = list(dmrx.deserialize(io.StringIO(x)))
print(dmrses)


Error messages
---------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tuananh/tmp/jacy.py", line 23, in <module>
    dmrses = list(dmrx.deserialize(io.StringIO(x)))
  File "/home/tuananh/ep3/lib/python3.6/site-packages/delphin/mrs/dmrx.py",
line 74, in deserialize
    yield _deserialize_dmrs(elem)
  File "/home/tuananh/ep3/lib/python3.6/site-packages/delphin/mrs/dmrx.py",
line 85, in _deserialize_dmrs
    return Dmrs(nodes=list(map(_decode_node, elem.iter('node'))),
  File "/home/tuananh/ep3/lib/python3.6/site-packages/delphin/mrs/dmrx.py",
line 101, in _decode_node
    return Node(pred=_decode_pred(elem.find('*[1]')),
  File "/home/tuananh/ep3/lib/python3.6/site-packages/delphin/mrs/dmrx.py",
line 122, in _decode_pred
    elem.get('sense'))
  File
"/home/tuananh/ep3/lib/python3.6/site-packages/delphin/mrs/components.py",
line 453, in realpred
    predstr = '_'.join([''] + string_tokens + ['rel'])
TypeError: sequence item 2: expected str instance, NoneType found

Yours,
-- 
Tuan Anh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.delph-in.net/archives/developers/attachments/20171220/735aec1b/attachment.html>


More information about the developers mailing list