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
5622d832
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "ad39271ae8518afaa4c4831bd1ddccc3bc86eab6"
Commit
5622d832
authored
Nov 05, 2018
by
thomwolf
Browse files
allowing to load small number of examples
parent
a725db4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
tensorflow_code/run_squad.py
tensorflow_code/run_squad.py
+3
-1
No files found.
tensorflow_code/run_squad.py
View file @
5622d832
...
@@ -207,7 +207,7 @@ class InputFeatures(object):
...
@@ -207,7 +207,7 @@ class InputFeatures(object):
self
.
end_position
=
end_position
self
.
end_position
=
end_position
def
read_squad_examples
(
input_file
,
is_training
):
def
read_squad_examples
(
input_file
,
is_training
,
max_num
=-
1
):
"""Read a SQuAD json file into a list of SquadExample."""
"""Read a SQuAD json file into a list of SquadExample."""
with
tf
.
gfile
.
Open
(
input_file
,
"r"
)
as
reader
:
with
tf
.
gfile
.
Open
(
input_file
,
"r"
)
as
reader
:
input_data
=
json
.
load
(
reader
)[
"data"
]
input_data
=
json
.
load
(
reader
)[
"data"
]
...
@@ -219,6 +219,8 @@ def read_squad_examples(input_file, is_training):
...
@@ -219,6 +219,8 @@ def read_squad_examples(input_file, is_training):
examples
=
[]
examples
=
[]
for
entry
in
input_data
:
for
entry
in
input_data
:
if
max_num
!=
-
1
and
len
(
examples
)
>
max_num
:
break
for
paragraph
in
entry
[
"paragraphs"
]:
for
paragraph
in
entry
[
"paragraphs"
]:
paragraph_text
=
paragraph
[
"context"
]
paragraph_text
=
paragraph
[
"context"
]
doc_tokens
=
[]
doc_tokens
=
[]
...
...
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