U
    œ+Be  ã                   @   s2   d d dg fe e e edœdd„Zdd„ Zdd„ Zd S )	NF)ÚcodeÚlanguage_typeÚdatasetÚissftc                 C   sf   |  ¡ dkr2|rt| ƒ} dddddg}t| |ƒ} n0|  ¡ dkrXt| |dd	d
ddg ƒ} n
t| |ƒ} | S )z'
    Cleans up the generated code.
    Úpythonz
defz
classz
ifz
#z
printÚtsz
exportz
importz
export defaultz
import defaultz
console.log)ÚlowerÚ_clean_python_code_for_sftÚ_truncate_code_at_stopwords)r   r   r   r   Ú
stop_words© r   úc/weka-jd/prod/containers/zhuqihao/dev-cpu/upload_code/deepseek-coder/Evaluation/MBPP/utils/utils.pyÚcleanup_code   s    
r   c                 C   sd   |   dd¡} d| kr`|  d¡}| |d …   dd¡ ¡ } d| krH|  d¡nt| ƒ}| d |…  ¡ } | S )NúÚ z	```pythonz```)ÚreplaceÚindexÚstripÚfindÚlen)r   Zcode_start_idxÚend_idxr   r   r   r      s    
r   c                 C   sD   t | ƒ}|D ]*}|  |¡}d|  kr.|k rn q|}q| d |… S )Né    )r   r   )r   r
   Zmin_stop_idxZ	stop_wordÚ
stop_indexr   r   r   r	   "   s    
r	   )ÚstrÚboolr   r   r	   r   r   r   r   Ú<module>   s   ûü
