From 250009537cfdf721eabb3f8fa9749fbeeb31cc9a Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Sat, 21 Nov 2026 04:55:29 -0500 Subject: [PATCH] chore(pdf): remove two orphaned region helpers from pdfminer_processing `_create_text_region()` and `pdfminer_elements_to_text_regions()` have no callers in the library, tests or scripts. They lost their last callers when layout merging moved to the vectorized `TextRegions`/`LayoutElements` structures (#3881, #3900); `pdfminer_elements_to_text_regions` describes itself as "a temporary solution" pending that refactor. Coverage over the full test suite shows neither ever runs. --- .../pdf_image/pdfminer_processing.py | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/unstructured/partition/pdf_image/pdfminer_processing.py b/unstructured/partition/pdf_image/pdfminer_processing.py index 580ad5f243..3d2a884825 100644 --- a/unstructured/partition/pdf_image/pdfminer_processing.py +++ b/unstructured/partition/pdf_image/pdfminer_processing.py @@ -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): @@ -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",