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

FEATURE: Extract Paragraphs #524

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

FEATURE: Extract Paragraphs #524

wants to merge 19 commits into from

Conversation

judy
Copy link

@judy judy commented Oct 25, 2023

We're using PDF::Reader at Zipline for parsing content out of PDFs. (I also forked this project on our team repo here.) We have a number of cases where we want to pull out all of the text from multi-column PDF layouts, but PDF::Reader's visually-aligned output via page.text was still difficult for us to programmatically parse.

I saw that borb has a paragraph extraction feature (code here), and this is my attempt to implement something similar in Ruby.

I'm leaving this in Draft until I can finish the remaining todo items below. Any feedback is appreciated.

To-do:

  • Implement type checking via Sorbet
  • Add tests for DisjointSet

@judy judy marked this pull request as ready for review November 13, 2023 22:06
@judy
Copy link
Author

judy commented Nov 14, 2023

I deleted an earlier comment about misunderstanding a Sorbet error. All good for review now!

Copy link
Owner

@yob yob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the well written submission ❤️

I've been flat out, but I'll try and take a look soon.

It's definitely the case that Page#text isn't very versatile, returning all the text in plain text with no markup.

There is Page#runs which returns a lower level view of the text of a page, including positioning data. I've flip flopped over time on how much I want to add to PDF::Reader directly, and how much I want to encourage folks to build their own code on top of Page#runs. I'll take this for a spin and see how it feels though, cheers!

@Cosmo
Copy link

Cosmo commented Feb 10, 2024

@yob I hope you're well!
Any updates on this PR?

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 this pull request may close these issues.

3 participants