MCPcopy Create free account
hub / github.com/OpenBMB/DecT / SnliProcessor

Class SnliProcessor

src/process_data.py:234–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232
233
234class SnliProcessor(DataProcessor):
235 dataset_project = {"train": "snli_1.0_train",
236 "dev": "snli_1.0_train",
237 "test": "snli_1.0_dev"
238 }
239 def __init__(self):
240 super().__init__()
241 self.labels = ["contradiction", "entailment", "neutral"]
242
243 def get_examples(self, data_dir, split):
244 path = os.path.join(data_dir, "{}.jsonl".format(self.dataset_project[split]))
245 examples = []
246 with open(path)as f:
247 lines = f.readlines()
248 for idx, line in enumerate(lines):
249 data = json.loads(line)
250 text_a = data["sentence1"]
251 text_b = data["sentence2"]
252 if data["gold_label"] not in self.labels:
253 continue
254 label = self.get_label_id(data["gold_label"])
255 example = InputExample(
256 guid=str(idx), text_a=text_a, text_b=text_b, label=label)
257 examples.append(example)
258 return examples
259
260class YelpProcessor(DataProcessor):
261 dataset_project = {"train": "train",

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected