o
    5ti#                     @   s  d dl mZmZ ddlmZmZmZmZmZm	Z	 ddddej
dfdee deee  d	efd
dZejd fdee deee  dee d	efddZdddej
dfdedee dedee deded	efddZejejejddfdee deee  dededededed	efddZejejejddfdedee dededededed	efddZ				d(dee deee  d ed!ed"ed#ed	e	fd$d%Z				d(dedee d ed!ed"ed#ed	e	fd&d'ZdS ))    )SequenceOptional   )BLEUCHRFTER	BLEUScore	CHRFScoreTERScoreexpNF
hypotheses
referencesreturnc           	      C   s    t ||||||d}|| |S )aJ  Computes BLEU for a corpus against a single (or multiple) reference(s).
    This is the main CLI entry point for computing BLEU between a system output
    and a reference sentence.

    :param hypotheses: A sequence of hypothesis strings.
    :param references: A sequence of reference documents with document being
        defined as a sequence of reference strings.
    :param smooth_method: The smoothing method to use ('floor', 'add-k', 'exp' or 'none')
    :param smooth_value: The smoothing value for `floor` and `add-k` methods. `None` falls back to default value.
    :param force: Ignore data that looks already tokenized
    :param lowercase: Lowercase the data
    :param tokenize: The tokenizer to use
    :param use_effective_order: Don't take into account n-gram orders without any match.
    :return: a `BLEUScore` object
    )	lowercaseforcetokenizesmooth_methodsmooth_valueeffective_order)r   corpus_score)	r   r   r   r   r   r   r   use_effective_ordermetric r   D/home/ubuntu/.local/lib/python3.10/site-packages/sacrebleu/compat.pycorpus_bleu	   s   r   floorr   c              	   C   s   t | |d|ddddS )a  Computes BLEU for a corpus against a single (or multiple) reference(s).
    This convenience function assumes a particular set of arguments i.e.
    it disables tokenization and applies a `floor` smoothing with value `0.1`.

    This convenience call does not apply any tokenization at all,
    neither to the system output nor the reference. It just computes
    BLEU on the "raw corpus" (hence the name).

    :param hypotheses: A sequence of hypothesis strings.
    :param references: A sequence of reference documents with document being
        defined as a sequence of reference strings.
    :param smooth_value: The smoothing value for `floor`. If not given, the default of 0.1 is used.
    :return: Returns a `BLEUScore` object.

    r   Tnone)r   r   r   r   r   )r   )r   r   r   r   r   r   raw_corpus_bleu(   s
   r   T
hypothesisr   r   r   c                 C   s    t ||d|||d}|| |S )a  
    Computes BLEU for a single sentence against a single (or multiple) reference(s).

    Disclaimer: Computing BLEU at the sentence level is not its intended use as
    BLEU is a corpus-level metric.

    :param hypothesis: A single hypothesis string.
    :param references: A sequence of reference strings.
    :param smooth_method: The smoothing method to use ('floor', 'add-k', 'exp' or 'none')
    :param smooth_value: The smoothing value for `floor` and `add-k` methods. `None` falls back to default value.
    :param lowercase: Lowercase the data
    :param tokenize: The tokenizer to use
    :param use_effective_order: Don't take into account n-gram orders without any match.
    :return: Returns a `BLEUScore` object.
    F)r   r   r   r   r   r   )r   sentence_score)r   r   r   r   r   r   r   r   r   r   r   sentence_bleu@   s   r    
char_order
word_orderbetaremove_whitespaceeps_smoothingc                 C       t |||| |d}|| |S )a  
    Computes chrF for a corpus against a single (or multiple) reference(s).
    If `word_order` equals to 2, the metric is referred to as chrF++.

    :param hypotheses: A sequence of hypothesis strings.
    :param references: A sequence of reference documents with document being
        defined as a sequence of reference strings.
    :param char_order: Character n-gram order.
    :param word_order: Word n-gram order. If equals to 2, the metric is referred to as chrF++.
    :param beta: Determine the importance of recall w.r.t precision.
    :param eps_smoothing: If `True`, applies epsilon smoothing similar
    to reference chrF++.py, NLTK and Moses implementations. Otherwise,
    it takes into account effective match order similar to sacreBLEU < 2.0.0.
    :param remove_whitespace: If `True`, removes whitespaces prior to character n-gram extraction.
    :return: A `CHRFScore` object.
    r!   r"   r#   
whitespacer%   )r   r   )r   r   r!   r"   r#   r$   r%   r   r   r   r   corpus_chrf^   s   r)   c                 C   r&   )aA  
    Computes chrF for a single sentence against a single (or multiple) reference(s).
    If `word_order` equals to 2, the metric is referred to as chrF++.

    :param hypothesis: A single hypothesis string.
    :param references: A sequence of reference strings.
    :param char_order: Character n-gram order.
    :param word_order: Word n-gram order. If equals to 2, the metric is referred to as chrF++.
    :param beta: Determine the importance of recall w.r.t precision.
    :param eps_smoothing: If `True`, applies epsilon smoothing similar
    to reference chrF++.py, NLTK and Moses implementations. Otherwise,
    it takes into account effective match order similar to sacreBLEU < 2.0.0.
    :param remove_whitespace: If `True`, removes whitespaces prior to character n-gram extraction.
    :return: A `CHRFScore` object.
    r'   )r   r   )r   r   r!   r"   r#   r$   r%   r   r   r   r   sentence_chrf~   s   r*   
normalizedno_punctasian_supportcase_sensitivec                 C      t ||||d}|| |S )a
  
    Computes TER for a corpus against a single (or multiple) reference(s).

    :param hypotheses: A sequence of hypothesis strings.
    :param references: A sequence of reference documents with document being
        defined as a sequence of reference strings.
    :param normalized: Enable character normalization.
    :param no_punct: Remove punctuation.
    :param asian_support: Enable special treatment of Asian characters.
    :param case_sensitive: Enables case-sensitivity.
    :return: A `TERScore` object.
    r+   r,   r-   r.   )r   r   )r   r   r+   r,   r-   r.   r   r   r   r   
corpus_ter   s   r1   c                 C   r/   )a  
    Computes TER for a single hypothesis against a single (or multiple) reference(s).

    :param hypothesis: A single hypothesis string.
    :param references: A sequence of reference strings.
    :param normalized: Enable character normalization.
    :param no_punct: Remove punctuation.
    :param asian_support: Enable special treatment of Asian characters.
    :param case_sensitive: Enable case-sensitivity.
    :return: A `TERScore` object.
    r0   )r   r   )r   r   r+   r,   r-   r.   r   r   r   r   sentence_ter   s   r2   )FFFF)typingr   r   metricsr   r   r   r   r	   r
   TOKENIZER_DEFAULTstrr   SMOOTH_DEFAULTSfloatr   boolr    
CHAR_ORDER
WORD_ORDERBETAintr)   r*   r1   r2   r   r   r   r   <module>   s     

!


 

"
!

