o
    h	                     @   s@   d dl Z d dlZdd Zd	ddZdd Zedkre  dS dS )
    Nc                 C   sF   g }t | }tt|d D ]}||d | d d d  q|S )zw
    Gets the AWS worker IDs from the annotation file in output folder.

    Returns a list of the AWS worker subs
    answersworkerMetadataidentityDatasub)jsonloadsrangelenappend)json_stringsubsjob_datai r   ]/var/www/html/env_mimamsha/lib/python3.10/site-packages/stanza/utils/ner/paying_annotators.pyget_worker_subs   s
   
 r   c              	   C   s   i }i }t | D ]B}t j| |}t |}t j||d }t|}| }	W d   n1 s3w   Y  t|	}
|
D ]}||dd ||< q>q	|r_|D ]}|| }|| ||< qP|S |S )a  
    Takes a path to a folder containing the worker annotation metadata from AWS Sagemaker labeling job and a
    dictionary mapping AWS worker subs to their names or identification tags and returns a dictionary mapping
    the names/identification tags to the number of labeling tasks completed.

    If no worker map is provided, this function returns a dictionary mapping the worker "sub" fields to
    the number of tasks they completed.

    :param input_path: string of the path to the directory containing the worker annotation sub-directories
    :param worker_map: dictionary mapping AWS worker subs to the worker identifications
    :return: dictionary mapping worker identifications to the number of tasks completed
    r   N   )oslistdirpathjoinopenreadr   get)
input_path
worker_maptrackerresdirecsubdir_pathsubdirjson_file_path	json_filer   r   r   workerr   r   r   track_tasks   s&   


r$   c                	   C   s,   t tdddddddd t td d S )	Nz..\tests\ner\aws_labeling_copyWorker1Worker2Worker3Worker4Worker5)z$7efc17ac-3397-4472-afe5-89184ad145d0z$afce8c28-969c-4e73-a20f-622ef122f585z$91f6236e-63c6-4a84-8fd6-1efbab6dedabz$6f202e93-e6b6-4e1d-8f07-0484b9a9093az$2b674d33-f656-44b0-8f90-d70a1ab71ec2)r   )printr$   r   r   r   r   main4   s   	r+   __main__)N)r   r   r   r$   r+   __name__r   r   r   r   <module>   s    
!
