0

could you please tell me what is wrong with below function. I would like to parse only first two pages of the pdf. When I call the function with argument page_numbers=[0,1] it extracts text from all pages anyway.

The function is very slow and I would like to limit number of pages parsed.

def spacy_extractor(label, pattern_name, list_name, pdf_path, pdf_name,
                    filtered_list,page_numbers):

    patterns = [{'label': label, 'pattern': pattern_name} for pattern_name in list_name]
    ruler.add_patterns(patterns)
    doc = pdf_reader(os.path.join(pdf_path, pdf_name), nlp, PdfminerParser, page_numbers)
    filtered_list = [ent.text for ent in doc.ents if ent.label_ == label]

    return filtered_list[0] if filtered_list else None

cover_page_legal_form = spacy_extractor(label='LEG', pattern_name= 'legal_form', list_name=legal_form_list,
                                         pdf_path=fs_path_pdf, pdf_name=fs_name_pdf, filtered_list='legal_forms_filtered',page_numbers=[0,1])

Thank you,

1 Answer 1

0

follow the links give document you can access the particular doc/page using

doc._.page_range method .

https://spacy.io/universe/project/spacypdfreader

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.