From ca4ad7deb88bf20a19ec4889cdf1db5ba22a573b Mon Sep 17 00:00:00 2001 From: Kevin Arvai Date: Tue, 5 Jan 2021 15:51:54 -0500 Subject: [PATCH 1/2] update phenopy api --- txt2hpo/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 21fd9297804cce285e57da01b9a473fac098134e Mon Sep 17 00:00:00 2001 From: Kevin Arvai Date: Wed, 6 Jan 2021 12:31:37 -0500 Subject: [PATCH 2/2] handle gensim 3.8 and 4.0 --- txt2hpo/nlp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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']