Skip to content

Commit

Permalink
Add BBoxAnnotation to TabbyPDF reader (#312)
Browse files Browse the repository at this point in the history
* Add BBoxAnnotation to TabbyPDF reader

* Fix import and add test

* Remove unused import
  • Loading branch information
sunveil committed Aug 29, 2023
1 parent 432781b commit d4c3d34
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions tests/api_tests/test_api_format_pdf_tabby_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,30 +270,3 @@ def test_pdf_with_tables(self) -> None:
node = self._get_by_tree_path(tree, "0.4.2")
self.assertEqual("list_item", node["metadata"]["paragraph_type"])
self.assertEqual("3. В соответствии с полученной", node["text"].strip()[:30])

def test_pdf_annotations(self) -> None:
file_name = "Document635.pdf"
result = self._send_request(file_name, data=dict(pdf_with_text_layer="tabby"))
content = result["content"]["structure"]["subparagraphs"]
annotations = content[0]["annotations"]
annotation_names = {annotation["name"] for annotation in annotations}
self.assertIn(BoldAnnotation.name, annotation_names)
self.assertIn(SpacingAnnotation.name, annotation_names)
self.assertIn(BBoxAnnotation.name, annotation_names)

def test_tables_with_merged_cells(self) -> None:
file_name = "big_table_with_merged_cells.pdf"
result = self._send_request(file_name, data=dict(pdf_with_text_layer="tabby"))
table = result["content"]["tables"][0]
cell_properties = table["metadata"]["cell_properties"]

hidden_cells_big_table_with_colspan = [[(1, 0), 10], [(5, 5), 5]]

for (i, j), k in hidden_cells_big_table_with_colspan:
self.assertFalse(cell_properties[i][j]["invisible"])
self.assertEqual(cell_properties[i][j]["rowspan"], 1)
self.assertEqual(cell_properties[i][j]["colspan"], k)

self.assertFalse(cell_properties[3][0]["invisible"])
self.assertEqual(cell_properties[3][0]["rowspan"], 3)
self.assertEqual(cell_properties[3][0]["colspan"], 4)

0 comments on commit d4c3d34

Please sign in to comment.