Skip to content

BUG: sentenceCount function does not count sentences properly #14

@akshitdandyan

Description

@akshitdandyan

Issue

The function sentenceCount uses this regular expression to calculate total sentences: (/ *[.?!]['")\]]*[ |\n](?=[A-Z])/g)

It works well when we have text separated by single \n but when there are multiple new lines in between the text, it does not split them properly.

Possible Fix

I suggest a fix: After getting sentences from regular expression mentioned above, we should split each by \n and consider each splitted string as new sentence if it's word count is greater than 3.

How did I find it?

I was matching text-readability fleschReadingEase score with some other tools like https://www.webfx.com/tools/read-able and https://charactercalculator.com/flesch-reading-ease/
There was a big difference in both scores, so I decided to look into library and found this issue in sentence counting part.

I would love to contribute and fix this, please assign me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions