運行python程序時出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯誤?
問題描述
我寫了一個70行左右的python小程序,用來計算文檔的相似性。材料是88篇論文文檔,用到了gensim包。程序的流程是預(yù)處理文檔(刪去不必要的符號,分詞等),計算文檔的tfidf值,建立88篇論文的tfidf模型以及模型索引。到這里程序運行都是正常的,但是在使用索引的時候,報錯:
請問這是什么原因引起的呢?謝謝~
以下是部分運行沒有問題的源代碼:
#分詞:texts = [[word for word in document.split()]for document in documents]#利用所有文檔,創(chuàng)建詞典dictionary = corpora.Dictionary(texts)#創(chuàng)建語料corpus = [dictionary.doc2bow(text) for text in texts]#利用這些語料,創(chuàng)建tfidf模型tfidf_model = models.TfidfModel(corpus)#計算每個文檔的tfidftfidfs = tfidf_model[corpus]#創(chuàng)建tfidf的索引index = similarities.SparseMatrixSimilarity(tfidfs,num_features=88075)
運行這個代碼時出現(xiàn)了問題:
#創(chuàng)建目標(biāo)文檔的語料content = ’A student of music needs as long and as arduous a training to become a performer as a medical student needs to become a doctor’content = content.lower().split()test = dictionary.doc2bow(content)#計算目標(biāo)文檔的tfidftest_tfidf = tfidf_model[test]sims = index[test_tfidf]#**就是這一句出現(xiàn)了問題!**
問題解答
回答1:你的python版本?當(dāng)前 gensim的版本?是否和官網(wǎng)測試過的穩(wěn)定版一致?還有,建議使用類Unix系統(tǒng),gensim基于 NumPy 和 Scipy,這兩者在win上都不好安裝吧,安裝好了也不見得不會出問題
回答2:這種錯誤也有可能是Windows操作系統(tǒng)的鍋,你把代碼復(fù)制到Google一下會發(fā)現(xiàn)很多解決方案,比如這個:
How to fix 0xc0000417 Error?回答3:http://www.wiki-errors.com/do... 下載安裝即可,退百度保平安。
回答4:操作系統(tǒng)用的盜版?換成Linux吧。
相關(guān)文章:
1. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?2. docker start -a dockername 老是卡住,什么情況?3. docker容器呢SSH為什么連不通呢?4. Android listview checkbox 單選5. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””6. Android TextView 或 ListView 加載過渡效果7. python-mysql Commands out of sync8. Python列表或者字典里面的中文如何處理?9. 爬蟲圖片 - 關(guān)于Python 爬蟲的問題10. python - (初學(xué)者)代碼運行不起來,求指導(dǎo),謝謝!
