I am facing a weird problem whenever I try to use a saved soft cosine similarity object in a python project. The structure of the project is as below (names in blue are directories):
The contents of test.py file are as below, which returns a list of dictionaries containing document number as 'keys' and their similarity probability as 'value':
Traceback (most recent call last):
File "test.py", line 55, in <module>
r = gen_search_results("textile dyeing")
File "test.py", line 37, in gen_search_results
cos_sim = softcossim(query)
File "test.py", line 28, in softcossim
similarities = docsim_index[query]
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/gensim/interfaces.py", line 340, in __getitem__
result = self.get_similarities(query)
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/gensim/similarities/docsim.py", line 981, in get_similarities
result = self.similarity_matrix.inner_product(query, self.corpus, normalized=True)
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/gensim/similarities/termsim.py", line 345, in inner_product
Y = corpus2csc(Y, num_terms=self.matrix.shape[0], dtype=dtype)[word_indices, :].todense()
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/gensim/matutils.py", line 140, in corpus2csc
for docno, doc in enumerate(corpus):
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/gensim/corpora/mmcorpus.py", line 83, in __iter__
for doc_id, doc in super(MmCorpus, self).__iter__():
File "gensim/corpora/_mmreader.pyx", line 127, in __iter__
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/gensim/utils.py", line 140, in file_or_filename
return open(input, 'rb')
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/smart_open/smart_open_lib.py", line 187, in open
newline=newline,
File "/home/sug/.pyenv/versions/3.7.3/envs/subs/lib/python3.7/site-packages/smart_open/smart_open_lib.py", line 287, in _shortcut_open
return _builtin_open(local_path, mode, buffering=buffering, **open_kwargs)
FileNotFoundError: [Errno 2] No such file or directory: 'corpus.mm'
How do I solve this issue which allows me to execute the python program from any dir without having to copy the saved corpus files there?
Please let me know if you need any other information.