Skip to content
Closed
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
9 changes: 5 additions & 4 deletions unstructured/partition/pdf_image/pdfminer_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,16 +811,17 @@ def aggregate_embedded_text_by_block(
.astype(bool)
)

text = " ".join([text for text in source_regions.slice(mask).texts if text])
sliced_source = source_regions.slice(mask)
text = " ".join([text for text in sliced_source.texts if text])

if sum(mask):
source_bboxes = source_regions.slice(mask).element_coords
if mask.sum():
source_bboxes = sliced_source.element_coords
target_bboxes = target_region.element_coords

iou = _aggregated_iou(source_bboxes, target_bboxes[0, :])

fully_filled = (
all(flag == IsExtracted.TRUE for flag in source_regions.slice(mask).is_extracted_array)
all(flag == IsExtracted.TRUE for flag in sliced_source.is_extracted_array)
and iou > text_coverage_threshold
)
is_extracted = IsExtracted.TRUE if fully_filled else IsExtracted.PARTIAL
Expand Down