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
cf32b2ee
Unverified
Commit
cf32b2ee
authored
Jul 27, 2022
by
Sylvain Gugger
Committed by
GitHub
Jul 27, 2022
Browse files
Remove all uses of six (#18318)
* Remove all uses of six * fix quality
parent
170fcaa6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
24 deletions
+11
-24
examples/research_projects/tapex/wikisql_utils.py
examples/research_projects/tapex/wikisql_utils.py
+1
-3
src/transformers/models/deberta_v2/tokenization_deberta_v2.py
...transformers/models/deberta_v2/tokenization_deberta_v2.py
+5
-14
src/transformers/models/flaubert/tokenization_flaubert.py
src/transformers/models/flaubert/tokenization_flaubert.py
+5
-7
No files found.
examples/research_projects/tapex/wikisql_utils.py
View file @
cf32b2ee
...
...
@@ -23,8 +23,6 @@ import re
# Original: https://github.com/google-research/tapas/master/wikisql_utils.py
from
typing
import
Any
,
List
,
Text
import
six
EMPTY_ANSWER
=
"none"
EMPTY_ANSWER_AGG
=
"none"
...
...
@@ -49,7 +47,7 @@ def convert_to_float(value):
return
value
if
isinstance
(
value
,
int
):
return
float
(
value
)
if
not
isinstance
(
value
,
s
ix
.
string_types
):
if
not
isinstance
(
value
,
s
tr
):
raise
ValueError
(
"Argument value is not a string. Can't parse it as float"
)
sanitized
=
value
...
...
src/transformers/models/deberta_v2/tokenization_deberta_v2.py
View file @
cf32b2ee
...
...
@@ -19,7 +19,6 @@ import unicodedata
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Tuple
import
sentencepiece
as
sp
import
six
from
...tokenization_utils
import
PreTrainedTokenizer
...
...
@@ -523,17 +522,9 @@ def _is_punctuation(char):
def
convert_to_unicode
(
text
):
"""Converts `text` to Unicode (if it's not already), assuming utf-8 input."""
if
six
.
PY3
:
if
isinstance
(
text
,
str
):
return
text
elif
isinstance
(
text
,
bytes
):
return
text
.
decode
(
"utf-8"
,
"ignore"
)
else
:
raise
ValueError
(
f
"Unsupported string type:
{
type
(
text
)
}
"
)
elif
six
.
PY2
:
if
isinstance
(
text
,
str
):
return
text
.
decode
(
"utf-8"
,
"ignore"
)
else
:
raise
ValueError
(
f
"Unsupported string type:
{
type
(
text
)
}
"
)
else
:
raise
ValueError
(
"Not running on Python2 or Python 3?"
)
src/transformers/models/flaubert/tokenization_flaubert.py
View file @
cf32b2ee
...
...
@@ -17,8 +17,6 @@
import
unicodedata
import
six
from
...utils
import
logging
from
..xlm.tokenization_xlm
import
XLMTokenizer
...
...
@@ -76,16 +74,16 @@ def convert_to_unicode(text):
"""
Converts `text` to Unicode (if it's not already), assuming UTF-8 input.
"""
# six_ensure_text is copied from https://github.com/benjaminp/six
def
six_
ensure_text
(
s
,
encoding
=
"utf-8"
,
errors
=
"strict"
):
if
isinstance
(
s
,
six
.
binary_type
):
def
ensure_text
(
s
,
encoding
=
"utf-8"
,
errors
=
"strict"
):
if
isinstance
(
s
,
bytes
):
return
s
.
decode
(
encoding
,
errors
)
elif
isinstance
(
s
,
s
ix
.
text_type
):
elif
isinstance
(
s
,
s
tr
):
return
s
else
:
raise
TypeError
(
f
"not expecting type '
{
type
(
s
)
}
'"
)
return
six_
ensure_text
(
text
,
encoding
=
"utf-8"
,
errors
=
"ignore"
)
return
ensure_text
(
text
,
encoding
=
"utf-8"
,
errors
=
"ignore"
)
class
FlaubertTokenizer
(
XLMTokenizer
):
...
...
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