text: # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  import numpy as np
  import os
  import unittest
  from paddlenlp.datasets import load_dataset
  
  import sys
  sys.path.append(os.pardir)
  
  from common_test import CpuCommonTest
  import util
  import unittest
  
  
  def get_examples(mode='train'):
      """
      dataset[0][0] examples
      """
      examples = {
          'train':
          ({'text_a': '你知道在这个季节,我猜在你的水平你把他们丢到下一个水平,如果他们决定召回的家长队,勇士队决定打电话召回一个家伙从三个 a ,然后一个双人上去.取代他和一个男人去取代他', 'text_b': '如果人们记得的话,你就会把事情弄丢了.', 'label': 1}),
      }
      return examples[mode]
  
  class TestXnli_CN(CpuCommonTest):
      """
      clue tnews case
      """
      def setUp(self):
          """
          check input params & datasets all flies
          """
          self.config['path_or_read_func'] = 'xnli_cn'
          self.config['splits'] = ['train', 'dev','test']
  
      def test_train_set(self):
          """
          check train.json length, label,premise, hypothesis
          """
          expected_ds_num = 3
          expected_len = 392701
          expected_train= get_examples('train')
          ds = load_dataset(**self.config)
          self.check_output_equal(len(ds), expected_ds_num)
          self.check_output_equal(len(ds[0]), expected_len)
  
          self.check_output_equal(expected_train['text_a'], ds[0][0]['text_a'])
          self.check_output_equal(expected_train['text_b'], ds[0][0]['text_b'])
          self.check_output_equal(expected_train['label'], ds[0][0]['label'])
  
  
  class TestXnliCNNoSplitDataFiles(CpuCommonTest):
      """
      check no splits 
      """
      def setUp(self):
          self.config['path_or_read_func'] = 'xnli_cn'
  
      @util.assert_raises
      def test_no_split_datafiles(self):
          load_dataset(**self.config)
  
  
  if __name__ == "__main__":
      unittest.main()
  