
    9i                     8    S SK JrJrJr  SSKJr   " S S5      rg)    )absolute_importdivisionprint_function   )CiderScorerc                   .    \ rS rSrSrSS jrS rS rSrg)	CiderD   z)
Main Class to compute the CIDEr metric

c                 n    Xl         X l        X0l        [        U R                   U R                  S9U l        g )N)ndf_mode)_n_sigma_dfr   cider_scorer)selfr   sigmadfs       `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/metrics/ciderD/ciderD.py__init__CiderD.__init__   s(    '$''488D    c                 P   U R                   R                  5       nUR                  5         U Hb  nUS   nXS      n[        U5      [        L d   e[        U5      S:X  d   e[        U5      [        L d   e[        U5      S:  d   eX5S   U4-  nMd     UR                  5       u  pxXx4$ )a:  
Main function to compute CIDEr score
:param  hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
        ref_for_image (dict)  : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the corpus
captionimage_idr   r   )r   
copy_emptycleartypelistlencompute_score)	r   gtsrestmp_cider_scorerres_idhyporefscorescoress	            r   r!   CiderD.compute_score   s      ,,779 F)$DZ()C J$&'&IN#NI%&%HqL!La#.  +88:}r   c                     g)NzCIDEr-D )r   s    r   methodCiderD.method8   s    r   )r   r   r   r   N)   g      @corpus)	__name__
__module____qualname____firstlineno____doc__r   r!   r-   __static_attributes__r,   r   r   r	   r	      s    
E6r   r	   N)
__future__r   r   r   ciderD_scorerr   r	   r,   r   r   <module>r9      s    A @ &+ +r   