o
    j                     @   sR   d Z ddlmZmZ ddlmZ ddlmZ dede	edf de
e fd	d
ZdS )zStage 3: Statistical bigram scoring.

Note: ``from __future__ import annotations`` is intentionally omitted because
this module is compiled with mypyc, which does not support PEP 563 string
annotations.
    )BigramProfilescore_best_languageDetectionResult)EncodingInfodata
candidates.returnc                 C   sp   | r|sg S t | }g }|D ]}t| |j|d\}}|dkr'||j||f q|jdd dd dd |D S )	zScore all candidates and return results sorted by confidence descending.

    :param data: The raw byte data to score.
    :param candidates: Encoding candidates to evaluate.
    :returns: A list of :class:`DetectionResult` sorted by confidence.
    )profileg        c                 S   s   | d S )N    )xr   r   b/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/chardet/pipeline/statistical.py<lambda>!   s    z"score_candidates.<locals>.<lambda>T)keyreversec                 S   s    g | ]\}}}t |||d qS ))encoding
confidencelanguager   ).0nameslangr   r   r   
<listcomp>"   s    z$score_candidates.<locals>.<listcomp>)r   r   r   appendsort)r   r   r
   scoresencr   r   r   r   r   score_candidates   s   	r   N)__doc__chardet.modelsr   r   chardet.pipeliner   chardet.registryr   bytestuplelistr   r   r   r   r   <module>   s    
