Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions unstructured/partition/pdf_image/pdfminer_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,18 +672,6 @@ def process_data_with_pdfminer(
return layouts, layouts_links


def _create_text_region(x1, y1, x2, y2, coef, text, source, region_class):
"""Creates a text region of the specified class with scaled coordinates."""
return region_class.from_coords(
x1 * coef,
y1 * coef,
x2 * coef,
y2 * coef,
text=text,
source=source,
)


def get_coords_from_bboxes(bboxes, round_to: int = DEFAULT_ROUND) -> np.ndarray:
"""convert a list of boxes's coords into np array"""
if isinstance(bboxes, np.ndarray):
Expand Down Expand Up @@ -755,29 +743,6 @@ def boxes_iou(
return inter_area > (threshold * denom)


@requires_dependencies("unstructured_inference")
def pdfminer_elements_to_text_regions(layout_elements: LayoutElements) -> list[TextRegions]:
"""a temporary solution to convert layout elements to a list of either EmbeddedTextRegion or
ImageTextRegion; this should be made obsolete after we refactor the merging logic in inference
library"""
from unstructured_inference.inference.elements import (
EmbeddedTextRegion,
ImageTextRegion,
)

regions = []
for i, element_class in enumerate(layout_elements.element_class_ids):
region_class = EmbeddedTextRegion if element_class == 0 else ImageTextRegion
regions.append(
region_class.from_coords(
*layout_elements.element_coords[i],
text=layout_elements.texts[i],
source=Source.PDFMINER,
)
)
return regions


@requires_dependencies("unstructured_inference")
def merge_inferred_with_extracted_layout(
inferred_document_layout: "DocumentLayout",
Expand Down