a
    ¡˜ëjm  ã                   @  s´  U d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZ d dlZd dlmZmZ d dlm Z  erâd dl!m"Z"m#Z# ee$e$e$e$f Z%d	e&d
< ee$e$f Z'd	e&d< ee'df Z(d	e&d< dZ)edƒZ*edƒZ+dddddœdd„Z,dddœdd„Z-G dd„ dee* ƒZ.ddd d!œd"d#„Z/ddd$œd%d&„Z0did'd(d)d*œd+d,„Z1dd-œd.d/„Z2d0d1d2œd3d4„Z3d0dd2œd5d6„Z4d7d8d2œd9d:„Z5d;d<„ Z6d=d>d?d@œdAdB„Z7ddd>dCdDœdEdF„Z8dddGdHœdIdJ„Z9djd
d
dLddMœdNdO„Z:dkddddQdRœdSdT„Z;dldVdWdWdWdLdXœdYdZ„Z<dd[œd\d]„Z=dmdVdWdWd>dLd_œd`da„Z>dndbd>dLdcddœdedf„Z?G dgdh„ dhƒZ@dS )oé    )ÚannotationsN)Úwraps)Úcombinations)ÚTYPE_CHECKINGÚAnyÚCallableÚGenericÚIterableÚIteratorÚListÚOptionalÚTupleÚTypeVarÚcast)Ú	ParamSpecÚ	TypeAlias)Ú__version__)ÚElementÚTextr   ÚBoxÚPoint.ÚPoints)z%Y-%m-%dz%Y-%m-%dT%H:%M:%Sz%Y-%m-%d+%H:%M:%Sz%Y-%m-%dT%H:%M:%S%zÚ_TÚ_PzCallable[_P, List[Element]]ú_P.argsú	_P.kwargszdict[str, Any])ÚfuncÚargsÚkwargsÚreturnc                 O  s^   t  | ¡}tf i tt|j|ƒƒ¤|¤Ž}|j ¡ D ]&}|j|vr2|j|jur2|j||j< q2|S )zMMap both explicit and default arguments of decorated func call by param name.)	ÚinspectÚ	signatureÚdictÚzipÚ
parametersÚvaluesÚnameÚdefaultÚempty)r   r   r   ÚsigZ	call_argsÚarg© r+   úQ/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/unstructured/utils.pyÚget_call_args_applying_defaults0   s    
r-   ÚstrÚbool)Ú	file_pathr   c                 C  s   |   t ¡ ¡S )zåTrue when file_path is in the Python-defined tempdir.

    The Python-defined temp directory is platform dependent (macOS != Linux != Windows)
    and can also be determined by an environment variable (TMPDIR, TEMP, or TMP).
    )Ú
startswithÚtempfileÚ
gettempdir©r0   r+   r+   r,   Úis_temp_file_path>   s    r5   c                   @  sF   e Zd ZdZdddœdd„Zdddd	d
œdd„Zddddœdd„ZdS )Úlazypropertya$  Decorator like @property, but evaluated only on first access.

    Like @property, this can only be used to decorate methods having only a `self` parameter, and
    is accessed like an attribute on an instance, i.e. trailing parentheses are not used. Unlike
    @property, the decorated method is only evaluated on first access; the resulting value is
    cached and that same value returned on second and later access without re-evaluation of the
    method.

    Like @property, this class produces a *data descriptor* object, which is stored in the __dict__
    of the *class* under the name of the decorated method ('fget' nominally). The cached value is
    stored in the __dict__ of the *instance* under that same name.

    Because it is a data descriptor (as opposed to a *non-data descriptor*), its `__get__()` method
    is executed on each access of the decorated attribute; the __dict__ item of the same name is
    "shadowed" by the descriptor.

    While this may represent a performance improvement over a property, its greater benefit may be
    its other characteristics. One common use is to construct collaborator objects, removing that
    "real work" from the constructor, while still only executing once. It also de-couples client
    code from any sequencing considerations; if it's accessed from more than one location, it's
    assured it will be ready whenever needed.

    Loosely based on: https://stackoverflow.com/a/6849299/1902513.

    A lazyproperty is read-only. There is no counterpart to the optional "setter" (or deleter)
    behavior of an @property. This is critically important to maintaining its immutability and
    idempotence guarantees. Attempting to assign to a lazyproperty raises AttributeError
    unconditionally.

    The parameter names in the methods below correspond to this usage example::

        class Obj(object)

            @lazyproperty
            def fget(self):
                return 'some result'

        obj = Obj()

    Not suitable for wrapping a function (as opposed to a method) because it is not callable.
    zCallable[..., _T]ÚNone)Úfgetr   c                 C  s   || _ |j| _t | |¡ dS )aY  *fget* is the decorated method (a "getter" function).

        A lazyproperty is read-only, so there is only an *fget* function (a regular
        @property can also have an fset and fdel function). This name was chosen for
        consistency with Python's `property` class which uses this name for the
        corresponding parameter.
        N)Ú_fgetÚ__name__Ú_nameÚ	functoolsÚupdate_wrapper)Úselfr8   r+   r+   r,   Ú__init__r   s    	zlazyproperty.__init__Nr   r   )ÚobjÚtyper   c                 C  sB   |du r| S |j  | j¡}|du r8|  |¡}||j | j< tt|ƒS )a  Called on each access of 'fget' attribute on class or instance.

        *self* is this instance of a lazyproperty descriptor "wrapping" the property
        method it decorates (`fget`, nominally).

        *obj* is the "host" object instance when the attribute is accessed from an
        object instance, e.g. `obj = Obj(); obj.fget`. *obj* is None when accessed on
        the class, e.g. `Obj.fget`.

        *type* is the class hosting the decorated getter method (`fget`) on both class
        and instance attribute access.
        N)Ú__dict__Úgetr;   r9   r   r   )r>   r@   rA   Úvaluer+   r+   r,   Ú__get__�   s    
zlazyproperty.__get__)r@   rD   r   c                 C  s   t dƒ‚dS )aé  Raises unconditionally, to preserve read-only behavior.

        This decorator is intended to implement immutable (and idempotent) object
        attributes. For that reason, assignment to this property must be explicitly
        prevented.

        If this __set__ method was not present, this descriptor would become a
        *non-data descriptor*. That would be nice because the cached value would be
        accessed directly once set (__dict__ attrs have precedence over non-data
        descriptors on instance attribute lookup). The problem is, there would be
        nothing to stop assignment to the cached value, which would overwrite the result
        of `fget()` and break both the immutability and idempotence guarantees of this
        decorator.

        The performance with this __set__() method in place was roughly 0.4 usec per
        access when measured on a 2.8GHz development machine; so quite snappy and
        probably not a rich target for optimization efforts.
        zcan't set attributeN)ÚAttributeError)r>   r@   rD   r+   r+   r,   Ú__set__ž   s    zlazyproperty.__set__)N)r:   Ú
__module__Ú__qualname__Ú__doc__r?   rE   rG   r+   r+   r+   r,   r6   G   s   *r6   zlist[dict[str, Any]]r7   )ÚdataÚfilenamer   c                 C  sB   t |dƒ�$}| dd„ | D ƒ¡ W d   ƒ n1 s40    Y  d S )Nzw+c                 s  s   | ]}t  |¡d  V  qdS )Ú
N)ÚjsonÚdumps)Ú.0Zdatumr+   r+   r,   Ú	<genexpr>¶   ó    z save_as_jsonl.<locals>.<genexpr>)ÚopenÚ
writelines)rK   rL   Zoutput_filer+   r+   r,   Úsave_as_jsonl´   s    rU   )rL   r   c                 C  s:   t | ƒ�}dd„ |D ƒW  d   ƒ S 1 s,0    Y  d S )Nc                 S  s   g | ]}t  |¡‘qS r+   )rN   Úloads)rP   Úliner+   r+   r,   Ú
<listcomp>»   rR   z#read_from_jsonl.<locals>.<listcomp>)rS   )rL   Z
input_filer+   r+   r,   Úread_from_jsonl¹   s    
rY   zstr | list[str]zOptional[str]z.Callable[[Callable[_P, _T]], Callable[_P, _T]])ÚdependenciesÚextrasr   c                   s*   t ˆ tƒrˆ g‰ dddœ‡ ‡fdd„}|S )NzCallable[_P, _T])r   r   c                   s\   ‡‡fdd„‰t ˆ ƒdddœ‡ ‡fdd„ƒ}t ˆ ƒdddœ‡ ‡fdd	„ƒ}t ˆ ¡rX|S |S )
Nc                    sh   g } ˆ D ]}t |ƒs|  |¡ qt| ƒdkrdtdd | ¡› d�ˆrNdˆ› d�ndd | ¡› d	� ƒ‚d S )
Nr   z$Following dependencies are missing: z, ú. z5Please install them using `pip install "unstructured[z]"`.z'Please install them using `pip install ú z`.)Údependency_existsÚappendÚlenÚImportErrorÚjoin)Úmissing_depsÚdep©rZ   r[   r+   r,   Ú	run_checkÆ   s    ÿüÿz;requires_dependencies.<locals>.decorator.<locals>.run_checkr   r   ©r   r   c                    s   ˆƒ  ˆ | i |¤ŽS ©Nr+   rg   ©r   rf   r+   r,   ÚwrapperÕ   s    z9requires_dependencies.<locals>.decorator.<locals>.wrapperc                  Ÿ  s   ˆƒ  ˆ | i |¤ŽI d H S rh   r+   rg   ri   r+   r,   Úwrapper_asyncÚ   s    z?requires_dependencies.<locals>.decorator.<locals>.wrapper_async)r   ÚasyncioÚiscoroutinefunction)r   rj   rk   re   ri   r,   Ú	decoratorÅ   s    
z(requires_dependencies.<locals>.decorator)Ú
isinstancer.   )rZ   r[   rn   r+   re   r,   Úrequires_dependencies¾   s    
rp   )Ú
dependencyc              
   C  sR   zt  | ¡ W n> tyL } z&| t|ƒv r8W Y d }~dS W Y d }~n
d }~0 0 dS )NFT)Ú	importlibÚimport_modulera   Úrepr)rq   Úer+   r+   r,   r^   æ   s    $r^   zIterable[_T]zTuple[_T, Iterator[_T]])Úitr   c                 C  s8   t | ƒ}zt|ƒ}W n ty.   tdƒ‚Y n0 ||fS )NzYExpected at least 1 element in iterable from which to retrieve first, got empty iterable.)ÚiterÚnextÚStopIterationÚ
ValueError)rv   ÚiteratorÚoutr+   r+   r,   Ú_first_and_remaining_iteratorð   s    ÿ
r}   c                 C  s   t | ƒ\}}|S )zRReturns the first item from an iterable. Raises an error if the iterable is empty.)r}   )rv   r|   Ú_r+   r+   r,   Úfirstü   s    r   zIterable[Any]r   c                 C  s*   t | ƒ\}}tdd„ |D ƒƒr&tdƒ‚|S )zqReturns the only element from a singleton iterable.

    Raises an error if the iterable is not a singleton.
    c                 s  s   | ]
}d V  qdS )TNr+   ©rP   r~   r+   r+   r,   rQ     rR   zonly.<locals>.<genexpr>zRExpected only 1 element in passed argument, instead there are at least 2 elements.)r}   Úanyrz   )rv   r|   r{   r+   r+   r,   Úonly  s    ÿr‚   c                  C  s  zt  d¡ d} W n ty(   d} Y n0 d t ¡  d¡d d… ¡}z®t d¡dkròt d¡dkròd	t	v r°t
jd
t	 d t ¡  d | d t ¡  d t| ƒ d dd� nBt
jd
t	 d t ¡  d | d t ¡  d t| ƒ d dd� W n t�y   Y n0 d S )Nz
nvidia-smiTFÚ.é   ZSCARF_NO_ANALYTICSÚtrueZDO_NOT_TRACKÚdevz:https://packages.unstructured.io/python-telemetry?version=z
&platform=z&pythonz&arch=z&gpu=z	&dev=trueé
   )Útimeoutz
&dev=false)Ú
subprocessÚcheck_outputÚ	Exceptionrb   ÚplatformÚpython_versionÚsplitÚosÚgetenvr   ÚrequestsrC   ÚsystemÚmachiner.   )Zgpu_presentr�   r+   r+   r,   Úscarf_analytics  sv    

ÿþýüûúùø	÷
öôÿþýüûúùø	÷
öô
r”   z	list[str]Úintzlist[tuple[str, ...]])ÚsÚnr   c                 C  sT   g }t t| ƒ| d ƒD ]6}g }t |ƒD ]}| | ||  ¡ q(| t|ƒ¡ q|S )zSGenerate n-grams from a list of strings where `n` (int) is the size of each n-gram.é   )Úranger`   r_   Útuple)r–   r—   Zngrams_listÚiZngramÚjr+   r+   r,   Úngrams<  s    r�   z"tuple[float, set[tuple[str, ...]]])Úfirst_stringÚsecond_stringr—   r   c                 C  sd   |sdt ƒ fS t|  ¡ |ƒ}t| ¡ |ƒ}|s8dt ƒ fS t |ƒt |ƒ@ }t|ƒt|ƒ d }||fS )zTCalculate the percentage of common_ngrams between string A and B with reference to Ar   éd   )Úsetr�   rŽ   r`   )rž   rŸ   r—   Zfirst_string_ngramsZsecond_string_ngramsZcommon_ngramsÚ
percentager+   r+   r,   Ú!calculate_shared_ngram_percentageH  s    

r£   z'tuple[float, set[tuple[str, ...]], str])rž   rŸ   r   c                 C  s�   t ƒ }t|  ¡ ƒt| ¡ ƒk r0t|  ¡ ƒd }nt| ¡ ƒd }||  } }d}|sxt| ||ƒ\}}|dkrnqxqN|d8 }qNt|dƒ|t|d ƒfS )aG  From two strings, calculate the shared ngram percentage.

    Returns a tuple containing...
        - The largest n-gram percentage shared between the two strings.
        - A set containing the shared n-grams found during the calculation.
        - A string representation of the size of the largest shared n-grams found.
    r˜   r   r„   )r¡   r`   rŽ   r£   Úroundr.   )rž   rŸ   Zshared_ngramsr—   Zngram_percentager+   r+   r,   Ú"calculate_largest_ngram_percentage[  s     

ý
r¥   ç        Úfloat)Úparent_targetÚchild_targetÚaddr   c                 C  s  t | ƒdkrdS g d¢}|rpt | ƒdkrpt| ƒ}|d  |8  < |d  |8  < |d  |7  < |d  |7  < t |ƒdkrÀ|d |d krÀ|d |d krÀ|d |d krÀ|d |d krÀdS t |ƒdk�o|d |d   koì|d kn  �o|d |d   k�o|d kS   S )	zõTrue if the child_target bounding box is nested in the parent_target.

    Box format: [x_bottom_left, y_bottom_left, x_top_right, y_top_right].
    The parameter 'add' is the pixel error tolerance for extra pixels outside the parent region
    é   F©r   r   r   r   r   r˜   r„   é   T)r`   Úlist)r¨   r©   rª   Zparent_targetsr+   r+   r,   Úis_parent_boxz  s0    
ÿþþýý&$þr¯   Útotalz!tuple[float, float, float, float])Úbox1Úbox2Úintersection_ratio_methodr   c                 C  s,  | d \}}| d \}}|d \}}|d \}	}
|| ||  }|	| |
|  }t ||ƒ}t ||ƒ}t||	ƒ}t||
ƒ}t d|| ƒt d|| ƒ }t ||ƒ}t||ƒ}|| }|dkrÒ|dkrÄdS || d }nH|dkrô|dkrædS || d }n&|| dk�rdS ||| |  d }t|dƒ|||fS )a7  Calculate the percentage of overlapped region.

    Calculate the percentage with reference to
    the biggest element-region (intersection_ratio_method="parent"),
    the smallest element-region (intersection_ratio_method="partial"), or
    the disjunctive union region (intersection_ratio_method="total")
    r   r„   Úparentr¬   r    Úpartial)ÚmaxÚminr¤   )r±   r²   r³   Úx1Úy1Zx2Úy2Zx3Zy3Zx4Zy4Z	area_box1Z	area_box2Zx_intersection1Zy_intersection1Zx_intersection2Zy_intersection2Zintersection_areaÚmax_areaÚmin_areaÚ
total_areaÚoverlap_percentager+   r+   r,   Úcalculate_overlap_percentage–  s:    



þ

r¿   ç      $@z$list[Points] | tuple[Points, Points]zlist[str] | tuple[str, str])Úbox_pairÚ
label_pairÚ	text_pairÚix_pairÚsm_overlap_thresholdc                 C  sÊ  d\}}}}| \}	}
|\}}|\}}|\}}t |	|
dd�\}}}}||k rr|› d|› d�|› d|› d�g}d}�nF|s¤|› d|› d�|› d|› d�g}d|› �}�n|sÔ|› d|› d�|› d|› d�g}d|› �}nä||v sæ||v �r|› d|› d�|› d|› d�g}d}n¬t||ƒ\}}}t|d	ƒ}|�sR|› d|› d�|› d|› d�g}d
}nf|› d|› d�|› d|› d�g}t| ¡ ƒt| ¡ ƒk �r�|n|}d| d|› d� }d|› d|› �}|||||||fS )aµ  Classifies the overlapping case for an element_pair input.

    There are 5 cases of overlapping:
        'Small partial overlap'
        'Partial overlap with empty content'
        'Partial overlap with duplicate text (sharing 100% of the text)'
        'Partial overlap without sharing text'
        'Partial overlap sharing {calculate_largest_ngram_percentage(...)}% of the text'

    Returns:
    overlapping_elements: List[str] - List of element types with their `ix` value.
        Ex: ['Title(ix=0)']
    overlapping_case: str - See list of cases above
    overlap_percentage: float
    largest_ngram_percentage: float
    max_area: float
    min_area: float
    total_area: float
    )NNNNrµ   ©r³   ú(ix=ú)zSmall partial overlapz&partial overlap with empty content in z#partial overlap with duplicate textr„   z$partial overlap without sharing textzof the text fromú(z-gram)zpartial overlap sharing z% )r¿   r¥   r¤   r`   rŽ   )rÁ   rÂ   rÃ   rÄ   rÅ   Úoverlapping_elementsÚoverlapping_caser¾   Úlargest_ngram_percentager±   r²   Útype1Útype2Ztext1Ztext2Úix_element1Úix_element2r»   r¼   r½   r~   Z	largest_nZref_typer+   r+   r,   Úidentify_overlapping_caseÇ  sj    ýþþþþÿ

þþ"ùrÑ   )Úcoordinatesc                 C  s$   | d \}}| d \}}||||fS )zåAccepts a set of Points and returns the lower-left and upper-right coordinates.

    Expects four coordinates representing the corners of a rectangle, listed in this order:
    bottom-left, top-left, top-right, bottom-right.
    r   r„   r+   )rÒ   Úx_bottom_left_1Úy_bottom_left_1Úx_top_right_1Úy_top_right_1r+   r+   r,   Ú_convert_coordinates_to_box,  s    r×   é   )rÁ   rÂ   rÃ   Únested_error_tolerance_pxrÅ   c           !   	   C  sü  | \}}|\}}d  dd„ |D ƒ¡}	d  dd„ |D ƒ¡}
|dd…  ¡ }|dd…  ¡ }t|ƒ}t|ƒ}|\}}}}|\}}}}||k oŽ||k}||k ož||k}d\}}}}}}d\}}}|�rÂ|�rÂt||d	d
�\}} } } t||dd
�\}}}}t|||d��rH|› d|	› d�|› d|
› d�g}d|› d|› �}d}|› d|	› d�}nzt|||d��rž|› d|
› d�|› d|	› d�g}d|› d|› �}d}|› d|
› d�}n$t| |||	|
f|d�\}}}}}}}||||�pÐd|�pØd|�pàd|�pèd|�pðd|�pødf	S )aª  Identify if overlapping or nesting elements exist and, if so, the type of overlapping case.

    Returns:
    overlapping_elements: List[str] - List of element types & their `ix` value. Ex: ['Title(ix=0)']
    overlapping_case: str - See list of cases above
    overlap_percentage: float
    overlap_percentage_total: float
    largest_ngram_percentage: float
    max_area: float
    min_area: float
    total_area: float
    Ú c                 S  s   g | ]}|  ¡ r|‘qS r+   ©Ú	isnumeric©rP   Úchr+   r+   r,   rX   M  rR   z8identify_overlapping_or_nesting_case.<locals>.<listcomp>c                 S  s   g | ]}|  ¡ r|‘qS r+   rÛ   rÝ   r+   r+   r,   rX   N  rR   r­   N)NNNNNN)NNNr°   rÆ   r´   )rª   rÇ   rÈ   znested z in r    )rÅ   r   )rb   Ústripr×   r¿   r¯   rÑ   )!rÁ   rÂ   rÃ   rÙ   rÅ   r±   r²   rÍ   rÎ   rÏ   rÐ   Zbox1_cornersZbox2_cornersrÓ   rÔ   rÕ   rÖ   Zx_bottom_left_2Zy_bottom_left_2Zx_top_right_2Zy_top_right_2Zhorizontal_overlapZvertical_overlaprÊ   Úparent_elementrË   r¾   Úoverlap_percentage_totalrÌ   r»   r¼   r½   r~   r+   r+   r,   Ú$identify_overlapping_or_nesting_case8  sŽ    ù	
ýýþþûø	÷râ   zlist['Text']z!tuple[bool, list[dict[str, Any]]])ÚelementsrÙ   rÅ   r   c                  C  s¸  | d j jpd}dd„ t|ƒD ƒ}dd„ t|ƒD ƒ}dd„ t|ƒD ƒ}t| ƒD ]r\}}|j jp`d}	|	d }
|j jr–tt|j j ¡ d ƒ}||
  |¡ ||
  |› d	|j	› �¡ ||
  |j
¡ qNd
}g }tt|||ƒdd�D ]Ð\}	\}}}tt|dƒƒ}tt|dƒƒ}tt|dƒƒ}t|||ƒD ]Š\}}}t|||||ƒ\	}}}}}}}}}|�r"| ||||› d�||› d�t|dƒ› d�t|dƒ› d�t|dƒ› d�dœdœ¡ d}�q"qÞ||fS )zLCatch overlapping and nested bounding boxes cases across a list of elements.éÿÿÿÿr   c                 S  s   g | ]}g ‘qS r+   r+   r€   r+   r+   r,   rX   ¬  rR   z7catch_overlapping_and_nested_bboxes.<locals>.<listcomp>c                 S  s   g | ]}g ‘qS r+   r+   r€   r+   r+   r,   rX   ®  rR   c                 S  s   g | ]}g ‘qS r+   r+   r€   r+   r+   r,   rX   ¯  rR   r˜   Zpointsr\   F)Ústartr„   ú%u   pxË†2)rÌ   rá   r»   r¼   r½   )rÊ   rà   rË   r¾   ÚmetadataT)rç   Úpage_numberr™   Ú	enumeraterÒ   r   r   Úto_dictr_   ÚcategoryÚtextr#   r®   r   râ   r¤   ) rã   rÙ   rÅ   Z	num_pagesZpages_of_bboxesZtext_labelsZtext_contentÚixÚelementrè   Zn_page_to_ixZboxZdocument_with_overlapping_flagZoverlapping_casesZpage_bboxesZpage_labelsZ	page_textZpage_bboxes_combinationsZpage_labels_combinationsZtext_content_combinationsrÁ   rÂ   rÃ   rÊ   rà   rË   r¾   rá   rÌ   r»   r¼   r½   r+   r+   r,   Ú#catch_overlapping_and_nested_bboxes¤  sv    
þýûö	ûûÿ
rï   c                   @  s:   e Zd Zddœdd„Zdd„ Zdddœd	d
„Zdd„ ZdS )ÚFileHandlerr.   r4   c                 C  s   || _ t ¡ | _d S rh   )r0   Ú	threadingÚLockÚlock)r>   r0   r+   r+   r,   r?   ñ  s    zFileHandler.__init__c              	   C  s`   | j �F t| jƒ�}| ¡ }W d   ƒ n1 s00    Y  |W  d   ƒ S 1 sR0    Y  d S rh   )ró   rS   r0   Úread)r>   ÚfilerK   r+   r+   r,   Ú	read_fileõ  s    &zFileHandler.read_filer7   )rK   r   c              	   C  s`   | j �F t| jdƒ�}| |¡ W d   ƒ n1 s40    Y  W d   ƒ n1 sR0    Y  d S )NÚw)ró   rS   r0   Úwrite)r>   rK   rõ   r+   r+   r,   Ú
write_fileû  s    zFileHandler.write_filec                 C  sD   | j �* tj | j¡r"t | j¡ W d   ƒ n1 s60    Y  d S rh   )ró   r�   ÚpathÚexistsr0   Úremove)r>   r+   r+   r,   Úcleanup_file   s    zFileHandler.cleanup_fileN)r:   rH   rI   r?   rö   rù   rý   r+   r+   r+   r,   rð   ð  s   rð   )N)r¦   )r°   )rÀ   )rØ   rÀ   )rØ   rÀ   )AÚ
__future__r   rl   r<   rr   r    rN   r�   rŒ   r‰   r2   rñ   r   Ú	itertoolsr   Útypingr   r   r   r   r	   r
   r   r   r   r   r   r‘   Ztyping_extensionsr   r   Zunstructured.__version__r   Zunstructured.documents.elementsr   r   r§   r   Ú__annotations__r   r   ZDATE_FORMATSr   r   r-   r5   r6   rU   rY   rp   r^   r}   r   r‚   r”   r�   r£   r¥   r¯   r¿   rÑ   r×   râ   rï   rð   r+   r+   r+   r,   Ú<module>   sh   4	m þ(
- ý6 ûe  ûn  ýL