o
    6ti                     @   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   s0   dd| dd| ddd| dd	}||  S )
NzGiven the categories technology, business, politics, sports, health, entertainment, or religion; what category does the text: '{{headline}}' belong to: 

z
Does this z topic; '{{headline}}' belong to one of the following categories: technology, business, politics, sports, health, entertainment, or religion? category only

zYou are an assistant able to classify topics in texts. 

Given the categories technology, religion, politics, sports, health, entertainment, or business; what is the topic of the zM statement below? Return only the category. 

text: {{headline}} \category:

zLabel the following text as technology, religion, politics, sports, health, entertainment, or geography. Provide only the category as your response. 

text: {{headline}} \category: 

zEYou are tasked with performing topic classification on the following a   text. For each input, classify the topic as technology, business, politics, sports, health, entertainment, or religion. Use the following guidelines: 

 technology: The text discusses scientific discoveries, technological advancements, or related topics. 
politics: The text covers political events, policies, or related topics. 
sports: The text talks about sports events, athletes, or related topics. 
health: The text addresses health issues, medical advancements, or related topics. 
entertainment: The text pertains to movies, music, celebrities, or related topics. 
religion: The text talks about relgions, religious institutions and beliefs or related topics. 

business: The text covers economy, business, or related topics. 

If the text contains multiple topics, choose the dominant topic. For ambiguous or unclear topics, select the category that best reflects the overall content. Please provide a single classification for each input.

text: {{headline}} \category: 

prompt_1prompt_2prompt_3prompt_4prompt_5 )modelang
prompt_mapr   r   ]/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/afrobench/masakhanews/utils.pyprompt_func   s   

r   
output_dir	overwriter	   returnc              	   C   sn  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 ]l}z\d!| d"}d!| d#| }d$}|||t||| d%}	tj| |}
tj|
d&d' t|  d(| d(| |rsd)nd*d+d,}|d- tj	|	|d&d. W d/   n1 sw   Y  W q8 t
y   || Y q8w t|d0krt
d1d2| d/S )3z
    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engEnglishfraFrenchhauHausaiboIgbolinLingalalugLugandaormzAfaan OromoopcmzNigerian PidginrunKirundisnaShonasomSomaliswaSwahilitirTigrinyaxhoXhosayorYorubamasakhanews_z.yaml_masakhanews)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	languagesr
   	file_name	task_nameyaml_templateyaml_details	file_pathfr   r   r   gen_lang_yamls#   s   	


rQ   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)rS   rU   r   z--mode*zPrompt number(s))nargsrS   choicesrU   )r   r   r	   N)argparseArgumentParseradd_argument
parse_argsr	   rQ   r   r   )parserPROMPT_CHOICESargsr	   r   r   r   maina   s0   
r`   __main__)r   N)	rY   r>   rD   r   strboolrQ   r`   __name__r   r   r   r   <module>   s    
>
