# Path: third_party/processors/utils.py
# class InputExample(object):
#   """
#   A single training/test example for simple sequence classification.
#   Args:
#     guid: Unique id for the example.
#     text_a: string. The untokenized text of the first sequence. For single
#     sequence tasks, only this sequence must be specified.
#     text_b: (Optional) string. The untokenized text of the second sequence.
#     Only must be specified for sequence pair tasks.
#     label: (Optional) string. The label of the example. This should be
#     specified for train and dev examples, but not for test examples.
#   """
# 
#   def __init__(self, guid, text_a, text_b=None, label=None, language=None):
#     self.guid = guid
#     self.text_a = text_a
#     self.text_b = text_b
#     self.label = label
#     self.language = language
# 
#   def __repr__(self):
#     return str(self.to_json_string())
# 
#   def to_dict(self):
#     """Serializes this instance to a Python dictionary."""
#     output = copy.deepcopy(self.__dict__)
#     return output
# 
#   def to_json_string(self):
#     """Serializes this instance to a JSON string."""
#     return json.dumps(self.to_dict(), indent=2, sort_keys=True) + "\n"


import logging
import os
from transformers import DataProcessor
from .utils import InputExample
          if split == 'test' and len(line) != 3:
            label = "neutral"
          else:
            label = str(line[2].strip())
          assert isinstance(text_a, str) and isinstance(text_b, str) and isinstance(label, str)
          examples.append(InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label, language=lg))
      return examples

    def get_train_examples(self, data_dir, language='en'):
        return self.get_examples(data_dir, language, split='train')

    def get_dev_examples(self, data_dir, language='en'):
        return self.get_examples(data_dir, language, split='dev')

    def get_test_examples(self, data_dir, language='en'):
        return self.get_examples(data_dir, language, split='test')

    def get_translate_train_examples(self, data_dir, language='en'):
        """See base class."""
        examples = []
        for lg in language.split(','):
            file_path = os.path.join(data_dir, "XNLI-Translated/en-{}-translated.tsv".format(lg))
            logger.info("reading file from " + file_path)
            lines = self._read_tsv(file_path)
            for (i, line) in enumerate(lines):
                guid = "%s-%s-%s" % ("translate-train", lg, i)
                text_a = line[0]
                text_b = line[1]
                label = "contradiction" if line[2].strip() == "contradictory" else line[2].strip()
                assert isinstance(text_a, str) and isinstance(text_b, str) and isinstance(label, str)

# Path: third_party/processors/utils.py
# class InputExample(object):
#   """
#   A single training/test example for simple sequence classification.
#   Args:
#     guid: Unique id for the example.
#     text_a: string. The untokenized text of the first sequence. For single
#     sequence tasks, only this sequence must be specified.
#     text_b: (Optional) string. The untokenized text of the second sequence.
#     Only must be specified for sequence pair tasks.
#     label: (Optional) string. The label of the example. This should be
#     specified for train and dev examples, but not for test examples.
#   """
# 
#   def __init__(self, guid, text_a, text_b=None, label=None, language=None):
#     self.guid = guid
#     self.text_a = text_a
#     self.text_b = text_b
#     self.label = label
#     self.language = language
# 
#   def __repr__(self):
#     return str(self.to_json_string())
# 
#   def to_dict(self):
#     """Serializes this instance to a Python dictionary."""
#     output = copy.deepcopy(self.__dict__)
#     return output
# 
#   def to_json_string(self):
#     """Serializes this instance to a JSON string."""
#     return json.dumps(self.to_dict(), indent=2, sort_keys=True) + "\n"


# Path: third_party/processors/xnli.py
import logging
import os
from transformers import DataProcessor
from .utils import InputExample

          if split == 'test' and len(line) != 3:
            label = "neutral"
          else:
            label = str(line[2].strip())
          assert isinstance(text_a, str) and isinstance(text_b, str) and isinstance(label, str)
          examples.append(InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label, language=lg))
      return examples

    def get_train_examples(self, data_dir, language='en'):
        return self.get_examples(data_dir, language, split='train')

    def get_dev_examples(self, data_dir, language='en'):
        return self.get_examples(data_dir, language, split='dev')

    def get_test_examples(self, data_dir, language='en'):
        return self.get_examples(data_dir, language, split='test')

    def get_translate_train_examples(self, data_dir, language='en'):
        """See base class."""
        examples = []
        for lg in language.split(','):
            file_path = os.path.join(data_dir, "XNLI-Translated/en-{}-translated.tsv".format(lg))
            logger.info("reading file from " + file_path)
            lines = self._read_tsv(file_path)
            for (i, line) in enumerate(lines):
                guid = "%s-%s-%s" % ("translate-train", lg, i)
                text_a = line[0]
                text_b = line[1]
                label = "contradiction" if line[2].strip() == "contradictory" else line[2].strip()
                assert isinstance(text_a, str) and isinstance(text_b, str) and isinstance(label, str)

                examples.append(InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label, language=lg))