您的位置:首頁技術文章
文章詳情頁

運行python程序時出現“應用程序發生異?!钡膬却驽e誤?

瀏覽:156日期:2022-07-23 11:09:45

問題描述

我寫了一個70行左右的python小程序,用來計算文檔的相似性。材料是88篇論文文檔,用到了gensim包。程序的流程是預處理文檔(刪去不必要的符號,分詞等),計算文檔的tfidf值,建立88篇論文的tfidf模型以及模型索引。到這里程序運行都是正常的,但是在使用索引的時候,報錯:運行python程序時出現“應用程序發生異?!钡膬却驽e誤?

請問這是什么原因引起的呢?謝謝~

以下是部分運行沒有問題的源代碼:

#分詞:texts = [[word for word in document.split()]for document in documents]#利用所有文檔,創建詞典dictionary = corpora.Dictionary(texts)#創建語料corpus = [dictionary.doc2bow(text) for text in texts]#利用這些語料,創建tfidf模型tfidf_model = models.TfidfModel(corpus)#計算每個文檔的tfidftfidfs = tfidf_model[corpus]#創建tfidf的索引index = similarities.SparseMatrixSimilarity(tfidfs,num_features=88075)

運行這個代碼時出現了問題:

#創建目標文檔的語料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)#計算目標文檔的tfidftest_tfidf = tfidf_model[test]sims = index[test_tfidf]#**就是這一句出現了問題!**

問題解答

回答1:

你的python版本?當前 gensim的版本?是否和官網測試過的穩定版一致?還有,建議使用類Unix系統,gensim基于 NumPy 和 Scipy,這兩者在win上都不好安裝吧,安裝好了也不見得不會出問題

回答2:

這種錯誤也有可能是Windows操作系統的鍋,你把代碼復制到Google一下會發現很多解決方案,比如這個:

How to fix 0xc0000417 Error?回答3:

http://www.wiki-errors.com/do... 下載安裝即可,退百度保平安。

回答4:

操作系統用的盜版?換成Linux吧。

標簽: Python 編程
相關文章:
国产综合久久一区二区三区