o
    6tih                     @   s`   d dl Z d dlZG dd d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                   @   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/afrisenti/utils.py__init__   s   
zFunctionTag.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                 C   s0   dd| dd| ddd| dd	}||  S )
NzZDoes this statement; {{tweet}} have a Neutral, Positive or Negative sentiment? Labels onlyz
Does this zS statement; '{{tweet}}' have a Neutral, Positive or Negative sentiment? Labels onlyzYou are an assistant able to detect sentiments in tweets. 

Given the sentiment labels Neutral, Positive or Negative; what is the sentiment of the zC statement below? Return only the labels. 

text: {{tweet}} 
label:zLabel the following text as Neutral, Positive, or Negative. Provide only the label as your response. 

text: {{tweet}} 
label: zIYou are tasked with performing sentiment classification on the following aZ   text. For each input, classify the sentiment as positive, negative, or neutral. Use the following guidelines: 

 Positive: The text expresses happiness, satisfaction, or optimism. 
Negative: The text conveys disappointment, dissatisfaction, or pessimism. 
Neutral: The text is factual, objective, or without strong emotional undertones. 

If the text contains both positive and negative sentiments, choose the dominant sentiment. For ambiguous or unclear sentiments, select the label that best reflects the overall tone. Please provide a single classification for each input.

text: {{tweet}} 
label: prompt_1prompt_2prompt_3prompt_4prompt_5r   )modelang
prompt_mapr   r   r   prompt_func   s   

r   
output_dir	overwriter   returnc                 C   s4  g }ddddddddd	d
ddddd}|  D ]p}z`d| d}d| d| }d}t|dd dkrB|||t||| d}	n|||d}	t|  d| d| |rVdnddd}
|
d tj|	|
dd W d    n1 ssw   Y  W q ty   |	| 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.
    AmhariczAlgerian ArabiczMoroccan ArabicHausaIgboKinyarwandaOromozNigerian PidginzMozambique PortugueseSwahiliTigrinyaXithongaTwiYoruba)amharqaryhauibokinormpcmporswatirtsotwiyor
afrisenti_z.yaml_	afrisenti   )includetaskdataset_namedoc_to_text)r5   r6   r7   /wxutf8)encodingz# Generated by utils.py
T)allow_unicodeNr   zJFiles were not created because they already exist (use --overwrite flag): z, )keysintsplitr   openwriteyamldumpFileExistsErrorappendlenjoin)r   r   r   err	languagesr   	file_name	task_nameyaml_templateyaml_detailsfr   r   r   gen_lang_yamls#   sn   

rQ   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)rS   rU   z--moder   r   zPrompt number)rS   choicesrU   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsrQ   r   r   r   )parserargsr   r   r   mainb   s(   r]   __main__)r   N)	rW   rD   r   r   strboolrQ   r]   r   r   r   r   r   <module>   s    
?
