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

list index out of range in engine.postprocess #108

Closed
theheuman opened this issue May 3, 2020 · 1 comment · Fixed by #125
Closed

list index out of range in engine.postprocess #108

theheuman opened this issue May 3, 2020 · 1 comment · Fixed by #125

Comments

@theheuman
Copy link

theheuman commented May 3, 2020

Inflect pip installed into virtual environment running python3.7 on ubuntu 18.04

After getting an error I wrote some debug statements into inflect.py starting on line 2215:

    def postprocess(self, orig, inflected):
        inflected = str(inflected)

        print("Inflected: " + inflected)
        if "|" in inflected:
            inflected = inflected.split("|")[self.classical_dict["all"]]
        result = inflected.split(" ")

        print("Orig: " + orig)
        print("Inflected: " + inflected)

        # Try to fix word wise capitalization
        for index, word in enumerate(orig.split(" ")):
            ...

My code:

>>> import inflect
>>> p = inflect.engine()
>>> p.classical(all=True)
>>> p.plural("Genie")
Inflected: genies|genii
Orig: Genie
Inflected: genii
'Genii'

>>> p.plural("Master Genie")
Inflected: Master genies|genii
Orig: Master Genie
Inflected: genii

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/omitted/for/privacy/lib/python3.7/site-packages/inflect.py", line 2260, in plural
    or self._plnoun(word, count),
  File "/omitted/for/privacy/lib/python3.7/site-packages/inflect.py", line 2230, in postprocess
    result[index] = result[index].capitalize()
IndexError: list index out of range

So it looks like something went wrong in this line:
inflected = inflected.split("|")[self.classical_dict["all"]]

Instead of returning "master genii" it returns just "genii"

Ninja Edit: This would be occuring on line 2226 in postprocess without the debug statements

@jaraco
Copy link
Owner

jaraco commented Nov 15, 2020

That does seem like a bug. Would you be willing to dig deeper and propose a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants