o
    6tii                     @   s`   d dl Z d dlZd dlZG d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                   @   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/afrimmlu/gen_utils.py__init__   s   
zFunctionTag.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s    r   
output_dir	overwritemode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 ]}}zmd%| d&}d%| d'| }d(}| d)d* d+krkd,| d&}d,| d'| }d-}|||d.}	tj|  d)| d/d0 t|  d)| d)| |rd1nd2d3d4}
|
d5 tj|	|
d/d6 W d7   n1 sw   Y  W q? ty   |	| Y q?w t
|d8krtd9d:| d7S );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afrimmlu_direct_z.yaml_afrimmlu_direct/	translateafrimmlu_translate_afrimmlu_translate)includetaskdataset_nameT)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osmakedirsopenwriteyamldumpFileExistsErrorappendlenjoin)r   r   r   err	languageslang	file_name	task_nameyaml_templateyaml_detailsfr   r   r   gen_lang_yamls   s   	


rX   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./directz Directory to write yaml files to)rZ   r\   z--modeprompt_4)prompt_1prompt_2prompt_3r]   prompt_5zPrompt number)rZ   choicesr\   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsrX   r   r   r   )parserargsr   r   r   mainM   s(   ri   __main__)r   N)	rc   rF   rJ   r   strboolrX   ri   r   r   r   r   r   <module>   s    
A
