/usr/local/lib/python3.6/site-packages/datasets/features/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/datasets/features/__pycache__/translation.cpython-36.pyc (5169B)
3
<%Eg @ st d dl mZmZ d dlmZmZmZmZmZm Z m
Z
d dlZerLddl
mZ eG dd dZeG dd d ZdS )
) dataclassfield)
TYPE_CHECKINGAnyClassVarDictListOptionalUnionN )FeatureTypec @ sv e Zd ZU dZee dZee dZ e
e dZe
e e
d dddZedd Zedeedf f d d
dZdS )Translationa `FeatureConnector` for translations with fixed languages per example.
Here for compatiblity with tfds.
Input: The Translate feature accepts a dictionary for each example mapping
string language codes to string translations.
Output: A dictionary mapping string language codes to translations as `Text`
features.
Example:
```python
>>> # At construction time:
>>> datasets.features.Translation(languages=['en', 'fr', 'de'])
>>> # During data generation:
>>> yield {
... 'en': 'the cat',
... 'fr': 'le chat',
... 'de': 'die katze'
... }
```
NdictF)defaultinitreprc C s t jdd t| jD S )Nc S s i | ]}t j |qS )pastring).0langr r G/usr/local/lib/python3.6/site-packages/datasets/features/translation.py
, s z(Translation.__call__..)r structsorted languages)selfr r r __call__+ s zTranslation.__call__r )returnc s$ ddl m fddt| jD S )z2Flatten the Translation feature into a dictionary.r )Valuec s i | ]} d |qS )r r )r k)r r r r 2 s z'Translation.flatten..)featuresr r r )r r )r r flatten. s zTranslation.flatten)__name__
__module____qualname____doc__r strr idr dtyper pa_typer r _typer r
r r" r r r r r
s
r
c @ s e Zd ZU dZdZee dZee dZ ee
dZee
dZ
ee
ed dddZe
dd Zdd Zd
d Zedee
df f d
ddZdS )TranslationVariableLanguagesa` `FeatureConnector` for translations with variable languages per example.
Here for compatiblity with tfds.
Input: The TranslationVariableLanguages feature accepts a dictionary for each
example mapping string language codes to one or more string translations.
The languages present may vary from example to example.
Output:
language: variable-length 1D tf.Tensor of tf.string language codes, sorted
in ascending order.
translation: variable-length 1D tf.Tensor of tf.string plain text
translations, sorted to align with language codes.
Example:
```python
>>> # At construction time:
>>> datasets.features.TranslationVariableLanguages(languages=['en', 'fr', 'de'])
>>> # During data generation:
>>> yield {
... 'en': 'the cat',
... 'fr': ['le chat', 'la chatte,']
... 'de': 'die katze'
... }
>>> # Tensor returned :
>>> {
... 'language': ['en', 'de', 'fr', 'fr'],
... 'translation': ['the cat', 'die katze', 'la chatte', 'le chat'],
... }
```
Nr F)r r r c C s<