0

I'd like to extract author names from pdf papers. Does anybody know a robust way to do so?

For example, I'd like to extract the name Archana Shukla from this pdf https://arxiv.org/pdf/1111.1648

2
  • 1
    I'm not sure, but I'm guessing that the reason this got down-voted a lot is because you didn't show your own attempt, and generally speaking we encourage people to show some effort to solve the problem before asking on Stack Overflow. If you did make an effort before asking this, it might help to express that in an edit to the question. Commented May 29, 2018 at 15:28
  • 1
    Did any of the answers solve the question for you? Or if not, is there some technical hurdle that remains to be solved which you could elaborate on? Commented May 30, 2018 at 1:00

3 Answers 3

6

PDF documents contain Metadata. It includes information about the document and its contents such as the author’s name, keywords, copyright information. See Adobe doc.

You can use PyPDF2 to extract PDF Metadata. See the documentation about the DocumentInformation class.

This information may not be filled and can appear blank. So, one possibility is to parse the beginning or the end of the text and extract what you think is the author name. Of course, it is not reliable. But, if you have a bibliographic database, to can try a match.

Nowadays, editors like Microsoft Word or Libre Office Writer always fill the author name in the Metadata. And it is copied in the PDF when you export your documents. So, this should work for you. Give it a try and tell us!

1

I am going to pre-suppose that you have a way to extract text from a PDF document, so the question is really "how can I figure out the author from this text". I think one straightforward solution is to use the correspondence email. Here is an example implementation:

import difflib

# Some sample text
pdf_text="""SENTIMENT ANALYSIS OF DOCUMENT BASED ON ANNOTATION\n
Archana Shukla\nDepartment of Computer Science and Engineering, 
Motilal Nehru National Institute of Technology, 
Allahabad\[email protected]\nABSTRACT\nI present a tool which 
tells the quality of document or its usefulness based on annotations."""

def find_author(some_text):
    words = some_text.split(" ")
    emails = []
    for word in words:
        if "@" in word:
            emails.append(word)
    emails_clean = emails[0].split("\n")
    actual_email = [a for a in emails_clean if "@" in a]
    actual_email = actual_email[0]
    maybe_name = actual_email.split("@")[0]
    all_words_lists = [a.split("\n") for a in words]
    words = [a for sublist in all_words_lists for a in sublist]
    words.remove(actual_email)
    return difflib.get_close_matches(maybe_name, words)

In this case, find_author(pdf_text) returns ['Archana']. It's not perfect, but it's not incorrect. I think you could likely extend this in some clever ways, perhaps by getting the next word after the result or by combining this guess with metadata, or even by finding the DOI in the document if/when it exists and looking it up through some API, but nonetheless I think this should be a good starting point.

1
  • For anyone interesting, my word similarity solution with dfflib is from this answer, modified for the context of this question. Commented May 29, 2018 at 5:21
-2

First thing first, there are some pdfs out there which pages are image. I don't know if you can extract the text from image easily. But from the pdf link you mentioned, I think it can be done. There is exist a package called PyPDF2 which as I know, can extract the text from pdf. All that left is to scan the last few pages and parse the Author names.

An example on how to use the package described here. Some of the code listed there is as follows:

import PyPDF2
pdfFileObj = open('meetingminutes.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
disp(pdfReader.numPages)
pageObj = pdfReader.getPage(0)
pageObj.extractText()
1
  • 3
    Hi, and welcome to Stack Overflow! I think people are likely downvoting this because it doesn't answer the specific question of getting the author name. Specifically, "how to extract text from a PDF" is already answered in at least one place on SO. Could you maybe edit your question to also include an example of how you would go about parsing out the author name? Commented May 29, 2018 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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