Skip to content

Commit

Permalink
TLDR-490 fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
oksidgy committed Oct 5, 2023
1 parent 178c1cd commit 7800336
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 3 additions & 5 deletions dedoc/scripts/test_words_bbox_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ def test_table_word_extraction(self):
image = self.__draw_word_annotations(image, word_annotations, angle=table_angle)
cv2.imwrite(os.path.join(output_path, file_name.split('/')[-1]), image)

def test_document_pipeline_reader(self) -> None:
def test_document_image_reader(self) -> None:
filename_to_parameters = {
"scanned/scan_orient_1.jpg": {}
"scanned/scan_orient_1.jpg": {},
"skew_corrector/rotated_2.jpg": {}
}
output_path = os.path.join(self.output_path, "document_pipeline_readers")
os.makedirs(output_path, exist_ok=True)
Expand All @@ -188,6 +189,3 @@ def test_document_pipeline_reader(self) -> None:
image = rotate_image(image, result["metadata"]["other_fields"].get("rotated_page_angles", [0.])[0])
image = self.__draw_word_annotations(image, word_annotations)
cv2.imwrite(os.path.join(output_path, filename.split("/")[-1]), image)



13 changes: 13 additions & 0 deletions tests/api_tests/test_api_format_pdf_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ def test_pdf_tables_uuid(self) -> None:
self.assertEqual(len(tables_uids), 2)
self.assertTrue(tables_uids[0] != tables_uids[1])

def test_ref_tables(self) -> None:
file_name = "example.pdf"
result = self._send_request(file_name, dict(pdf_with_text_layer="true"))
tables_uids = [table["metadata"]["uid"] for table in result["content"]["tables"]]
self.assertEqual(len(tables_uids), 2)
node_with_annotation = self._get_by_tree_path(result["content"]["structure"], "0.2.2")
ref0 = self.__filter_by_name(node_with_annotation["annotations"], "table")[0]["value"]
node_with_annotation = self._get_by_tree_path(result["content"]["structure"], "0.2.2.0")
ref1 = self.__filter_by_name(node_with_annotation["annotations"], "table")[0]["value"]

self.assertEqual(ref0, tables_uids[0])
self.assertEqual(ref1, tables_uids[1])

def test_pdf_with_text_style(self) -> None:
file_name = "diff_styles.pdf"
result = self._send_request(file_name, dict(pdf_with_text_layer="true", document_type="", need_pdf_table_analysis="false"))
Expand Down

0 comments on commit 7800336

Please sign in to comment.