Files
doczyai-pipelines/fieldExtraction/tests/ac_funcs_test.py
T
Alex Galarce 47a01e13f0 Merged in chore/contract_effective_date (pull request #307)
New Prompt Method (starting with contract effective date)

* add todos for Siddhant

* moved effective date prompts to prompts.py and added docstring and type hints

* moved effective date prompts to prompts.py and added docstring and type hints

* fixed conflict

Co-authored-by: Alex Galarce <agalarce@aarete.com>

* modified contract effective date logic in existing smart chunking

* Merged main into chore/contract_effective_date

* updated extract_text_from_delimiters function and unit tests for it

* Merge remote-tracking branch 'origin/main' into chore/contract_effective_date

* added comments to preprocessing_funcs

* preprocessing_funcs.py edited online with Bitbucket
* utils.py edited online with Bitbucket
* add debug line

* add NA handling into fix_date_formatting()

* add debug print statements

* worked on review comments

* fixed date checking

* fixed date checking and added unit tests

* Merged main into chore/contract_effective_date

* added logic to handle case when smart chunking returns empty context for effective date

* added comments to file_processing.py

* optimized imports and removed a TODO

* Merged main into chore/contract_effective_date

* made prompt changes for effective date

* keywords.py edited online with Bitbucket
* Removed excess print statements


Approved-by: Katon Minhas
2024-12-05 22:46:41 +00:00

52 lines
2.8 KiB
Python

import pytest
from enums.delimiters import Delimiter
from ac_funcs import extract_text_from_delimiters
class TestExtractTextFromDelimiters:
# Test case for valid inputs
def test_pipe_delimiter_match_first_position(self):
raw_text = "Here is the answer |this is a pipe answer| and |more text.|"
result = extract_text_from_delimiters(raw_text,delimiter=Delimiter.PIPE,match_index=0)
assert result == "this is a pipe answer"
def test_pipe_delimiter_match_last_position(self):
raw_text = "Here is the answer |this is a pipe answer| and |more text.|"
result = extract_text_from_delimiters(raw_text,delimiter=Delimiter.PIPE,match_index=-1)
assert result == "more text."
def test_pipe_delimiter_match_any_position(self):
raw_text = "|Here| is the answer |this is a pipe answer| and |more text.|"
result = extract_text_from_delimiters(raw_text,delimiter=Delimiter.PIPE,match_index=1)
assert result == "this is a pipe answer"
def test_backtick_delimiter_match_first_position(self):
raw_text = "Here is the answer `this is a backtick answer` and `more text.`"
result = extract_text_from_delimiters(raw_text, delimiter=Delimiter.BACKTICK, match_index=0)
assert result == "this is a backtick answer"
def test_backtick_delimiter_match_last_position(self):
raw_text = "Here is the answer `this is a backtick answer` and `more text.`"
result = extract_text_from_delimiters(raw_text, delimiter=Delimiter.BACKTICK, match_index=-1)
assert result == "more text."
def test_backtick_delimiter_match_any_position(self):
raw_text = "`Here` is the answer `this` is a `backtick answer` and `more text.`"
result = extract_text_from_delimiters(raw_text, delimiter=Delimiter.BACKTICK, match_index=2)
assert result == "backtick answer"
def test_triple_backtick_delimiter_match_first_position(self):
raw_text = "Here is the answer ```this is a triple backtick answer``` and more text."
result = extract_text_from_delimiters(raw_text, delimiter=Delimiter.TRIPLE_BACKTICK, match_index=0)
assert result == "this is a triple backtick answer"
def test_triple_backtick_delimiter_match_last_position(self):
raw_text = "Here is the answer ```this``` is a ```triple``` backtick ```answer``` and more text."
result = extract_text_from_delimiters(raw_text, delimiter=Delimiter.TRIPLE_BACKTICK, match_index=-1)
assert result == "answer"
def test_triple_backtick_delimiter_match_any_position(self):
raw_text = "```Here``` is the answer ```this is a triple backtick answer``` and ```more text.```"
result = extract_text_from_delimiters(raw_text, delimiter=Delimiter.TRIPLE_BACKTICK, match_index=1)
assert result == "this is a triple backtick answer"