Unverified Commit 708ffff6 authored by Midhun R Nair's avatar Midhun R Nair Committed by GitHub
Browse files

Raise exceptions instead of asserts in xnli.py (#13945)

parent e1bb2ebd
......@@ -47,9 +47,12 @@ class XnliProcessor(DataProcessor):
text_a = line[0]
text_b = line[1]
label = "contradiction" if line[2] == "contradictory" else line[2]
assert isinstance(text_a, str), f"Training input {text_a} is not a string"
assert isinstance(text_b, str), f"Training input {text_b} is not a string"
assert isinstance(label, str), f"Training label {label} is not a string"
if not isinstance(text_a, str):
raise ValueError(f"Training input {text_a} is not a string")
if not isinstance(text_b, str):
raise ValueError(f"Training input {text_b} is not a string")
if not isinstance(label, str):
raise ValueError(f"Training label {label} is not a string")
examples.append(InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label))
return examples
......@@ -67,9 +70,12 @@ class XnliProcessor(DataProcessor):
text_a = line[6]
text_b = line[7]
label = line[1]
assert isinstance(text_a, str), f"Training input {text_a} is not a string"
assert isinstance(text_b, str), f"Training input {text_b} is not a string"
assert isinstance(label, str), f"Training label {label} is not a string"
if not isinstance(text_a, str):
raise ValueError(f"Training input {text_a} is not a string")
if not isinstance(text_b, str):
raise ValueError(f"Training input {text_b} is not a string")
if not isinstance(label, str):
raise ValueError(f"Training label {label} is not a string")
examples.append(InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label))
return examples
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment