-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(page_element): Parse page numbers and separators (PR#59)
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
from sec_parser.semantic_elements import IrrelevantElement | ||
from sec_parser.semantic_elements.abstract_semantic_element import AbstractSemanticElement | ||
from sec_parser.processing_engine.processing_log import LogItemOrigin, ProcessingLog | ||
|
||
|
||
class PageElement(IrrelevantElement): | ||
""" | ||
The PageElement class represents the page content of a paragraph or other content object. | ||
It relates to an irrelevant element, storing page numbers and context for the document. | ||
""" | ||
|
||
PageNum = 0 | ||
|
||
def is_page(source: AbstractSemanticElement): | ||
try: | ||
if source.text.__contains__('|'): | ||
pageNum = source.text.replace(" ","").split('|')[-1] | ||
else: | ||
pageNum = int(source.text.strip()) | ||
except ValueError: | ||
return False | ||
|
||
if PageElement.PageNum == 0: | ||
PageElement.PageNum = int(pageNum) | ||
|
||
if int(pageNum) == PageElement.PageNum: | ||
PageElement.PageNum = PageElement.PageNum + 1 | ||
return True | ||
|
||
return False |