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
ModelZoo
ResNet50_tensorflow
Commits
91e2171b
Commit
91e2171b
authored
Jun 29, 2020
by
Chen Chen
Committed by
A. Unique TensorFlower
Jun 29, 2020
Browse files
Internal Change
PiperOrigin-RevId: 318942343
parent
e30aa7d8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
official/nlp/data/tagging_data_lib.py
official/nlp/data/tagging_data_lib.py
+3
-4
No files found.
official/nlp/data/tagging_data_lib.py
View file @
91e2171b
...
@@ -148,6 +148,9 @@ def _tokenize_example(example, max_length, tokenizer, text_preprocessing=None):
...
@@ -148,6 +148,9 @@ def _tokenize_example(example, max_length, tokenizer, text_preprocessing=None):
new_examples
=
[]
new_examples
=
[]
new_example
=
InputExample
(
sentence_id
=
example
.
sentence_id
)
new_example
=
InputExample
(
sentence_id
=
example
.
sentence_id
)
for
i
,
word
in
enumerate
(
example
.
words
):
for
i
,
word
in
enumerate
(
example
.
words
):
if
any
([
x
<
0
for
x
in
example
.
label_ids
]):
raise
ValueError
(
"Unexpected negative label_id: %s"
%
example
.
label_ids
)
if
text_preprocessing
:
if
text_preprocessing
:
word
=
text_preprocessing
(
word
)
word
=
text_preprocessing
(
word
)
subwords
=
tokenizer
.
tokenize
(
word
)
subwords
=
tokenizer
.
tokenize
(
word
)
...
@@ -177,11 +180,7 @@ def _convert_single_example(example, max_seq_length, tokenizer):
...
@@ -177,11 +180,7 @@ def _convert_single_example(example, max_seq_length, tokenizer):
tokens
.
extend
(
example
.
words
)
tokens
.
extend
(
example
.
words
)
tokens
.
append
(
"[SEP]"
)
tokens
.
append
(
"[SEP]"
)
input_ids
=
tokenizer
.
convert_tokens_to_ids
(
tokens
)
input_ids
=
tokenizer
.
convert_tokens_to_ids
(
tokens
)
label_ids
=
[
_PADDING_LABEL_ID
]
label_ids
=
[
_PADDING_LABEL_ID
]
if
any
([
x
<
0
for
x
in
example
.
label_ids
]):
raise
ValueError
(
"Unexpected negative label_id: %s"
%
example
.
label_ids
)
label_ids
.
extend
(
example
.
label_ids
)
label_ids
.
extend
(
example
.
label_ids
)
label_ids
.
append
(
_PADDING_LABEL_ID
)
label_ids
.
append
(
_PADDING_LABEL_ID
)
...
...
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