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
aa2a2c65
Unverified
Commit
aa2a2c65
authored
Nov 12, 2020
by
Beomsoo Kim
Committed by
GitHub
Nov 11, 2020
Browse files
Replaced some iadd operations on lists with proper list methods. (#8433)
parent
026a2ff2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
src/transformers/tokenization_utils.py
src/transformers/tokenization_utils.py
+7
-7
No files found.
src/transformers/tokenization_utils.py
View file @
aa2a2c65
...
@@ -291,7 +291,7 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
...
@@ -291,7 +291,7 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
full_word
+=
sub_text
+
tok
full_word
+=
sub_text
+
tok
elif
full_word
:
elif
full_word
:
full_word
+=
sub_text
full_word
+=
sub_text
result
+=
[
full_word
]
result
.
append
(
full_word
)
full_word
=
""
full_word
=
""
continue
continue
# Strip white spaces on the right
# Strip white spaces on the right
...
@@ -310,16 +310,16 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
...
@@ -310,16 +310,16 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
sub_text
=
sub_text
.
lstrip
()
sub_text
=
sub_text
.
lstrip
()
if
i
==
0
and
not
sub_text
:
if
i
==
0
and
not
sub_text
:
result
+=
[
tok
]
result
.
append
(
tok
)
elif
i
==
len
(
split_text
)
-
1
:
elif
i
==
len
(
split_text
)
-
1
:
if
sub_text
:
if
sub_text
:
result
+=
[
sub_text
]
result
.
append
(
sub_text
)
else
:
else
:
pass
pass
else
:
else
:
if
sub_text
:
if
sub_text
:
result
+=
[
sub_text
]
result
.
append
(
sub_text
)
result
+=
[
tok
]
result
.
append
(
tok
)
return
result
return
result
def
split_on_tokens
(
tok_list
,
text
):
def
split_on_tokens
(
tok_list
,
text
):
...
@@ -334,9 +334,9 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
...
@@ -334,9 +334,9 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
tokenized_text
=
[]
tokenized_text
=
[]
for
sub_text
in
text_list
:
for
sub_text
in
text_list
:
if
sub_text
not
in
self
.
unique_no_split_tokens
:
if
sub_text
not
in
self
.
unique_no_split_tokens
:
tokenized_text
+=
split_on_token
(
tok
,
sub_text
)
tokenized_text
.
extend
(
split_on_token
(
tok
,
sub_text
)
)
else
:
else
:
tokenized_text
+=
[
sub_text
]
tokenized_text
.
append
(
sub_text
)
text_list
=
tokenized_text
text_list
=
tokenized_text
return
list
(
return
list
(
...
...
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