Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
708ffff6
Unverified
Commit
708ffff6
authored
Oct 11, 2021
by
Midhun R Nair
Committed by
GitHub
Oct 11, 2021
Browse files
Raise exceptions instead of asserts in xnli.py (#13945)
parent
e1bb2ebd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
src/transformers/data/processors/xnli.py
src/transformers/data/processors/xnli.py
+12
-6
No files found.
src/transformers/data/processors/xnli.py
View file @
708ffff6
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment