


import os

from ...utils import logging
from .utils import DataProcessor, InputExample


lowerCAmelCase__       :	Tuple     				=logging.get_logger(__name__)







class      __lowercase  (_a   ):





							"""simple docstring"""







							def __init__(	self       ,		lowerCAmelCase__       ,		lowerCAmelCase__=None    ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_						:			Any       						= language
										SCREAMING_SNAKE_CASE_						:			int       						= train_language






							def  UpperCamelCase__			(	self       ,		lowerCAmelCase__    ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_						:			List[str]       						= self.language if self.train_language is None else self.train_language
										SCREAMING_SNAKE_CASE_						:			Any       						= self._read_tsv(os.path.join(lowerCAmelCase_       ,		F'''XNLI-MT-1.0/multinli/multinli.train.{lg}.tsv'''    )    )
										SCREAMING_SNAKE_CASE_						:			Optional[int]       						= []
										for i, line in enumerate(lowerCAmelCase_    ):
													if i == 0:
																continue
													SCREAMING_SNAKE_CASE_						:			Union[str, Any]       						= F'''train-{i}'''
													SCREAMING_SNAKE_CASE_						:			int       						= line[0]
													SCREAMING_SNAKE_CASE_						:			Optional[Any]       						= line[1]
													SCREAMING_SNAKE_CASE_						:			Optional[Any]       						= 'contradiction' if line[2] == 'contradictory' else line[2]
													if not isinstance(lowerCAmelCase_       ,		lowerCAmelCase_    ):
																raise ValueError(F'''Training input {text_a} is not a string'''    )
													if not isinstance(lowerCAmelCase_       ,		lowerCAmelCase_    ):
																raise ValueError(F'''Training input {text_b} is not a string'''    )
													if not isinstance(lowerCAmelCase_       ,		lowerCAmelCase_    ):
																raise ValueError(F'''Training label {label} is not a string'''    )
													examples.append(InputExample(guid=lowerCAmelCase_       ,		text_a=lowerCAmelCase_       ,		text_b=lowerCAmelCase_       ,		label=lowerCAmelCase_    )    )
										return examples






							def  UpperCamelCase__			(	self       ,		lowerCAmelCase__    ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_						:			List[str]       						= self._read_tsv(os.path.join(lowerCAmelCase_       ,		'XNLI-1.0/xnli.test.tsv'    )    )
										SCREAMING_SNAKE_CASE_						:			Optional[int]       						= []
										for i, line in enumerate(lowerCAmelCase_    ):
													if i == 0:
																continue
													SCREAMING_SNAKE_CASE_						:			List[Any]       						= line[0]
													if language != self.language:
																continue
													SCREAMING_SNAKE_CASE_						:			Dict       						= F'''test-{i}'''
													SCREAMING_SNAKE_CASE_						:			Dict       						= line[6]
													SCREAMING_SNAKE_CASE_						:			str       						= line[7]
													SCREAMING_SNAKE_CASE_						:			Tuple       						= line[1]
													if not isinstance(lowerCAmelCase_       ,		lowerCAmelCase_    ):
																raise ValueError(F'''Training input {text_a} is not a string'''    )
													if not isinstance(lowerCAmelCase_       ,		lowerCAmelCase_    ):
																raise ValueError(F'''Training input {text_b} is not a string'''    )
													if not isinstance(lowerCAmelCase_       ,		lowerCAmelCase_    ):
																raise ValueError(F'''Training label {label} is not a string'''    )
													examples.append(InputExample(guid=lowerCAmelCase_       ,		text_a=lowerCAmelCase_       ,		text_b=lowerCAmelCase_       ,		label=lowerCAmelCase_    )    )
										return examples






							def  UpperCamelCase__			(	self    ):





										"""simple docstring"""




										return ["contradiction", "entailment", "neutral"]







lowerCAmelCase__       :	Tuple     				={
    'xnli': XnliProcessor,
}

lowerCAmelCase__       :	str     				={
    'xnli': 'classification',
}

lowerCAmelCase__       :	Union[str, Any]     				={
    'xnli': 3,
}











'''simple docstring'''


from dataclasses import dataclass
from typing import Callable, Optional

import datasets

@dataclass
class 			A    (		datasets.BuilderConfig    ):
							lowercase_							=				None
							lowercase_							=				None
							lowercase_							=				None







							def    __lowerCAmelCase			(  self       :  Dict					)			->							List[str]:


														"""simple docstring"""


														assert self.generator is not None, "generator must be specified"

														if self.gen_kwargs is None:
																					_a	     =				{}



class 			A    (		datasets.GeneratorBasedBuilder    ):
							lowercase_							=				GeneratorConfig







							def    __lowerCAmelCase			(  self       :  Any					)			->							List[str]:


														"""simple docstring"""


														return datasets.DatasetInfo(features=self.config.features					)







							def    __lowerCAmelCase			(  self       :  Dict							,			lowerCAmelCase_       :  Optional[int]					)			->							Optional[Any]:


														"""simple docstring"""


														return [datasets.SplitGenerator(name=datasets.Split.TRAIN							,			gen_kwargs=self.config.gen_kwargs					)]







							def    __lowerCAmelCase			(  self       :  str							,			**lowerCAmelCase_       :  int					)			->							List[str]:


														"""simple docstring"""


														for idx, ex in enumerate(self.config.generator(**lowerCAmelCase_					)					):
																					yield idx, ex

