o
    6ti                  
   @   sl   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	ed
df
ddZdddZe	dkr4e  dS dS )    Nc                   @   s   e Zd Zdd ZdS )FunctionTagc                 C   s
   || _ d S )N)value)selfr    r   \/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrobench/mafand/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||  d	| d
d||  dd||  d||  d	| dd||  d||  dd}||  S )N_textz]You are an advanced Translator, a specialized assistant designed to translate documents from zh into English. 
Your main goal is to ensure translations are grammatically correct and human-oriented. 
z: {{z}} 
English: zjYou are an advanced Translator, a specialized assistant designed to translate documents from English into zp. 
Your main goal is to ensure translations are grammatically correct and human-oriented. 
English: {eng_text} 
z: z sentence: {{z}} 
English sentence: z English sentence: {{eng_text}} 
z sentence: z6You are a translation expert. Translate the following z sentences to English 
z}}
English sentence: zKYou are a translation expert. Translate the following English sentences to z" 
English sentence: {{eng_text}} 
)prompt_1prompt_1_reverseprompt_2prompt_2_reverseprompt_3prompt_3_reverser   )modelang	lang_dictlanguage_column_name
prompt_mapr   r   r   prompt_func   s:   
r   
output_dir	overwriter   reverse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'}g d(}|  D ]}z||vrR| d)n| d*}||vr`d+| nd,| }	|ri|n|	}
d-|
 d.}d-|
 d/| }d0}|||	d1}|r|  d2| d3n|  d2| d4}tj|d5d6 t| d2| |rd7nd8d9d:}|d; tj||d5d< W d=   n1 sw   Y  W qF ty   || Y qFw t	|d>krtd?d@
| d=S )Az
    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.
    amhAmharicbamBambarabbjGbomalaeweEwefonFonhauHausaiboIgbokinKinyarwandalugLugandaluoLuomosMossinyaChichewapcmzNigerian PidginsnaShonaswaSwahilitsnSetswanatwiTwiWolofXhosaYorubaZulu)wolxhoyorzul)r   r    r"   r$   rA   r0   z-enz-frzen-zfr-mafand_z.yaml_mafand)includetaskdataset_name/z/african-englishz/english-africanT)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osmakedirsopenwriteyamldumpFileExistsErrorappendlenjoin)r   r   r   r   err	languagesfrench_langsr   	norm_langreverse_langrJ   	file_name	task_nameyaml_templateyaml_detailsfile_dirfr   r   r   gen_lang_yamls#   s   	


rh   c                  C   sz   t  } | jddddd | jdddd	 | jd
dg ddd | jddddgdd |  }t|j|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)rj   rl   z--moder   )r   r   r   zPrompt number)rj   choicesrl   z	--reverseFz!Reverse the translation direction)r   r   r   r   N)	argparseArgumentParseradd_argument
parse_argsrh   r   r   r   r   )parserargsr   r   r   mainn   s>   
rt   __main__)r   N)
rn   rS   rW   r   r   strboolrh   rt   r   r   r   r   r   <module>   s    
K$
