question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Latin verse scanners recurse infinitely

See original GitHub issue

From prosody.latin.hexameter_scanner.py:

        # if the line doesn't scan "as is", if may scan if the optional i to j transformations
        # are made, so here we set them and try again.
        if self.optional_transform and not verse.valid:
            return self.scan(original_line, optional_transform=True, dactyl_smoothing=True)

If this second scan fails as well (e.g. if a line is too badly malformed for optional_transform to fix it), it recurses infinitely until it crashes with a RecursionError. The same holds true for HendecasyllableScanner and PentameterScanner.

The condition should instead be:

        if self.optional_transform and not optional_transform and not verse.valid:

This will return an invalid verse if the optional transformations didn’t help, rather than spiralling forever. (I’d submit this as a pull request, but I don’t have permission.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
todd-cookcommented, May 9, 2020

Your use case brings up a good point, there are number of lines in hexameter poems that are incomplete, often deliberately so, and so method of meter detection or meter for what is there would be helpful too.

@dstelzer Thanks for the example. I’ll take a look at this. I’ll take another crack at the code; there’s a few things to fix.

1reaction
kylepjohnsoncommented, May 9, 2020

Also @dstelzer please provide text of poetry, for at least one meter type, that causes this recursion to happen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

debugging - python: unexplainable infinite recursion with __repr
Here's a piece of code, which goes into an infinite recursion loop, which consists only of __repr__ function, seemingly calling itself.
Read more >
Scansion - Wikipedia
Scansion or a system of scansion, is the method or practice of determining and (usually) graphically representing the metrical pattern of a line...
Read more >
Recursive generation in language | Oxford
The connection between recursion and infinity has remained a constant in Chomsky's writings ever since. In the introduction to the published version of...
Read more >
recursion - Wiktionary
Borrowed from Latin recursiō (“the act of running back or again, return”), from recurrō (“run back; return”), from re- (“back, again”) + currō...
Read more >
Everything you need to know about Regular Expressions
This set is infinite. ... If you're working with numbers, Latin characters and basic punctuation, you can instead look at the much smaller ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found