
    :Qg                        d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	 e j                  j                  de	j                  e	j                  e	j                  e	j                  g      d        Zd Zd	 Ze j                  j                  d
g d      d        Ze j                  j                  dg d      d        Ze j                  j                  dddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fddddge	j                  fdddg e	j                  fg      d        Zd Zy)    N)example_doc_path)Text)pdf
strategies)PartitionStrategystrategyc                 0    t        j                  |        y )Nr   )r   validate_strategyr
   s    h/var/www/html/answerous/venv/lib/python3.12/site-packages/test_unstructured/partition/test_strategies.pytest_validate_strategyr   	   s       (3    c                      t        j                  t              5  t        j                  t
        j                  d       d d d        y # 1 sw Y   y xY wNT)r   is_image)pytestraises
ValueErrorr   r   r   FAST r   r   /test_validate_strategy_raises_for_fast_strategyr      s>    	z	" U$$.?.D.DtTU U Us   &A		Ac                      t        j                  t              5  t        j                  d       d d d        y # 1 sw Y   y xY w)Ntotally_guess_the_text)r   r   r   r   r   r   r   r   .test_validate_strategy_raises_for_bad_strategyr      s2    	z	" ?$$%=>? ? ?s	   9A)filename	from_fileexpected))layout-parser-paper-fast.pdfTT)copy-protected.pdfTT)loremipsum-flat.pdfTF)r   FT)r   FT)r    FFc                     t        d|        } |r,t        | d      5 }t        j                  |      }d d d        nt        j                  |       }t	        d D              }||u sJ y # 1 sw Y   "xY w)Nzpdf/rb)file)r   c              3      K   | ]7  }|D ]0  }t        |t              xr |j                  j                          2 9 y w)N)
isinstancer   textstrip).0page_elementsels      r   	<genexpr>z/test_is_pdf_text_extractable.<locals>.<genexpr>5   sF        	2t000s   =?)r   openr   extractable_elementsany)r   r   r   fextracted_elementspdf_text_extractables         r   test_is_pdf_text_extractabler2   !   s      $xj 12H(D! 	BQ!$!9!9q!A	B 	B !55xH /   8+++	B 	Bs   A,,A5)r1   infer_table_structure))TT)FT)TF)FFc                 z    t        j                  t        j                  | |      }|t        j                  k(  sJ y )N)r   r1   r3   )r   determine_pdf_or_image_strategyr   r   )r1   r3   r   s      r   )test_determine_pdf_or_image_fast_strategyr6   >   s:     99"''13H
 (-----r   )r1   r3   extract_images_in_pdfextract_image_block_typesr   TImageFc                 d    t        j                  t        j                  d| |||      }||k(  sJ y )NF)r   r   r1   r3   r7   r8   )r   r5   r   AUTO)r1   r3   r7   r8   r   r   s         r    test_determine_pdf_auto_strategyr<   P   s=    D 99"''133";H xr   c                  x    t        j                  t        j                  d      } | t        j                  k(  sJ y r   )r   r5   r   r;   HI_RESr
   s    r   "test_determine_image_auto_strategyr?   }   s5    99"''H (/////r   )r   test_unstructured.unit_utilsr   unstructured.documents.elementsr   unstructured.partitionr   r   &unstructured.partition.utils.constantsr   markparametrizer;   r   OCR_ONLYr>   r   r   r   r2   r6   r<   r?   r   r   r   <module>rG      sX    9 0 2 D ""  	44
U
?
 )
,
,$ 5..  
tTG9&7&>&>?	tT20778	tUWI'8'?'?@	tUB 1 8 89	udWI'8'?'?@	udB 1 8 89	uegY(9(@(@A	ueR!2!7!78	dWI'8'?'?@	dB 1 8 89	egY(9(@(@A	eR!2!9!9:	tgY(9(@(@A	tR!2!9!9:	uwi):)A)AB	ub"3"<"<=!6 76 $0r   