55import numpy as np
66import pytest
77
8- from unstructured_inference .constants import Source , TextSource
8+ from unstructured_inference .constants import Source
99from unstructured_inference .inference import elements
1010from unstructured_inference .inference .elements import (
1111 Rectangle ,
@@ -410,8 +410,8 @@ def test_layoutelements_from_list_no_elements():
410410
411411def test_textregions_from_list_no_elements ():
412412 back = TextRegions .from_list (regions = [])
413- assert back .text_sources .size == 0
414- assert back .text_source is None
413+ assert back .is_extracted_array .size == 0
414+ assert back .is_extracted is None
415415 assert back .element_coords .size == 0
416416
417417
@@ -456,8 +456,8 @@ def test_layoutelements_concatenate():
456456 ]
457457 ),
458458 texts = np .array (["0" , "1" , "2" , "3" , "4" ]),
459- text_sources = np .array ([TextSource . OCR ] * 5 ),
460- text_source = TextSource . OCR ,
459+ is_extracted_array = np .array ([True ] * 5 ),
460+ is_extracted = True ,
461461 ),
462462 LayoutElements (
463463 element_coords = np .array (
@@ -472,8 +472,8 @@ def test_layoutelements_concatenate():
472472 texts = np .array (["0" , "1" , "2" , "3" , "4" ]),
473473 sources = np .array ([Source .YOLOX ] * 5 ),
474474 source = Source .YOLOX ,
475- text_sources = np .array ([TextSource . OCR ] * 5 ),
476- text_source = TextSource . OCR ,
475+ is_extracted_array = np .array ([] * 5 ),
476+ is_extracted = True ,
477477 element_probs = np .array ([0.0 , 0.1 , 0.2 , 0.3 , 0.4 ]),
478478 ),
479479 ],
@@ -496,7 +496,7 @@ def test_textregions_from_list_collects_sources():
496496
497497 regions = [
498498 TextRegion .from_coords (
499- 0 , 0 , 10 , 10 , text = "first" , source = Source .YOLOX , text_source = TextSource . OCR
499+ 0 , 0 , 10 , 10 , text = "first" , source = Source .YOLOX , is_extracted = True
500500 ),
501501 TextRegion .from_coords (
502502 10 ,
@@ -505,7 +505,7 @@ def test_textregions_from_list_collects_sources():
505505 20 ,
506506 text = "second" ,
507507 source = Source .DETECTRON2_ONNX ,
508- text_source = TextSource . EXTRACTED ,
508+ is_extracted = True ,
509509 ),
510510 ]
511511
@@ -532,7 +532,7 @@ def test_textregions_iter_elements_preserves_source():
532532
533533 regions = [
534534 TextRegion .from_coords (
535- 0 , 0 , 10 , 10 , text = "first" , source = Source .YOLOX , text_source = TextSource . OCR
535+ 0 , 0 , 10 , 10 , text = "first" , source = Source .YOLOX , is_extracted = True
536536 ),
537537 ]
538538 text_regions = TextRegions .from_list (regions )
@@ -549,7 +549,7 @@ def test_textregions_slice_preserves_sources():
549549
550550 regions = [
551551 TextRegion .from_coords (
552- 0 , 0 , 10 , 10 , text = "first" , source = Source .YOLOX , text_source = TextSource . OCR
552+ 0 , 0 , 10 , 10 , text = "first" , source = Source .YOLOX , is_extracted = True
553553 ),
554554 TextRegion .from_coords (
555555 10 ,
@@ -558,7 +558,7 @@ def test_textregions_slice_preserves_sources():
558558 20 ,
559559 text = "second" ,
560560 source = Source .DETECTRON2_ONNX ,
561- text_source = TextSource . EXTRACTED ,
561+ is_extracted = True ,
562562 ),
563563 ]
564564 text_regions = TextRegions .from_list (regions )
@@ -587,8 +587,8 @@ def test_textregions_from_coords_accepts_source():
587587 """Test that TextRegion.from_coords() accepts source parameter"""
588588 # This should fail because from_coords() doesn't accept source parameter
589589 region = TextRegion .from_coords (
590- 0 , 0 , 10 , 10 , text = "test" , source = Source .YOLOX , text_source = TextSource . OCR
590+ 0 , 0 , 10 , 10 , text = "test" , source = Source .YOLOX , is_extracted = True
591591 )
592592
593593 assert region .source == Source .YOLOX
594- assert region .text_source == TextSource . OCR
594+ assert region .is_extracted
0 commit comments