def test_should_not_tag_using_none_tag(self): token_1 = SimpleToken(TOKEN_TEXT_1) structured_document = SimpleStructuredDocument( lines=[SimpleLine([token_1])]) annotate_structured_document_using_predictions(structured_document, [NONE_TAG]) assert structured_document.get_tag(token_1, scope=CRF_TAG_SCOPE) is None
def test_should_raise_error_if_token_props_do_not_match(self): token_1 = SimpleToken(TOKEN_TEXT_1, bounding_box=BOUNDING_BOX) structured_document = SimpleStructuredDocument( SimplePage(lines=[SimpleLine([token_1])], bounding_box=BOUNDING_BOX)) token_props_list = list( structured_document_to_token_props(structured_document)) token_props_list[0]['text'] = TOKEN_TEXT_2 with pytest.raises(AssertionError): annotate_structured_document_using_predictions( structured_document, [TAG_1], token_props_list)
def test_should_tag_single_token_using_prediction_and_check_token_props( self): token_1 = SimpleToken(TOKEN_TEXT_1, bounding_box=BOUNDING_BOX) structured_document = SimpleStructuredDocument( SimplePage(lines=[SimpleLine([token_1])], bounding_box=BOUNDING_BOX)) token_props_list = structured_document_to_token_props( structured_document) annotate_structured_document_using_predictions(structured_document, [TAG_1], token_props_list) assert structured_document.get_tag(token_1, scope=CRF_TAG_SCOPE) == TAG_1
def test_should_not_fail_with_empty_document(self): structured_document = SimpleStructuredDocument() annotate_structured_document_using_predictions(structured_document, [])