
    Ng                     \    d Z ddlZddlmZ e G d d                      Z e            ZdS )a  
This module contains variables that can permitted to be tweaked by the system environment. For
example, model parameters that changes the output of an inference call. Constants do NOT belong in
this module. Constants are values that are usually names for common options (e.g., color names) or
settings that should not be altered without making a code change (e.g., definition of 1Gb of memory
in bytes). Constants should go into `./constants.py`
    N)	dataclassc                      e Zd ZdZddededefdZdededefdZdededefdZ	e
defd	            Ze
defd
            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            ZdS )InferenceConfigz*class for configuring inference parameters vardefault_valuereturnc                 B    t           j                            ||          S )zhattempt to get the value of var from the os environment; if not present return the
        default_value)osenvironget)selfr   r   s      Y/var/www/html/ai-engine/env/lib/python3.11/site-packages/unstructured_inference/config.py_get_stringzInferenceConfig._get_string   s     z~~c=111    c                 R    |                      |          x}rt          |          S |S N)r   intr   r   r   values       r   _get_intzInferenceConfig._get_int   s/    $$S)))5 	u::r   c                 R    |                      |          x}rt          |          S |S r   )r   floatr   s       r   
_get_floatzInferenceConfig._get_float   s/    $$S)))5 	 <<r   c                 .    |                      dd          S )znumber of pixels to pad around an table image with a white background color

        The padding adds NO image data around an identified table bounding box; it simply adds white
        background around the image
        TABLE_IMAGE_BACKGROUND_PAD   )r   r   s    r   r   z*InferenceConfig.TABLE_IMAGE_BACKGROUND_PAD    s     }}92>>>r   c                 .    |                      dd          S )z>confidence threshold for table identified by table transformerTT_TABLE_CONF      ?r   r   s    r   r    zInferenceConfig.TT_TABLE_CONF)   s     444r   c                 .    |                      dd          S )?confidence threshold for column identified by table transformerTABLE_COLUMN_CONFr!   r"   r   s    r   r%   z!InferenceConfig.TABLE_COLUMN_CONF.   s     2C888r   c                 .    |                      dd          S )r$   TABLE_ROW_CONFr!   r"   r   s    r   r'   zInferenceConfig.TABLE_ROW_CONF3   s     /555r   c                 .    |                      dd          S )zFconfidence threshold for column header identified by table transformerTABLE_COLUMN_HEADER_CONFr!   r"   r   s    r   r)   z(InferenceConfig.TABLE_COLUMN_HEADER_CONF8        93???r   c                 .    |                      dd          S )zMconfidence threshold for projected row header identified by table transformerTABLE_PROJECTED_ROW_HEADER_CONFr!   r"   r   s    r   r,   z/InferenceConfig.TABLE_PROJECTED_ROW_HEADER_CONF=   s     @#FFFr   c                 .    |                      dd          S )zMconfidence threshold for table spanning cells identified by table transformerTABLE_SPANNING_CELL_CONFr!   r"   r   s    r   r.   z(InferenceConfig.TABLE_SPANNING_CELL_CONFB   r*   r   c                 .    |                      dd          S )znminimum intersection over box area ratio for a box to be considered part of a larger box
        it intersectsTABLE_IOB_THRESHOLDr!   r"   r   s    r   r0   z#InferenceConfig.TABLE_IOB_THRESHOLDG   s     4c:::r   c                 .    |                      dd          S )zthreshold for two layouts' bounding boxes to be considered as the same region

        When the intersection area over union area of the two is larger than this threshold the two
        boxes are considered the same region
        LAYOUT_SAME_REGION_THRESHOLD      ?r"   r   s    r   r2   z,InferenceConfig.LAYOUT_SAME_REGION_THRESHOLDM   s     =tDDDr   c                 .    |                      dd          S )zthreshold for one bounding box to be considered as a sub-region of another bounding box

        When the intersection region area divided by self area is larger than this threshold self is
        considered a subregion of the other
        LAYOUT_SUBREGION_THRESHOLDr3   r"   r   s    r   r5   z*InferenceConfig.LAYOUT_SUBREGION_THRESHOLDV   s     ;TBBBr   c                 .    |                      dd          S )ap  When extending the boundaries of a PDF object for the purpose of determining which other
        elements should be considered in the same text region, we use a relative distance based on
        some fraction of the block height (typically character height). This is the fraction used
        for the horizontal extension applied to the left and right sides.
        ELEMENTS_H_PADDING_COEFg?r"   r   s    r   r7   z'InferenceConfig.ELEMENTS_H_PADDING_COEF_   s     8#>>>r   c                 .    |                      dd          S )z;Same as ELEMENTS_H_PADDING_COEF but the vertical extension.ELEMENTS_V_PADDING_COEFg333333?r"   r   s    r   r9   z'InferenceConfig.ELEMENTS_V_PADDING_COEFh   s     8#>>>r   N)r   )__name__
__module____qualname____doc__strr   r   r   r   r   propertyr   r    r%   r'   r)   r,   r.   r0   r2   r5   r7   r9    r   r   r   r      s       442 2s 23 2 2 2 2 2
C      
c % E    
 ?C ? ? ? X? 5u 5 5 5 X5 95 9 9 9 X9 6 6 6 6 X6 @% @ @ @ X@ G G G G XG @% @ @ @ X@ ;U ; ; ; X;
 Ee E E E XE CE C C C XC ? ? ? ? X? ? ? ? ? X? ? ?r   r   )r=   r   dataclassesr   r   inference_configr@   r   r   <module>rC      s     
			 ! ! ! ! ! ! ]? ]? ]? ]? ]? ]? ]? ]?@ #?$$   r   