Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
45650c41
Commit
45650c41
authored
Sep 14, 2018
by
Sinan Tan
Committed by
xuehui
Sep 14, 2018
Browse files
Fix a bug when using official GLoVE embedding.
parent
fb08ee59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
examples/trials/ga_squad/trial.py
examples/trials/ga_squad/trial.py
+3
-1
No files found.
examples/trials/ga_squad/trial.py
View file @
45650c41
...
...
@@ -88,11 +88,13 @@ def load_embedding(path):
'''
return embedding for a specif file by given file path.
'''
EMBEDDING_DIM
=
300
embedding_dict
=
{}
with
open
(
path
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
pairs
=
[
line
.
strip
(
'
\r\n
'
).
split
()
for
line
in
file
.
readlines
()]
for
pair
in
pairs
:
embedding_dict
[
pair
[
0
]]
=
[
float
(
x
)
for
x
in
pair
[
1
:]]
if
len
(
pair
)
==
EMBEDDING_DIM
+
1
:
embedding_dict
[
pair
[
0
]]
=
[
float
(
x
)
for
x
in
pair
[
1
:]]
logger
.
debug
(
'embedding_dict size: %d'
,
len
(
embedding_dict
))
return
embedding_dict
...
...
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