o
    6tiG                     @   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   sv   |dkrd}d|   d|   d|   dd dd	|   d
d d|   dd |   dd d}||  S )NpidginzNigerian Pidginz-Provide a summary of the document written in z). Ensure that you provide the summary in z and nothing else.
Document in z: z{{'text'}}\nSummary: zqSummarize the document below in triple backticks and return only the summary and nothing else.
```{{'text'}}```\nz[You are an advanced Summarizer, a specialized assistant designed to summarize documents in z. Your main goal is to ensure summaries are concise and informative. Ensure you return the summary only and nothing else.
Document: zSummarize this z document:
z document: prompt_1prompt_2prompt_3prompt_4prompt_5)
capitalize)modelang
prompt_map r   W/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrobench/xlsum/utils.pyprompt_func   s   r   
output_dir	overwriter
   returnc              	   C   s  g }d}|D ]k}z[d| d}d| d| }d}|||t ||dd}	tj| |}
tj|
dd	 t|  d
| d
| |r@dnddd}|d tj|	|dd W d   n1 s]w   Y  W q t	yq   |
| 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.
    )amharicarabichausaigbokirundioromor   somaliswahilitelugutigrinyayorubaxlsum_z.yaml_xlsumz{{summary}})includetaskdataset_namedoc_to_textdoc_to_targetT)exist_ok/wxutf8)encodingz# Generated by utils.py
)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )r   ospathjoinmakedirsopenwriteyamldumpFileExistsErrorappendlen)r   r   r
   errXLSUM_LANGUAGESr   	file_name	task_nameyaml_templateyaml_details	file_pathfr   r   r   gen_lang_yamls   sN   

r@   c                  C   sp   t  } | jddddd | jdddd	 g d
}| jdd||dd |  }|jD ]}t|j|j|d q*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)rB   rD   r   z--mode*zPrompt number(s))nargsrB   choicesrD   )r   r   r
   N)argparseArgumentParseradd_argument
parse_argsr
   r@   r   r   )parserPROMPT_CHOICESargsr
   r   r   r   mainX   s0   
rO   __main__)r   N)	rH   r-   r3   r   strboolr@   rO   __name__r   r   r   r   <module>   s    
;
