0
$\begingroup$

Is it possible to extract some information from a pdf file? I am interested in extracting the words before the squared brackets and the following word (in the image, for example, I would like to extract A and s, then a and an, and so on...)?

Many thanks for all your suggestions.

enter image description here

$\endgroup$
  • 2
    $\begingroup$ When you Import["mypdf", "Plaintext"], does this text appear? $\endgroup$ – Carl Lange Oct 2 '19 at 19:55
  • $\begingroup$ yes, the text appears. Unfortunately, my difficulties are mainly on how to extract some specific items from it. $\endgroup$ – still_learning Oct 2 '19 at 22:22
1
$\begingroup$

Given that the formatting of the text seems consistent, it might suffice to partition the text by periods (".") and remove newlines ("\n" and "\r").

text = StringSplit[StringDelete[Import["mypdf.pdf", "Plaintext"], {"\n", "\r"}], "."];

Then, you can simply make a list of all the words you have:

words = Flatten[StringDrop[StringCases[#, ___ ~~ "["], -2] & /@ text]

(The -2 is removing [)

I hope this works!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.