mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Raise exceptions instead of asserts in xnli.py (#13945)
This commit is contained in:
parent
e1bb2ebd92
commit
708ffff665
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user