o
    Ni(                     @   sz   d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlm  m	Z
 ddlmZ dZdZdZG d	d
 d
ejjZdS ).Movie reviews with human annotated rationales.    )absolute_import)division)print_functionNaJ  
@unpublished{eraser2019,
    title = {ERASER: A Benchmark to Evaluate Rationalized NLP Models},
    author = {Jay DeYoung and Sarthak Jain and Nazneen Fatema Rajani and Eric Lehman and Caiming Xiong and Richard Socher and Byron C. Wallace}
}
@InProceedings{zaidan-eisner-piatko-2008:nips,
  author    =  {Omar F. Zaidan  and  Jason Eisner  and  Christine Piatko},
  title     =  {Machine Learning with Annotator Rationales to Reduce Annotation Cost},
  booktitle =  {Proceedings of the NIPS*2008 Workshop on Cost Sensitive Learning},
  month     =  {December},
  year      =  {2008}
}
zT
The movie rationale dataset contains human annotated rationales for movie
reviews.
z3http://www.eraserbenchmark.com/zipped/movies.tar.gzc                   @   s4   e Zd ZdZejdZdd Zdd Z	dd Z
d	S )
MovieRationalesr   z0.1.0c                 C   sJ   t jj| tt jt j t jjddgdt jt j dd dt	dS )NNEGPOS)namesreviewlabel	evidencesz*http://www.cs.jhu.edu/~ozaidan/rationales/)builderdescriptionfeaturessupervised_keyshomepagecitation)
tfdscoreDatasetInfo_DESCRIPTIONr   FeaturesDictText
ClassLabelSequence	_CITATION)self r   ]/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/text/movie_rationales.py_info7   s   zMovieRationales._infoc              	   C   s   | t}tj|d}tjjtjj	|tj|dddtjjtjj
|tj|dddtjjtjj|tj|dddgS )zReturns SplitGenerators.moviesztrain.jsonl)data_dirfilepath)name
gen_kwargsz	val.jsonlz
test.jsonl)download_and_extract_DOWNLOAD_URLospathjoinr   r   SplitGeneratorSplitTRAIN
VALIDATIONTEST)r   
dl_managerdl_dirr"   r   r   r   _split_generatorsE   s*   
z!MovieRationales._split_generatorsc              
   c   s    t j|d}tjj|Y}|D ]M}t|}|d }t j||}tjj|}	|		 }
W d   n1 s:w   Y  g }|d D ]}|D ]	}|
|d  qIqE||
|d |dfV  qW d   dS 1 skw   Y  dS )zYields examples.docsannotation_idNr   textclassificationr
   )r(   r)   r*   tfiogfileGFilejsonloadsreadappend)r   r"   r#   reviews_dirflinerowdoc_idreview_filef1review_textr   evidenceer   r   r   _generate_examplesb   s,   

"z"MovieRationales._generate_examplesN)__name__
__module____qualname____doc__r   r   VersionVERSIONr    r2   rI   r   r   r   r   r   2   s    r   )rM   
__future__r   r   r   r;   r(   tensorflow.compat.v2compatv2r7   tensorflow_datasets.public_api
public_apir   r   r   r'   r   GeneratorBasedBuilderr   r   r   r   r   <module>   s   