Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/evaluation/wordsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def get_wordsim_scores(language, word2id, embeddings, lower=True):

def get_wordanalogy_scores(language, word2id, embeddings, lower=True):
"""
Return (english) word analogy score
Return monolingual word analogy scores.
"""
dirpath = os.path.join(MONOLINGUAL_EVAL_PATH, language)
if not os.path.isdir(dirpath) or language not in ["en"]:
filepath = os.path.join(MONOLINGUAL_EVAL_PATH, language, 'questions-words.txt')
if not os.path.exists(filepath):
return None

# normalize word embeddings
Expand All @@ -127,7 +127,7 @@ def get_wordanalogy_scores(language, word2id, embeddings, lower=True):
word_ids = {}
queries = {}

with io.open(os.path.join(dirpath, 'questions-words.txt'), 'r', encoding='utf-8') as f:
with io.open(filepath, 'r', encoding='utf-8') as f:
for line in f:
# new line
line = line.rstrip()
Expand Down