Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Fix a bug when using official GLoVE embedding.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinytangent authored and xuehui1991 committed Sep 14, 2018
1 parent fb08ee5 commit 45650c4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/trials/ga_squad/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 45650c4

Please sign in to comment.