d345dd0ed3
Feature/integrate standard and complex * last edits to merge_tables_draft_v2 before moving to table_funcs * migrate to table_utils.py * fix typehint that caused mypy error * fix mypy errors * black and isort * fix error with multi-table pages * update poetry.lock * add tests, fix bug when table start marker or table end marker is missing * added more tests * tests for get_str_dictionaries_from_text() * fix edge case in get_str_dictionaries_from_text * fix mypy error * more tests * add tests, add handling for invalid dictionaries * add tests * add tests for insert_column_headers() * update requirements * add new simple/complex logic to preprocess.py * remove files used solely for testing * split pages into sub-pages by tables * add table split on end marker. Also add tests * add docstrings, change control flow * remove unused tests, add TODO for new tests * get in prompt changes and intermediate decisions * TODO for future enhancement for get_exhibit_pages Approved-by: Katon Minhas
64 lines
2.7 KiB
Python
64 lines
2.7 KiB
Python
|
|
|
|
def EXHIBIT_CHECK(page_start):
|
|
return f"""
|
|
Analyze the following contract excerpt and determine if it indicates the start of a section. Follow the following instructions:
|
|
1. Look specifically for the words 'Exhibit', 'Article', 'Amendment', 'Schedule', 'Attachment', or 'Addendum'. These words indicate the start of a new section.
|
|
2. If the above words are found in the context of a longer sentence or statement, this does not by itself indicate the start of a section. Section starts will be formatted like a title or header.
|
|
3. The phrase 'Additional Provisions' does not indicate the start of a section.
|
|
4. Return Y if the excerpt indicates the start of a section, N if not. Please justify your answer, but enclose your final answer in |pipes|
|
|
|
|
Here is the text to analyze:
|
|
|
|
## START CONTRACT TEXT ##
|
|
{page_start}
|
|
## END CONTRACT TEXT ##
|
|
|
|
State your answer according to the instructions above.
|
|
"""
|
|
|
|
|
|
def FIX_JSON(d):
|
|
return f"""dict: {d}
|
|
|
|
The above dictionary was not parsable by the json.loads() function.
|
|
This may be due to the keys having commas, single- or double-quotes, or other json characters.
|
|
Modify the values and formatting of the string to make it json parsable. Remove punctuation from the values if needed.
|
|
|
|
Return only the json object, with no other commentary.
|
|
"""
|
|
|
|
|
|
|
|
def ALIGN_AND_FORMAT_TABLES(page):
|
|
return f"""{page}
|
|
|
|
----- End Page -----
|
|
|
|
Above is a page with one or more misplaced tables in json format.
|
|
|
|
Return the exact same page with the tables properly aligned and formatted, without changing anything else about the page. Here are instructions and examples to help:
|
|
|
|
Alignment Instructions:
|
|
Align the tables in the text using the Table Header text found after -------Table Start--------. If there is no header, align based on context clues in the text such as "the table below", etc.
|
|
If there are multiple tables on the page, the first table should be placed in the first valid spot, the second in the second, etc.
|
|
If the Table Header is None, place the updated table at the top of the page.
|
|
Do not replicate the table header text twice. Do not remove the -------Table Start-------- or -------Table End-------- lines.
|
|
|
|
Formatting Instructions:
|
|
Reformat the table from json format to a human-readable fixed-width format. Use the following tempate format:
|
|
|
|
Original JSON: "-------Table Start-------- Table Header {{'Column 1' : ['Value 1', 'Value 2', 'Value 3'], 'Column 2' : ['Value 4', 'Value 5', 'Value 6']}}-------Table End--------"
|
|
|
|
Output Format:
|
|
-------Table Start--------
|
|
Table Header
|
|
Column 1 : Value 1 | Column 2 : Value 4
|
|
Column 1 : Value 2 | Column 2 : Value 5
|
|
Column 1 : Value 3 | Column 2 : Value 6
|
|
-------Table End--------
|
|
|
|
Ensure that all text other than the tables is exactly the same
|
|
|
|
Write only the page text, with no additional commentary.
|
|
""" |