Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative ref_dif in Blocks.py causing paragraph splitting #282

Open
tehwenyi opened this issue Apr 24, 2024 · 0 comments · May be fixed by #288
Open

Negative ref_dif in Blocks.py causing paragraph splitting #282

tehwenyi opened this issue Apr 24, 2024 · 0 comments · May be fixed by #288

Comments

@tehwenyi
Copy link

I've encountered an issue with paragraph splitting in some documents, where certain pages separate sentences in the same paragraph into different text blocks while others do not. Upon investigation, I found that the problem originates from the _join_lines_vertically function (line 423) in Blocks.py, particularly with the ref_dif value generated by the common_vertical_spacing function (line 444).

The issue arises when ref_dif becomes negative (e.g., -15.3, -8.2) on certain pages, causing the start_new_block flag to be True when it should be False, thus incorrectly initiating a new block at every sentence. I'd like to check if this behavior is intended?

To address this issue, I made a modification on line 452 in common_vertical_spacing of Blocks.py to ensure that ref_dif always remains positive:

return max(max(distances, key=distances.count), 0.0) if distances else 0.0

If this behavious is indeed unexpected and the proposed fix resolves the issue for you, I'd be happy to make a pull request.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant