gensim.similarities.SparseMatrixSimilarity get segmentation-
gensim.similarities.SparseMatrixSimilarity get segmentation-fault
我想将一个文档的相似性与其他文档相似。我使用Gensim。该程序可以正确运行,但是经过一些步骤后,它会以细分故障退出。
以下是我的代码:
from gensim import corpora, models, similarities
docs = [['Looking', 'for', 'the', 'meanings', 'of', 'words'],
['phrases'],
['and', 'expressions'],
['We', 'provide', 'hundreds', 'of', 'thousands', 'of', 'definitions'],
['synonyms'],
['antonyms'],
['and', 'pronunciations', 'for', 'English', 'and', 'other', 'languages'],
['derived', 'from', 'our', 'language', 'research', 'and', 'expert', 'analysis'],
['We', 'also', 'offer', 'a', 'unique', 'set', 'of', 'examples', 'of', 'real', 'usage'],
['as', 'well', 'as', 'guides', 'to:']]
dictionary = corpora.Dictionary(docs)
corpus = [dictionary.doc2bow(text) for text in docs]
nf=len(dictionary.dfs)
index = similarities.SparseMatrixSimilarity(corpus, num_features=nf)
phrases = [['This',
'section',
'gives',
'guidelines',
'on',
'writing',
'in',
'everyday',
'situations'],
['from',
'applying',
'for',
'a',
'job',
'to',
'composing',
'letters',
'of',
'complaint',
'or',
'making',
'an',
'insurance',
'claim'],
['There',
'are',
'plenty',
'of',
'sample',
'documents',
'to',
'help',
'you',
'get',
'it',
'right',
'every',
'time'],
['create',
'a',
'good',
'impression'],
['and',
'increase',
'the',
'likelihood',
'of',
'achieving',
'your',
'desired',
'outcome']]
phrase2word=[dictionary.doc2bow(text,allow_update=True) for text in phrases]
sims=index[phrase2word]
它可以正常运行,直到获得SIMS,但是无法获得SIMS,并且使用gdb
获取以下信息:
程序接收到信号sigsegv,分段故障。 CSR_TOCSC中的0x00007FFD881D809(n_row = 5,n_col = 39, AP = 0x4a4eb10,aj = 0x9fc6ec0,ax = 0x1be4a00,bp = 0xa15f6a0,bi = 0x9f3ee80, Bx = 0x9f85f60(在Scipy/Sparse/Sparsetools/CSR.H:411 411
scipy/稀疏/sparsetools/csr.h:没有没有。
我得到了github的答案
主要原因是num_features应该与dictionary.dfs
相关文章:
- Cpp-Tuple使用带有变量的get
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- 通过 get-Method 访问变量在类外不起作用
- 为什么我的C++代码中出现'Segmentation Fault: 11'行?
- 为什么无论你输入什么,这"while(cin.get(str,3))"只运行一次?
- Boost.Asio/OpenSSL HTTPS GET certificate trouble
- C++中是否有任何函数等同于python中字典的get函数?
- 给定一个整数数组,需要在Max_Heap上运行操作。得到错误"segmentation fault",有什么想法吗?(C++)
- 导致Segmentation错误的结构中的矢量
- 使用istringstearm和get行缓慢读取文件
- 如何将 c++ get 函数代码转换为 opencv 算法中使用的 python
- 使用 cin.get() 初始化字符数组
- std::variant<>::get() 不能使用 Apple LLVM 10.0 编译
- 编写 cin.get() 以接收字符数组时出现问题
- 作用域枚举和标准::get
- 循环时无法进入:"Segmentation fault"
- Visual Studio 2017 中的 cpprestapi 问题找不到 POST/GET 常量
- 在 C++/C 中使用 CURL 发出带有数据文件的 GET HTTP 请求
- 使用"push_back"作为带有"get"函数C++的向量
- gensim.similarities.SparseMatrixSimilarity get segmentation-