[docs]classControlDataset(AbstractTEDataset):def__init__(self,split_set:str)->None:""" The function takes in a string as an argument and returns None. The function first checks if the string is in the list of split sets. If it is not, it raises an error. If the string is in the list of split sets, the function checks if the control dataset folder exists. If it does not, it downloads the dataset. The function then sets the split set to the string that was passed in as an argument. The function then sets the dataset path to the control dataset folder and the split set. The function then reads the dataset and sets the premises, hypotheses, and labels to the read dataset. If there is an error, the function prints the error message. :param split_set: str :type split_set: str """super().__init__()try:ifsplit_setnotinSPLIT_SETS:raiseSplitSetError(SPLIT_SETS)ifnotos.path.exists(CONTROL_DATASET_FOLDER):download_dataset(CONTROL_DATASET_ZIP_URL,CONTROL_DATASET)self.split_set=split_setself.dataset_path=f"{CONTROL_DATASET_FOLDER}/{self.split_set}.jsonl"self.premises,self.hypotheses,self.labels=self.__read_dataset("premise","hypothesis","label")exceptSplitSetErroraserr:print(err.message)def__read_dataset(self,premises_key:str,hypotheses_key:str,labels_key:str)->Tuple[List[str],List[str],List[int]]:""" It reads a jsonl file and returns a tuple of lists of strings and integers :param premises_key: str, hypotheses_key: str, labels_key: str :type premises_key: str :param hypotheses_key: str = "hypothesis" :type hypotheses_key: str :param labels_key: str = "label" :type labels_key: str :return: A tuple of lists of strings and integers. """data=read_jsonl(self.dataset_path)premises_list=[]hypotheses_list=[]labels_list=[]foriindata:premises_list.append(str(i[premises_key]))hypotheses_list.append(str(i[hypotheses_key]))labels_list.append(CONTROL_LABEL_TO_ID[str(i[labels_key])])returnpremises_list,hypotheses_list,labels_listdef__getitem__(self,index:int)->Tuple[str,str,int]:""" This function returns the premise, hypothesis, and label of the index of the dataset :param index: The index of the data point you want to access :type index: int :return: The premise, hypothesis, and label for the given index. """returnself.premises[index],self.hypotheses[index],self.labels[index]def__str__(self)->str:""" This function returns a string that describes the split set of ConTRoL and the number of instances in the split set :return: The number of instances in the split set. """returnf"The {self.split_set} set of ConTRoL has {self.__len__()} instances"def__len__(self)->int:""" This function returns the length of the premises list :return: The length of the premises. """returnlen(self.premises)