o
    6ti                     @   sh   d dl Z d dlZd dlZG dd dZdd Zdededed	dfd
dZdddZe	dkr2e  dS dS )    Nc                   @   s   e Zd Zdd ZdS )FunctionTagc                 C   s
   || _ d S )N)value)selfr    r   T/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrixnli/gen_utils.py__init__   s   
zFunctionTag.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                 C   s,   dd| dd| d| ddd}||  S )	Na  Please identify whether the premise entails or contradicts the hypothesis in the following premise and hypothesis. The answer should be exact entailment, contradiction, or neutral.

Premise: {premise}
Hypothesis: {hypothesis}

Is it entailment, contradiction, or neutral?z.Given the following premise and hypothesis in z, identify if the premise entails, contradicts, or is neutral towards the hypothesis. Please respond with exact 'entailment', 'contradiction', or 'neutral'. 

Premise: {{premise}} 
Hypothesis: {{hypothesis}}zJYou are an expert in Natural Language Inference (NLI) specializing in the z7 language.
Analyze the premise and hypothesis given in z, and determine the relationship between them.
 Respond with one of the following options: 'entailment', 'contradiction', or 'neutral'. 

Premise: {{premise}} 
Hypothesis: {{hypothesis}}zBased on the given statement, is the following claim 'true', 'false', or 'inconclusive'. 
Statement: {{premise}} 
Claim: {{hypothesis}})prompt_1prompt_3prompt_4prompt_5r   )modelang
prompt_mapr   r   r   prompt_func   s   
r   
output_dir	overwriter   returnc              	   C   s  g }i ddddddddd	d
dddddddddddddddddddddd d!d"d#d$i}|  D ]}zd%| d&}d%| d'| }d(}| d)d* d+krkd,| d&}d,| d'| }d-}t|d'd* d.kst|d'd* d/kr|||t||| d0}	n|||d1}	tj|  d)| d2d3 t|  d)| d)| |rd4nd5d6d7}
|
d8 tj	|	|
d2d9 W d:   n1 sw   Y  W q? t
y   || Y q?w t|d;krt
d<d=| d:S )>z
    Generate a yaml file for each language.

    :param output_dir: The directory to output the files to.
    :param overwrite: Whether to overwrite files if they already exist.
    engEnglishamhAmhariciboIgbofraFrenchsnachiShonawolWolofeweEwelinLingalalugLugandaxhoisiXhosakinKinyarwandatwiTwizulZuluormOromoyorYorubahauHausasotSesothoswaSwahili	afrixnli_z.yaml_afrixnli_yaml/	translateafrixnli_translate_afrixnli_translate_yaml      )includetaskdataset_namedoc_to_text)rD   rE   rF   T)exist_okwxutf8)encodingz# Generated by utils.py
)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )keyssplitintr   osmakedirsopenwriteyamldumpFileExistsErrorappendlenjoin)r   r   r   err	languagesr   	file_name	task_nameyaml_templateyaml_detailsfr   r   r   gen_lang_yamls   s   	
,

rb   c                  C   s`   t  } | jddddd | jdddd	 | jd
dg ddd |  }t|j|j|jd dS )z9Parse CLI args and generate language-specific yaml files.z--overwriteT
store_truez%Overwrite files if they already exist)defaultactionhelpz--output-dirz./translatez Directory to write yaml files to)rd   rf   z--moder   )r   prompt_2r   r   r   zPrompt number)rd   choicesrf   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsrb   r   r   r   )parserargsr   r   r   maing   s(   ro   __main__)r   N)
ri   rQ   rU   r   r   strboolrb   ro   r   r   r   r   r   <module>   s    
I
