# Split text from Annual Report pdfs into paragraphs

**URL:** <https://discuss.huggingface.co/t/split-text-from-annual-report-pdfs-into-paragraphs/80885>\
**Category:** Beginners\
**Created:** [April 9, 2024, 12:45pm UTC](https://discuss.huggingface.co/t/split-text-from-annual-report-pdfs-into-paragraphs/80885 "2024-04-09T12:45:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kip-koech](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Kip-koech](https://discuss.huggingface.co/u/Kip-koech)\
**Post date:** [April 9, 2024, 12:45pm UTC](https://discuss.huggingface.co/t/split-text-from-annual-report-pdfs-into-paragraphs/80885/1 "2024-04-09T12:45:49Z")

</div>

Hi,

I’m trying to split text from companies’ Annual Reports into paragraphs for classification with various models. Parsing paragraphs seems a lot more challenging than parsing sentences, mostly due to the diverse organization of reports across companies. I’m currently using the code below but I struggle to filter out non-content elements like titles and legal information.

paragraphs = report[“content”].split(‘\n\n’)

def is\_informative(paragraph):  
paragraph = paragraph.strip()  
if len(paragraph) \< 40 or not any(c.isalpha() for c in paragraph):  
return False  
non\_content\_patterns = [  
r’^\d+', r'continued on next page', r'^Table of Contents', r'^See next page', r'^[\W\_]+’  
]  
if any(re.search(pattern, paragraph, re.IGNORECASE) for pattern in non\_content\_patterns):  
return False  
return True

Any ideas on how to refine the approach? Cheers!

---

<div class="post-metadata">

**Author:** ![Kip-koech](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Kip-koech](https://discuss.huggingface.co/u/Kip-koech)\
**Post date:** [April 10, 2024, 9:45am UTC](https://discuss.huggingface.co/t/split-text-from-annual-report-pdfs-into-paragraphs/80885/2 "2024-04-10T09:45:44Z")

</div>

It would also be great to hear how others use filters to clean sentences extracted from pdfs, in particular in the context of mandatory corporate documents such as Annual Reports. Thanks again!
