Latin verse scanners recurse infinitely
See original GitHub issueFrom 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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Also @dstelzer please provide text of poetry, for at least one meter type, that causes this recursion to happen.