diff --git a/txt2hpo/nlp.py b/txt2hpo/nlp.py index a4bc131..a2288f4 100644 --- a/txt2hpo/nlp.py +++ b/txt2hpo/nlp.py @@ -72,7 +72,12 @@ def similarity_term_to_context(term, context, model): :return: float """ def remove_out_of_vocab(tokens): - return [x for x in tokens if x in model.key_to_index] + try: + # gensim 3.8 + return [x for x in tokens if x in model.vocab] + except AttributeError: + # gensim 4.0 + return [x for x in tokens if x in model.wv.key_to_index] hpo_term = hpo_network.nodes[term] hpo_term_definition = hpo_term['name'] diff --git a/txt2hpo/util.py b/txt2hpo/util.py index 4d47310..f0b0925 100644 --- a/txt2hpo/util.py +++ b/txt2hpo/util.py @@ -2,7 +2,7 @@ import math from phenopy.config import config as phenopy_config -from phenopy import generate_annotated_hpo_network +from phenopy.build_hpo import generate_annotated_hpo_network import sys import subprocess