Merged in feature/topSheetConditional (pull request #281)
Initial top sheet conditional commit * Initial top sheet conditional commit * Merged main into feature/topSheetConditional * preprocessing_funcs.py edited online with Bitbucket * Updated quick review docstring Approved-by: Alex Galarce
This commit is contained in:
@@ -226,10 +226,34 @@ def smart_chunk_ac(
|
||||
|
||||
|
||||
def filter_quick_review(text_dict):
|
||||
"""
|
||||
Cover Sheets (aka Top Sheets or Quick Review pages) are pages stapled to the front of the contract that contain manually written summaries of the contract's contents.
|
||||
They are NOT legally binding documents, and because they are often manually filled out and hand-written, are more prone to have erroneous information than the rest of the contract.
|
||||
For Doczy.AI, we should not pull any information from top sheets, except as a very last resort.
|
||||
|
||||
filter_quick_review() splits the input dictionary into two dictionaries, one containing the contract pages, the other containing the top sheet pages.
|
||||
|
||||
The function checks each page's text for the keywords "QUICK REVIEW", "TOP SHEET", and "COVER SHEET". It categorizes the text into two separate dictionaries: one for texts that do not contain any of these keywords, and another for texts that do.
|
||||
|
||||
Parameters:
|
||||
text_dict (dict): A dictionary where the key is the page number and the value is the text of that page.
|
||||
|
||||
Returns:
|
||||
tuple of two dicts:
|
||||
- The first dictionary contains pages that do not have the specified keywords.
|
||||
- The second dictionary includes pages that contain any of the specified keywords.
|
||||
"""
|
||||
return {
|
||||
page_num: page_text
|
||||
for page_num, page_text in text_dict.items()
|
||||
if "QUICK REVIEW" not in page_text.upper()
|
||||
and "TOP SHEET" not in page_text.upper()
|
||||
and "COVER SHEET" not in page_text.upper()
|
||||
}, {
|
||||
page_num: page_text
|
||||
for page_num, page_text in text_dict.items()
|
||||
if "QUICK REVIEW" in page_text.upper()
|
||||
or "TOP SHEET" in page_text.upper()
|
||||
or "COVER SHEET" in page_text.upper()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user