Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LeveshteinSimilarityIndex fails when called from SparseTermSimilarityMatrix #2688

Closed
ptorrestr opened this issue Nov 27, 2019 · 0 comments · Fixed by #2689
Closed

LeveshteinSimilarityIndex fails when called from SparseTermSimilarityMatrix #2688

ptorrestr opened this issue Nov 27, 2019 · 0 comments · Fixed by #2689

Comments

@ptorrestr
Copy link
Contributor

Problem description

When trying to build a SparseTermSimilarityMatrix using Levenshtein it fails.

Steps/code/corpus to reproduce

index = LevenshteinSimilarityIndex(dictionary)
SparseTermSimilarityMatrix(index, dictionary) # <- fails here
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-59-c16b89564835> in <module>
----> 1 similarity_matrix1 = SparseTermSimilarityMatrix(similarity_index1, dictionary)

~/.local/share/virtualenvs/pdftagger-LHy_2RHk/lib/python3.6/site-packages/gensim/similarities/termsim.py in __init__(self, source, dictionary, tfidf, symmetric, positive_definite, nonzero_limit, dtype)
    234                 for term, similarity in index.most_similar(t1, topn=num_rows)
    235                 if term in dictionary.token2id
--> 236             ] if num_rows > 0 else []
    237 
    238             if tfidf is None:

~/.local/share/virtualenvs/pdftagger-LHy_2RHk/lib/python3.6/site-packages/gensim/similarities/levenshtein.py in most_similar(self, t1, topn)
    151             if similarity > 0
    152         )
--> 153         return islice(most_similar, topn)

ValueError: Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.

Versions

Linux-4.18.0-25-generic-x86_64-with-debian-buster-sid
Python 3.6.9 (default, Nov 18 2019, 15:20:23)
[GCC 8.3.0]
NumPy 1.17.4
SciPy 1.3.3
gensim 3.8.1
FAST_VERSION 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant