#๐Ÿ”’ Extracting a particular title in an article

30 messages ยท Page 1 of 1 (latest)

sleek chasm
#

Hello guys, I was able to extract a paragraph from a pdf only if the paragraph contains a particular keyword. However, I now want to extract the title of the paragraph but I don't know how to proceed, like what logic can I use... for example consider the picture:

I was able to extract the paragraphs: "Le gardien..."

But how do I extract the title which is in blue

craggy tartanBOT
#

@sleek chasm

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

spice leaf
#

that's a pretty hard problem. are your pdfs in a standardized format, or at least all created by the same tool?

sleek chasm
#

euh

#

they are just simple pdf

sleek chasm
#

yeah I think they are of same format each time

spice leaf
#

simple pdf is sort of an oxymoron

#

text reconstruction is hard in pdfs due to how characters are laid out, in the case that you even have characters

#

and then even further it sounds like you want to extract some sort of hierarchy from the text

sleek chasm
#

yeah true... do you think it is possible to extract the title like in the picture above ?

spice leaf
#

do you only want to do it for that file?

sleek chasm
#

hmm I will have to do it for multiple pdf later on but if I grasp the concept, should be fine I think

#

do you want a copy of the pdf ?

spice leaf
#

are the pdfs all in roughly the same layout

#

just with different text

sleek chasm
#

yeah I think so

spice leaf
#

hmmmm

#

if they're all of the same format then you can probably get away with a simpler solution

#

you may need to try a few and use a heuristic to determine if it's the text you're looking for

#

though it sounds like you've already been able to extract the text of paragraphs

#

if i were to do this from scratch i would probably parse out all the TJ operators and concat them if they're blue

#

but that seems a bit involved

sleek chasm
spice leaf
#

it's one of the graphics operators for drawing text inside of a pdf

#

but you shouldn't need to worry about that. these python libraries should be high level enough to get you what you need in an easier way

sleek chasm
#

ok will have a look then, thanks !

craggy tartanBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.