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 module not properly parsing inflectional rules #153

Closed
goodmami opened this issue Jun 21, 2018 · 0 comments
Closed

tdl module not properly parsing inflectional rules #153

goodmami opened this issue Jun 21, 2018 · 0 comments
Milestone

Comments

@goodmami
Copy link
Member

There are some errors in parsing inflectional rules.

>>> from delphin import tdl
>>> xs = list(tdl.parse(open('../../grammars/erg/inflr.tdl')))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/goodmami/repos/pydelphin/delphin/tdl.py", line 212, in parse
    yield parse_typedef(data)
  File "/home/goodmami/repos/pydelphin/delphin/tdl.py", line 226, in parse_typedef
    affixes = parse_affixes(tokens)  # only for inflectional rules
  File "/home/goodmami/repos/pydelphin/delphin/tdl.py", line 260, in parse_affixes
    affixes.append(tokens.popleft(), tokens.popleft())
TypeError: append() takes exactly one argument (2 given)

This first error is a Python bug. After that, it appears that TdlInflRule is not being used. From parse_typedef():

try:
    identifier = tokens.popleft()
    assignment = tokens.popleft()
    affixes = parse_affixes(tokens)  # only for inflectional rules
    tdldef, corefs = parse_conjunction(tokens)
    # Now make coref paths a string instead of list
    corefs = _make_coreferences(corefs)
    #features = parse_conjunction(tokens)
    assert tokens.popleft() == '.'
    # :+ doesn't need supertypes
    if assignment != ':+' and len(tdldef.supertypes) == 0:
        raise TdlParsingError('Type definition requires supertypes.')
    t = TdlType(identifier, tdldef, coreferences=corefs)
 ...

There should be some branch to instantiate TdlInflRule if affixes is not None.

@goodmami goodmami added this to the v0.8.0 milestone Jun 21, 2018
goodmami added a commit that referenced this issue Sep 21, 2018
This adds a lot of code to tdl.py, although much of the old stuff will
be removed in a future release. The new-style parsing is ~36% slower
at reading the ERG's lexicon, but it is better able to deal with
malformed TDL, and it handles docstrings and comments in all valid
places.

Addresses #153, #167, #168, and #170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant