Fix paragraphs and full width spaces#17
Open
Zarxrax wants to merge 3 commits into
Open
Conversation
Owner
|
Thanks for this PR! I’ll look into it this weekend (really busy this week) |
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Owner
|
Hey apologies I haven't quite had time to look at this yet. I'll take a look and hopefully get this merged as soon as I have time! |
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.
This PR makes 2 changes which both bring the scores more in line with the official web implementation at https://jreadability.net/sys/en for certain types of content.
First, this better handles paragraphs/line breaks by splitting sentences whenever there are 2 or more line breaks. (for example, an html
<p>tag will end a sentence, but a single<br>tag will not. )In some types of text, its common to omit punctuation at the end of a sentence, which would cause sentences to appear much longer than they actually were, which in turn made the difficulty score much higher than it should be.
The second change is that full width spaces are stripped. (this has to be done both in the main doc, and within the split_japanese_sentences function)
This change makes the token count more closely match the token count on jreadability.net, and brings the score slightly closer to that score as well.
Here are the before and after results on the texts in test_jreadability.py
The line splitting does not effect any of these, though the full width space removal changes the first one.
upper_advanced_text - Original: 1.0664359061543713
upper_advanced_text - New: 1.0129233407648766
lower_advanced_text - Original: 2.3329023569023573
lower_advanced_text - New: 2.3329023569023573
upper_intermediate_text - Original: 3.0853157894736842
upper_intermediate_text - New: 3.0853157894736842
lower_intermediate_text - Original: 4.161580021715526
lower_intermediate_text - New: 4.161580021715526
upper_elementary_text - Original: 4.861306967984935
upper_elementary_text - New: 4.861306967984935
lower_elementary_text - Original: 5.613666666666667
lower_elementary_text - New: 5.613666666666667
Closes #16