o
    6tiw                     @   sZ   d dl Z d dlZd dlZdd Zdedededdfdd	Zdd
dZedkr+e  dS dS )    Nc                 C   s   dddddd}||  S )NzP: {{flores_passage}}
Q: {{question.strip()}}
A: {{mc_answer1}}
B: {{mc_answer2}}
C: {{mc_answer3}}
D: {{mc_answer4}}
Please choose the correct answer from the options above:zPassage: {{flores_passage}}
Question: {{question.strip()}}
1: {{mc_answer1}}
2: {{mc_answer2}}
3: {{mc_answer3}}
4: {{mc_answer4}}
Please select the correct answer from the given choices:zContext: {{flores_passage}}
Query: {{question.strip()}}
Option A: {{mc_answer1}}
Option B: {{mc_answer2}}
Option C: {{mc_answer3}}
Option D: {{mc_answer4}}
Please indicate the correct option from the list above:z{{flores_passage}}
Based on the above passage, answer the following question:
{{question.strip()}}
Choices:
A) {{mc_answer1}}
B) {{mc_answer2}}
C) {{mc_answer3}}
D) {{mc_answer4}}
Please provide the correct answer from the choices given:zRead the passage: {{flores_passage}}
Then answer the question: {{question.strip()}}
Options:
A. {{mc_answer1}}
B. {{mc_answer2}}
C. {{mc_answer3}}
D. {{mc_answer4}}
Please choose the correct option from the above list:prompt_1prompt_2prompt_3prompt_4prompt_5 )modelang
prompt_mapr   r   Z/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrobench/belebele/utils.py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$d%d&d'd(d)d*d+d,d-d.d/d0d1}i dd2dd3dd4dd5d	d6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAd!dBdCdDdEdFdGdHdIdJdKdLdMdNdOdPd1}|  D ]o}z^dQ| dR}dQ| dS| }dT}	|	||| t||| dU}
tj| |}tj|dVdW t|  dX| dX| |rdYndZd[d\}|d] tj	|
|dVd^ W d_   n1 sw   Y  W q t
y   || Y qw t|d`krt
dadb| d_S )cz
    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.
    afr	AfrikaansamhAmharicaryzMoroccan ArabicarzzEgyptian ArabicbamBambaraengEnglishfraFrenchhauHausaiboIgbolinLingalapor
PortuguesesnaShonaswaSwahilitirTigrinyatsoTsongatsnTswanawolWolofXhosaYorubaZuluSwatizSouthern SothoSomalizPlateau MalagasyNyanjaLuoLugandaKinyarwandaKabuverdianuOromozNigerian Fulfulde)xhoyorzulsswsotsompltnyaluolugkinkeagazfuvafr_Latnamh_Ethiary_Arabarz_Arabbam_Latneng_Latnfra_Latnhau_Latnibo_Latnlin_Latnpor_Latnsna_Latnswh_Latntir_Ethitso_Latntsn_Latnwol_Latnxho_Latnyor_Latnzul_Latnssw_Latnsot_Latnsom_Latnplt_Latnnya_Latnluo_Latnlug_Latnkin_Latnkea_Latngaz_Latnfuv_Latn	belebele_z.yaml_belebele)includetaskdataset_namedoc_to_textT)exist_ok/wxutf8)encodingz# Generated by utils.py
)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )keysr   ospathjoinmakedirsopenwriteyamldumpFileExistsErrorappendlen)r   r   r	   err	languageslang_2_dataset_lang_coder
   	file_name	task_nameyaml_templateyaml_details	file_pathfr   r   r   gen_lang_yamls   s  	
"	
"

r   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./z Directory to write yaml files to)r   r   z--moder   r   zPrompt number)r   choicesr   )r   r   r	   N)argparseArgumentParseradd_argument
parse_argsr   r   r   r	   )parserargsr   r   r   main   s(   r   __main__)r   N)	r   rx   r~   r   strboolr   r   __name__r   r   r   r   <module>   s    
o
