Skip to content

Commit

Permalink
fixed bug of connector_words not loading, while loading saved phrases…
Browse files Browse the repository at this point in the history
… model of version >= 4
  • Loading branch information
aloknayak29 committed Apr 14, 2021
1 parent 9f2a4ac commit 39f9350
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions gensim/models/phrases.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,16 @@ def load(cls, *args, **kwargs):
raise ValueError(f'failed to load {cls.__name__} model, unknown scoring "{model.scoring}"')

# common_terms didn't exist pre-3.?, and was renamed to connector in 4.0.0.
if hasattr(model, "common_terms"):
model.connector_words = model.common_terms
del model.common_terms
else:
logger.warning(
'older version of %s loaded without common_terms attribute, setting connector_words to an empty set',
cls.__name__,
)
model.connector_words = frozenset()
if not hasattr(model, "connector_words"):
if hasattr(model, "common_terms"):
model.connector_words = model.common_terms
del model.common_terms
else:
logger.warning(
'older version of %s loaded without common_terms attribute, setting connector_words to an empty set',
cls.__name__,
)
model.connector_words = frozenset()

if not hasattr(model, 'corpus_word_count'):
logger.warning('older version of %s loaded without corpus_word_count', cls.__name__)
Expand Down

0 comments on commit 39f9350

Please sign in to comment.