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.
This fixes the issue with #222 and is an improvement. However, it is not a perfect solution for all other possible phrases.
Summary of Changes:
Added Handling for Irregular Plurals:
handle_irregular_plural()
, which checks if a word is an irregular plural and replaces it with its singular form when necessary.pl_sb_irregular.values()
to determine if the word is irregular and maps it back to its singular form.Improved Inflection Handling:
count != 1
but the word already ends in 's'.handle_irregular_plural()
.Refactored Inflection Logic:
inflection(cand, count)
call is now stored in afor
loop to ensure that it is only computed once and can be used in multiple checks.cand
) should be replaced with the inflected version or left unchanged.Removed Docstring Examples:
doctests
), which were present in the original method.Possible Future Improvements
Here is a script that illustrates other scenarios that are related conceptually but that this PR decided to not address at this time, for your future improvements:
TEST SCRIPT