Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDL error: 'String' object does not support item assignment #293

Closed
goodmami opened this issue Jun 5, 2020 · 1 comment
Closed

TDL error: 'String' object does not support item assignment #293

goodmami opened this issue Jun 5, 2020 · 1 comment
Labels
Milestone

Comments

@goodmami
Copy link
Member

goodmami commented Jun 5, 2020

I'm getting an error parsing the pet/qc.tdl file of the ERG, and the error message isn't terribly indicative of the problem:

>>> from delphin import tdl
>>> list(tdl.iterparse('pet/qc.tdl'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  [...]
  File "/home/goodmami/delphin/pydelphin/delphin/tdl.py", line 207, in __setitem__
    super(AVM, self).__setitem__(key, val)
  File "/home/goodmami/delphin/pydelphin/delphin/tfs.py", line 58, in __setitem__
    subdef[subkeys[1]] = val
TypeError: 'String' object does not support item assignment

If there's a problem with the TDL there should be a TDLSyntaxError.

@goodmami
Copy link
Member Author

goodmami commented Jun 5, 2020

The problem can be seen from the first few lines of an AVM in the file:

qc_unif_trad_pack := *top* &
[ ARGS.SYNSEM.LOCAL.CAT.HEAD "0" #| 5.1e+05 |#,
  ARGS.SYNSEM.LOCAL.CAT.VAL.COMPS "1" #| 2.7e+05 |#,
  ARGS.SYNSEM.PUNCT.RPUNCT "2" #| 1.5e+05 |#,
  ARGS.SYNSEM.LOCAL.CAT.HEAD.MOD "3" #| 1.2e+05 |#
[...]

The value of ARGS.SYNSEM.LOCAL.CAT.HEAD is the string "0", but in the fourth feature path it is treated as a sub-AVM in ARGS.SYNSEM.LOCAL.CAT.HEAD.MOD. These wouldn't unify, so I think this file is processed specially by PET.

I think an appropriate fix, then, is to return a more useful error message.

@goodmami goodmami added this to the v1.3.0 milestone Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant