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

the ordering for apply longest first includes the indices #299

Closed
joanise opened this issue Nov 9, 2023 · 0 comments · Fixed by #300
Closed

the ordering for apply longest first includes the indices #299

joanise opened this issue Nov 9, 2023 · 0 comments · Fixed by #300

Comments

@joanise
Copy link
Collaborator

joanise commented Nov 9, 2023

To reproduce, add this test case to test_mappings.py:

    def test_rule_ordering_with_indices(self):
        """a{1}b{3} should be shorter than abc"""
        rules = [{"in": "a{1}b{2}", "out": "x{1}x{2}"}, {"in": "abc", "out": "y"}]
        mapping = Mapping(rules=rules, rule_ordering="apply-longest-first")
        transducer = Transducer(mapping)
        self.assertEqual(transducer("abc").output_string, "y")

it will fail, saying:

FAIL: test_rule_ordering_with_indices (__main__.MappingTest)
a{1}b{3} should be shorter than abc
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./test_mappings.py", line 186, in test_rule_ordering_with_indices
    self.assertEqual(transducer("abc").output_string, "y")
AssertionError: 'xxc' != 'y'
- xxc
+ y
roedoejet added a commit that referenced this issue Nov 9, 2023
roedoejet added a commit that referenced this issue Nov 9, 2023
roedoejet added a commit that referenced this issue Nov 9, 2023
fixes: #299

Co-authored-by: Eric Joanis <eric.joanis@nrc-cnrc.gc.ca>
joanise added a commit that referenced this issue Nov 10, 2023
fixes: #299

Co-authored-by: Eric Joanis <eric.joanis@nrc-cnrc.gc.ca>
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

Successfully merging a pull request may close this issue.

1 participant