o
    6tip                     @   sh   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	dfd
dZdddZe	dkr2e  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/masakhaner/gen_utils.py__init__   s   
zFunctionTag.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                 C   s4   ddd| d| dd| d| dd	d
}||  S )Na  Named entities refers to names of location, organisation and personal name. 
 For example, 'David is an employee of Amazon and he is visiting New York next week to see Esther' will be 
PERSON: David $ ORGANIZATION: Amazon $ LOCATION: New York $ PERSON: Esther 

Ensure the output strictly follows the format: label: entity $ label: entity, with each unique entity on a separate label line, avoiding grouped entities (e.g., avoid LOC: entity, entity) or irrelevant entries like none. 

Text: {{text}} 
Return only the outputa  You are working as a named entity recognition expert and your task is to label a given text with named entity labels. Your task is to identify and label any named entities present in the text. The named entity labels that you will be using are PER (person), LOC (location), ORG (organization) and DATE (date). Label multi-word entities as a single named entity. For words which are not part of any named entity, do not return any value for it. 
Ensure the output strictly follows the format: label: entity $$ label: entity, with each unique entity on a separate label line, avoiding grouped entities (e.g., avoid LOC: entity, entity) or irrelevant entries like none. Return only the output 

Text: {{text}}z-You are a Named Entity Recognition expert in z: language. 
Extract all named entities from the following aM   text and categorize them into PERSON, LOCATION, ORGANIZATION, or DATE. Ensure the output strictly follows the format: label: entity $$ label: entity, with each unique entity on a separate label line, avoiding grouped entities (e.g., avoid LOC: entity, entity) or irrelevant entries like none. Return only the output 

Text: {{text}}zAs a z+ linguist, label all named entities in the aQ   text below with the categories: PERSON, LOCATION, ORGANIZATION, and DATE. Ensure the output strictly follows the format: label: entity $$ label: entity, with each unique entity on a separate label line, avoiding grouped entities (e.g., avoid LOC: entity, entity) or irrelevant entries like none. Return only the output. 

Text: {{text}}a  Provide a concise list of named entities in the text below. Use the following labels: PERSON, LOCATION, ORGANIZATION, and DATE. Ensure the output strictly follows the format: label: entity $$ label: entity, with each unique entity on a separate label line, avoiding grouped entities (e.g., avoid LOC: entity, entity) or irrelevant entries like none. Return only the output.  

Text: {{text}}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   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 ]j}zZd'| d(}d'| d)| }d*}|||t||| d+}	tj|  d,| d-d. t|  d,| d,| |rzd/nd0d1d2}
|
d3 tj|	|
d-d4 W d5   n1 sw   Y  W qA ty   |	| Y qAw t
|d6krtd7d8| d5S )9z
    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.
    amAmharicbmBambarabbjGhomalaeeEwehaHausaigIgborwKinyarwandalgLugandaluoLuomosMossinyChichewapcmzNigerian PidginsnchiShonasw	KiswahilitnSetswanatwTwiwoWolofisiXhosaYorubaisiZulu)xhyozumasakhaner_z.yaml_
masakhaner)includetaskdataset_namedoc_to_text/T)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makedirs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_yamls0   s   	


r_   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)ra   rc   z--moder   r   zPrompt number)ra   choicesrc   )r   r   r   N)argparseArgumentParseradd_argument
parse_argsr_   r   r   r   )parserargsr   r   r   mainp   s(   rk   __main__)r   N)
re   rN   rR   r   r   strboolr_   rk   r   r   r   r   r   <module>   s    $
@
