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	Z
 dZdZdZd	Zd
ZdZdZg dZdd ZG dd de
jjZG dd de
jjZdS )zwordnet dataset.    )absolute_import)division)print_functionNa  WordNet Release 3.0 This software and database is being provided
to you, the LICENSEE, by Princeton University under the following license. By
obtaining, using and/or copying this software and database, you agree that you
have read, understood, and will comply with these terms and conditions.:
Permission to use, copy, modify and distribute this software and database and
its documentation for any purpose and without fee or royalty is hereby granted,
provided that you agree to comply with the following copyright notice and
statements, including the disclaimer, and that the same appear on ALL copies of
the software, database and documentation, including modifications that you make
for internal use or for distribution. WordNet 3.0 Copyright 2006 by Princeton
University. All rights reserved. THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS"
AND PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON UNIVERSITY MAKES NO
REPRESENTATIONS OR WARRANTIES OF MERCHANT- ABILITY OR FITNESS FOR ANY PARTICULAR
PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL
NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
The name of Princeton University or Princeton may not be used in advertising or
publicity pertaining to distribution of the software and/or database. Title to
copyright in this software, database and any associated documentation shall at
all times remain with Princeton University and LICENSEE agrees to preserve same.
a  @article{10.1145/219717.219748,
author = {Miller, George A.},
title = {WordNet: A Lexical Database for English},
year = {1995},
issue_date = {Nov. 1995},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
volume = {38},
number = {11},
issn = {0001-0782},
url = {https://doi.org/10.1145/219717.219748},
doi = {10.1145/219717.219748},
journal = {Commun. ACM},
month = nov,
pages = {39--41},
numpages = {3}
}
zWordNet is a large lexical database of English. Nouns, verbs,
adjectives and adverbs are grouped into sets of cognitive synonyms (synsets),
each expressing a distinct concept. Synsets are interlinked by means of
conceptual-semantic and lexical relations.
a.  This WORDNET TENSOR DATA consists of a collection of
triplets (synset, relation_type, triplet) extracted from WordNet 3.0
(http://wordnet.princeton.edu). This data set can be seen as a 3-mode tensor
depicting ternary relationships between synsets. See
https://everest.hds.utc.fr/doku.php?id=en:transe.
a.  @incollection{NIPS2013_5071,
title = {Translating Embeddings for Modeling Multi-relational Data},
author = {Bordes, Antoine and Usunier, Nicolas and Garcia-Duran, Alberto and Weston, Jason and Yakhnenko, Oksana},
booktitle = {Advances in Neural Information Processing Systems 26},
editor = {C. J. C. Burges and L. Bottou and M. Welling and Z. Ghahramani and K. Q. Weinberger},
pages = {2787--2795},
year = {2013},
publisher = {Curran Associates, Inc.},
url = {http://papers.nips.cc/paper/5071-translating-embeddings-for-modeling-multi-relational-data.pdf}
}
ziSame as WN18 but fixes test leakage through inverse
relations. See https://github.com/TimDettmers/ConvE.
a~  @inproceedings{dettmers2018conve,
	Author = {Dettmers, Tim and Pasquale, Minervini and Pontus, Stenetorp and Riedel, Sebastian},
	Booktitle = {Proceedings of the 32th AAAI Conference on Artificial Intelligence},
	Title = {Convolutional 2D Knowledge Graph Embeddings},
	Url = {https://arxiv.org/abs/1707.01476},
	Year = {2018},
        pages  = {1811--1818},
  	Month = {February}
}
)	_also_see_derivationally_related_form	_has_part	_hypernym_instance_hypernym_member_meronym_member_of_domain_region_member_of_domain_usage_similar_to_synset_domain_topic_of_verb_groupc                 C   sl   i }t jj| }|D ]}| d\}}}t||d||< qW d    n1 s+w   Y  tt|dS )N	)name
definition)	relationssynsets)tfiogfileGFilestripsplitdict
_RELATIONS)synset_definitions_pathr   fline	synset_idr   r    r!   T/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/text/wordnet.py_make_wn18_metadata{   s   r#   c                       s4   e Zd ZdZ fddZedd Zdd Z  ZS )WordnetConfigzConfiguration for `Wordnet`.c                    s&   || _ || _tt| j|||d d S )N)r   descriptionversion)	_citation_path_prefixsuperr$   __init__)selfr   path_prefixr%   citationr&   	__class__r!   r"   r*      s
   

zWordnetConfig.__init__c                 C   s   d t| jgS )N
)join	_CITATIONr'   r+   r!   r!   r"   r-      s   zWordnetConfig.citationc                 C   sD   || j  }tj|| jd tj|| jd tj|| jd fS )Nz	train.txtz	valid.txtztest.txt)r   ospathr1   r(   )r+   dl_pathsroot_dirr!   r!   r"   	get_paths   s
   
zWordnetConfig.get_paths)	__name__
__module____qualname____doc__r*   propertyr-   r8   __classcell__r!   r!   r.   r"   r$      s    
r$   c                	   @   sf   e Zd ZdZedejddee	e
jddeddeee
jddgZd	d
 Zdd Zdd ZdS )WordnetzBuilder for WordNet dataset.WN18wordnet-mlj12zwordnet-mlj12-z0.1.0)r   r,   r%   r-   r&   WN18RR c              
   C   sL   t jj| tt jt j t j t j dd| jjt j	 t
tddS )Nlhsrelationrhszhttps://wordnet.princeton.edu/)license)builderr%   featureshomepager-   metadataredistribution_info)tfdscoreDatasetInfo_DESCRIPTIONrJ   FeaturesDictTextbuilder_configr-   MetadataDictr   _LICENSEr3   r!   r!   r"   _info   s   zWordnet._infoc                 C   s   | ddd}tj|d dd}| jjt| | j	|\}}}t
jjt
jjt|ddt
jjt
jjt|ddt
jjt
jjt|ddgS )	zReturns SplitGenerators.zJhttps://everest.hds.utc.fr/lib/exe/fetch.php?media=en:wordnet-mlj12.tar.gzz=https://github.com/TimDettmers/ConvE/raw/master/WN18RR.tar.gz)r@   rB   r@   rA   zwordnet-mlj12-definitions.txt)triplets_path)r   
gen_kwargs)download_and_extractr4   r5   r1   inforL   updater#   rT   r8   rN   rO   SplitGeneratorSplitTRAINr   
VALIDATIONTEST)r+   
dl_managerr6   r   
train_pathval_path	test_pathr!   r!   r"   _split_generators   s,   zWordnet._split_generatorsc                 c   sn    t jj|%}t|D ]\}}| d\}}}||||dfV  qW d   dS 1 s0w   Y  dS )zYields examples.r   rD   N)r   r   r   r   	enumerater   r   )r+   rX   r   ir   rE   rF   rG   r!   r!   r"   _generate_examples   s   "zWordnet._generate_examplesN)r9   r:   r;   r<   r$   r4   r5   r1   _WN18_DESCRIPTION_WN18_CITATIONrN   rO   Version_WN18RR_DESCRIPTION_WN18RR_CITATIONBUILDER_CONFIGSrW   rf   ri   r!   r!   r!   r"   r?      s(    

r?   )r<   
__future__r   r   r   r4   
tensorflowr   tensorflow_datasets.public_api
public_apirN   rV   r2   rQ   rj   rk   rm   rn   r   r#   rO   BuilderConfigr$   GeneratorBasedBuilderr?   r!   r!   r!   r"   <module>   s$   	