o
    7t¾i  ã                   @   sH   d dl mZmZ dedee fdd„Zdedee fdd„Zdd	„ Zd
S )é    )ÚDictÚListÚdocÚreturnc                 C   s   t | d ƒS )z.Return all of the accepted answers as choices.Úanswers)Ú_remove_prefixes)r   © r   úM/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/webqs/utils.pyÚdoc_to_choice   s   r
   c                 C   s   t | d ƒ}ttt|ƒƒƒS )z9Return list of indices of accepted answers (all of them).r   )r   ÚlistÚrangeÚlen)r   Ú	remainingr   r   r	   Údoc_to_target	   s   r   c                 C   s@   |   ¡  | d g}| dd… D ]}| |d ¡s| |¡ q|S )zÁ
    Remove any alias that has a strict prefix elsewhere in the list.

    This is an optimization. We can do this because if the prefix is acceptable by isgreedy,
    we can stop looking.
    r   é   Néÿÿÿÿ)ÚsortÚ
startswithÚappend)ÚaliasesÚretÚaliasr   r   r	   r      s   

€r   N)Útypingr   r   Ústrr
   Úintr   r   r   r   r   r	   Ú<module>   s    