潜在语义分析索引问题
每次我在安装了 Python 2.6.6 的 Windows 7 企业版(64 位)上运行这个 Python 脚本时,总是会出现这个错误:
问题签名:
问题事件名称: APPCRASH
应用程序名称: python.exe
应用程序版本: 0.0.0.0
应用程序时间戳: 4c73f7b6
故障模块名称: _csr.pyd
故障模块版本: 0.0.0.0
故障模块时间戳: 4d6a645b
异常代码: c0000005
异常偏移量: 000c05d4
我已经尝试重新安装 Python 和我程序所需的所有模块(比如 gensim、nlptk、scipy 和 numpy)。
我不知道这些信息是否足够,但请告诉我!!
lsi = models.LsiModel(corpus, num_topics = num_Topics)
index_lsi = similarities.MatrixSimilarity(lsi[corpus])
for k, v in dict_Queries.items():
File.write("Check Key: " +k+ "\n")
print "Running.... \n"
vec_bow = dict.doc2bow(v.split(), allow_update=True)
#In the last iteration, the code below the line doesn't run and i think the vec_lsi
#is the source of the problem but I don't know why?
vec_lsi = lsi[vec_bow]
#indexing the LSI
sims = index_lsi[vec_lsi]
sims = sorted(enumerate(sims), key = lambda item: -item[1])
if not cut_Off == 0:
sims = sims[0:cut_Off]
else:
pass
for t in sims:
dup_info = dict_tcs.get(t[0])
if t[1] > 0.75:
#print "Key: " + k + " Link: " + dup_info + "\n"
File.write("Adding: "+str(t)+ " To LSI actual \n")
if dict_Actual_LSI.has_key(k):
links = dict_Actual_LSI.get(k)
links.append(dup_info)
else:
links = []
links.append(dup_info)
dict_Actual_LSI[k] = links
print "Added\n"
在最后一次运行中,下面那行代码没有执行,我觉得 vec_lsi 可能是问题的来源,但我不知道为什么?
谢谢
1 个回答
3
异常代码c0000005表示“访问违规”。这通常意味着某段代码试图读取或写入一个它没有权限访问的内存地址。这可能是因为指针损坏、内存没有初始化,或者是本地代码在数组的边界外进行索引。
出错的模块是_csr.pyd。这是SciPy的一部分,听起来是用来处理稀疏数组的。这说明错误发生的原因可能是SciPy指向了无效的内存。没有看到你的程序,很难猜测这可能是怎么发生的。
接下来的步骤,你可以尝试在崩溃前找出发生了什么,可以在程序中添加一些打印语句——通过打印出程序的进展,你可以缩小崩溃发生的范围。如果运气好的话,可能就能清楚为什么SciPy会试图访问无效的内存。