Fix KeyError in Catalan to_ordinal for exact tens#670
Open
santhreal wants to merge 1 commit into
Open
Conversation
to_ordinal built the tens ordinals (30, 40, ..., 90) by appending a
units part looked up in self.ords_3, which only has keys 1-9. For an
exact multiple of ten the units index is 0, so self.ords_3[0] raised
KeyError: 0. This also broke every higher ordinal that recurses through
a whole ten (for example 130 -> "cent trentè").
Emit the tens ordinal as the tens stem plus the gender suffix when there
is no units part, matching how 20 ("vintè") and 100 ("centè") are
already handled. Add the previously missing exact-tens cases to the
ordinal test data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Catalan
to_ordinalbuilds the tens ordinals (30, 40, ..., 90) by appending a units part looked up inself.ords_3, which only has keys 1-9. For an exact multiple of ten the units index is 0, soself.ords_3[0]raisesKeyError: 0. Every higher ordinal that recurses through a whole ten crashes too (for exampleto_ordinal(130)->"cent " + to_ordinal(30)).When there is no units part, emit the tens stem plus the gender suffix ("trentè", "quarantè", ...), matching how 20 ("vintè") and 100 ("centè") are already handled. Unit-tens ordinals like 33 ("trenta-tresè") are unchanged. Added the previously missing exact-tens cases to the ordinal test data.