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

REPP crashing on unmatched groups in the replacement #301

Closed
goodmami opened this issue Jul 16, 2020 · 0 comments
Closed

REPP crashing on unmatched groups in the replacement #301

goodmami opened this issue Jul 16, 2020 · 0 comments
Labels
Milestone

Comments

@goodmami
Copy link
Member

The REPP code assumes that match.group(index) will return a string, but if the group specified by index was not matched at all, the expression will return None, leading to some kind of type error. For instance:

>>> from delphin import repp
>>> repp.REPP.from_string(r'!(a)(b)*    \1 \2').apply('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/goodmami/delphin/pydelphin/delphin/repp.py", line 573, in apply
    return self.group.apply(s, active=active)
  File "/home/goodmami/delphin/pydelphin/delphin/repp.py", line 123, in apply
    for step in self._trace(s, set(active or []), False):
  File "/home/goodmami/delphin/pydelphin/delphin/repp.py", line 143, in _trace
    for step in self._apply(s, active):
  File "/home/goodmami/delphin/pydelphin/delphin/repp.py", line 335, in _apply
    for step in operation._apply(o, active):
  File "/home/goodmami/delphin/pydelphin/delphin/repp.py", line 243, in _apply
    _copy_part(literal, shift, parts, smap, emap)
  File "/home/goodmami/delphin/pydelphin/delphin/repp.py", line 679, in _copy_part
    smap.extend([shift] * len(s))
TypeError: object of type 'NoneType' has no len()

Also I think that the REPP rules that result in this error are bad patterns and should be fixed (e.g., something like !(a)(b*) \1 \2 for the above).

@goodmami goodmami added the bug label Jul 16, 2020
@goodmami goodmami added this to the v1.4.0 milestone Jul 20, 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