Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
f671997e
Commit
f671997e
authored
Nov 28, 2019
by
Lysandre
Browse files
Interface with TFDS
parent
bd41e829
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
transformers/data/processors/squad.py
transformers/data/processors/squad.py
+12
-4
No files found.
transformers/data/processors/squad.py
View file @
f671997e
...
...
@@ -246,16 +246,24 @@ class SquadProcessor(DataProcessor):
dev_file
=
None
def
get_example_from_tensor_dict
(
self
,
tensor_dict
):
"""See base class."""
return
NewSquadExample
(
tensor_dict
[
'id'
].
numpy
(),
tensor_dict
[
'id'
].
numpy
()
.
decode
(
"utf-8"
)
,
tensor_dict
[
'question'
].
numpy
().
decode
(
'utf-8'
),
tensor_dict
[
'context'
].
numpy
().
decode
(
'utf-8'
),
tensor_dict
[
'answers'
][
'text'
].
numpy
().
decode
(
'utf-8'
),
tensor_dict
[
'answers'
][
'answer
s
_start'
].
numpy
()
.
decode
(
'utf-8'
)
,
tensor_dict
[
'answers'
][
'text'
]
[
0
]
.
numpy
().
decode
(
'utf-8'
),
tensor_dict
[
'answers'
][
'answer_start'
]
[
0
]
.
numpy
(),
tensor_dict
[
'title'
].
numpy
().
decode
(
'utf-8'
)
)
def
get_examples_from_dataset
(
self
,
dataset
):
"""See base class."""
examples
=
[]
for
tensor_dict
in
tqdm
(
dataset
):
examples
.
append
(
self
.
get_example_from_tensor_dict
(
tensor_dict
))
return
examples
def
get_train_examples
(
self
,
data_dir
,
only_first
=
None
):
"""See base class."""
if
self
.
train_file
is
None
:
...
...
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