ó
    �®žjY  ã                   ó¤   • S SK r S SKrS SKrS SKrS SKrS SKJs  Jr  S SK	J
r
  \R                  r\R                  " S\5      rS rS rSS jrS rg)	é    N)Ú	BaseModelÚcommonc                 ó°   • SU ;  a  gSU ;  a  gSU S   ;   d   S5       eSU S   ;   a/  U S   S   S:”  d   S5       eU S   S   U S   S   S	-   ::  d   S
5       eg)zì
Validate the provided configuration file.
A ValueError exception will be thrown in case the config file is invalid

Parameters
----------
config : dictionary
    Configuration for the tablemodel

Returns
-------
bool : True on success
ÚmodelTÚpreparationÚmax_tag_lenz<Config error: 'preparation.max_tag_len' parameter is missingÚseq_lenr   z0Config error: 'model.seq_len' should be positiveé   zKConfig error: 'model.seq_len' should be up to 'preparation.max_tag_len' + 2© )Úconfigs    Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docling_ibm_models/tableformer/common.pyÚvalidate_configr      s¢   € ð �fÓØØ˜FÓ"Øà˜ Ñ.Ó.ðFàEóFØ.à�F˜7‘OÓ#à�7‰O˜IÑ&¨Ó*ð	>à=ó	>Ø*à�g‰˜yÑ)Ø�=Ñ! -Ñ0°1Ñ4ó
ð 	YàXó	Yð 
ð ó    c                 ó”   • [        U S5       n[        R                  " U5      nS S S 5        [        W5        U$ ! , (       d  f       N= f)NÚr)ÚopenÚjsonÚloadr   )Úconfig_filenameÚfdr   s      r   Úread_configr   /   s8   € Ü	ˆo˜sÔ	# rÜ—’˜2“ˆ÷ 
$ô �FÔà€M÷ 
$Õ	#ús	   �9¹
Ac                 óì   • U b  Uc  U$ U nUSS  H1  nXT;  a%  U(       a  [        SR                  U5      5      eUs  $ XE   nM3     US   nXd;  a#  U(       a  [        SR                  U5      5      eU$ XF   $ )a]  
Safe get parameter from a nested dictionary.

Provide a nested dictionary (dictionary of dictionaries) and a list of indices:
- If the whole index path exists the value pointed by it is returned
- Otherwise the default value is returned.

Input:
    input_dict: Data structure of nested dictionaries.
    index_path: List with the indices path to follow inside the input_dict.
    default: Default value to return if the indices path is broken.
    required: If true a ValueError exception will be raised in case the parameter does not exist
Output:
    The value pointed by the index path or "default".
NéÿÿÿÿzMissing parameter: {})Ú
ValueErrorÚformat)Ú
input_dictÚ
index_pathÚdefaultÚrequiredÚdÚiÚ
last_indexs          r   Úsafe_get_parameterr#   9   sŒ   € ð  Ñ˜ZÑ/Øˆà€AØ˜˜‹_ˆØ‹:ÞÜ Ð!8×!?Ñ!?ÀÓ!BÓCÐCØŠNØ‰DŠñ ð ˜B‘€JØÓÞÜÐ4×;Ñ;¸JÓGÓHÐHØˆà‰=Ðr   c                 ó\   • [         R                  U    nSU;   a  UR                  SU5      nU$ )zö
Build the full filename of the prepared data part

Parameters
----------
prepared_data_part : string
    Part of the prepared data
dataset_name : string
    Name of the dataset

Returns
-------
string
    The full filename for the prepared file
z	<POSTFIX>)ÚsÚPREPARED_DATA_PARTSÚreplace)Úprepared_data_partÚdataset_nameÚtemplates      r   Úget_prepared_data_filenamer+   ]   s4   € ô  ×$Ñ$Ð%7Ñ8€HØ�hÓØ×#Ñ# K°Ó>ˆØ€Or   )NF)Úargparser   ÚloggingÚosÚtorchÚ'docling_ibm_models.tableformer.settingsÚtableformerÚsettingsr%   Ú7docling_ibm_models.tableformer.models.common.base_modelr   ÚDEBUGÚ	LOG_LEVELÚget_custom_loggerÚloggerr   r   r#   r+   r   r   r   Ú<module>r8      sN   ðÛ Û Û Û 	ã ç 3Ð 3Ý Mà�M‰M€	Ø	
×	Ò	˜X yÓ	1€òò@ô!óHr   