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
OpenDAS
Fairseq
Commits
d85b61d6
Commit
d85b61d6
authored
May 01, 2018
by
Angela Fan
Committed by
Myle Ott
Jun 15, 2018
Browse files
fix to adding tokens to dictionary while thresholding
parent
7f538f54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
fairseq/dictionary.py
fairseq/dictionary.py
+9
-9
No files found.
fairseq/dictionary.py
View file @
d85b61d6
...
...
@@ -96,14 +96,6 @@ class Dictionary(object):
if
nwords
==
-
1
:
nwords
=
len
(
self
)
if
padding_factor
>
1
:
i
=
0
while
nwords
%
padding_factor
!=
0
:
if
nwords
>=
len
(
self
):
self
.
add_symbol
(
'madeupword{:04d}'
.
format
(
i
))
i
+=
1
nwords
+=
1
new_symbols
=
self
.
symbols
[:
self
.
nspecial
]
new_count
=
self
.
count
[:
self
.
nspecial
]
...
...
@@ -114,8 +106,16 @@ class Dictionary(object):
new_count
.
append
(
count
)
else
:
break
threshold_nwords
=
len
(
new_symbols
)
if
padding_factor
>
1
:
i
=
0
while
threshold_nwords
%
padding_factor
!=
0
:
new_symbols
.
append
(
'madeupword{:04d}'
.
format
(
i
))
i
+=
1
threshold_nwords
+=
1
assert
min
(
new_count
[
self
.
nspecial
:])
>=
threshold
assert
len
(
new_symbols
)
<=
nwords
assert
len
(
new_symbols
)
%
padding_factor
==
0
self
.
count
=
tuple
(
new_count
)
...
...
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