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
90c83387
Unverified
Commit
90c83387
authored
Jun 17, 2020
by
Sam Shleifer
Committed by
GitHub
Jun 17, 2020
Browse files
[MarianTokenizer] Switch to sacremoses for punc normalization (#5092)
parent
049e14f0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/transformers/tokenization_marian.py
src/transformers/tokenization_marian.py
+4
-4
No files found.
src/transformers/tokenization_marian.py
View file @
90c83387
...
@@ -82,11 +82,11 @@ class MarianTokenizer(PreTrainedTokenizer):
...
@@ -82,11 +82,11 @@ class MarianTokenizer(PreTrainedTokenizer):
def
_setup_normalizer
(
self
):
def
_setup_normalizer
(
self
):
try
:
try
:
from
moses
tokenizer
import
MosesPunct
uation
Normalizer
from
sacre
moses
import
MosesPunctNormalizer
self
.
punc_normalizer
=
MosesPunct
uation
Normalizer
(
self
.
source_lang
)
self
.
punc_normalizer
=
MosesPunctNormalizer
(
self
.
source_lang
)
.
normalize
except
ImportError
:
except
(
ImportError
,
FileNotFoundError
)
:
warnings
.
warn
(
"Recommended: pip install
mosestokenizer
"
)
warnings
.
warn
(
"Recommended: pip install
sacremoses.
"
)
self
.
punc_normalizer
=
lambda
x
:
x
self
.
punc_normalizer
=
lambda
x
:
x
def
normalize
(
self
,
x
:
str
)
->
str
:
def
normalize
(
self
,
x
:
str
)
->
str
:
...
...
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