o
    Ni                     @   s   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G dd dejjZdS )zARC dataset.    )absolute_import)division)print_functionNz
@misc{chollet_francois_2019,
  title     = {The Measure of Intelligence},
  url       = {https://arxiv.org/abs/1911.01547},
  journal   = {arXiv.org},
  author    = {Francois Chollet},
  year      = {2019},
  month     = {Nov}
}
a  
ARC can be seen as a general artificial intelligence benchmark, as a program
synthesis benchmark, or as a psychometric intelligence test. It is targeted at
both humans and artificially intelligent systems that aim at emulating a
human-like form of general fluid intelligence.
z https://github.com/fchollet/ARC/c                       s(   e Zd ZdZejj fddZ  ZS )	ARCConfigzBuilderConfig for ARC.c                    sV   t t| jddtj|i| || _dt| j| _	tj
j| j	tj
jjd| _dS )zBuilderConfig for ARC.

    Args:
      version (string): version as string.
      commit: github.com/fchollet/ARC commit to use (defaults to "master").
      **kwargs: keyword arguments forwarded to super.
    versionz{}zipball/{})urlextract_methodN )superr   __init__tfdscoreVersioncommitformat	_BASE_URLdownload_urldownloadResourceExtractMethodZIPdownload_resource)selfr   r   kwargs	__class__r	   Q/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image/arc.pyr   5   s   	
zARCConfig.__init__)	__name__
__module____qualname____doc__r   r   disallow_positional_argsr   __classcell__r	   r	   r   r   r   2   s    r   c                   @   s:   e Zd ZdZedddddgZdd Zd	d
 Zdd ZdS )ARCz+The Abstraction and Reasoning Corpus (ARC).z
2019-12-06z1.0.0z"ARC commit bd9e2c9 from 2019-12-06(bd9e2c934c83d00251b7b4781ffc38cd167c885f)namer   descriptionr   c                 C   s   t jj| tt jt j t jt jt jtj	t jt jtj	dt jt jt jtj	t jt jtj	ddd t
tdS )N)inputoutputtask_idtraintest)builderr&   featuressupervised_keyshomepagecitation)r   r   DatasetInfo_DESCRIPTIONr.   FeaturesDictTextSequencetfint32r   	_CITATION)r   r	   r	   r   _infoQ   s4   	z	ARC._infoc                 C   s   | | jj}dd tjj|D }t|dkrtdt	j
||d d}t	j
|d}t	j
|d}tjjtjjd	|id
tjjtjjd	|id
gS )zCDownloads the data, defines the splits and returns SplitGenerators.c                 S   s   g | ]	}| d r|qS )zfchollet-ARC-)
startswith).0pathr	   r	   r   
<listcomp>~   s    z)ARC._split_generators.<locals>.<listcomp>   zUnexpected ARC archive formatr   datatraining
evaluation	directory)r%   
gen_kwargs)download_and_extractbuilder_configr   r7   iogfilelistdirlen
ValueErrorosr=   joinr   r   SplitGeneratorSplitTRAINTEST)r   
dl_managerextracted_dirextract_subdirdata_dir	train_dirtest_dirr	   r	   r   _split_generatorsw   s,   zARC._split_generatorsc              	   c   s    t jjtj|d}t|D ]8}t jj|}t	
|}W d   n1 s*w   Y  tj|dtd  }|||d |d dfV  qdS )z.Yields (key, example) tuples from the dataset.z*.jsonNz.jsonr+   r,   r)   )r7   rG   rH   globrL   r=   rM   sortedGFilejsonloadbasenamerJ   )r   rC   json_filepaths	json_pathftaskr*   r	   r	   r   _generate_examples   s   zARC._generate_examplesN)	r   r   r   r    r   BUILDER_CONFIGSr:   rX   rc   r	   r	   r	   r   r#   F   s    &r#   )r    
__future__r   r   r   r\   rL   tensorflow.compat.v2compatv2r7   tensorflow_datasets.public_api
public_apir   r9   r3   r   r   BuilderConfigr   GeneratorBasedBuilderr#   r	   r	   r	   r   <module>   s   