我正在使用 python 进行一个项目,该项目开始使我的低端 Windows 笔记本电脑不堪重负,我想就如何找到我认为需要的额外计算能力征求意见。
以下是关于我的项目的一些细节: 我正在处理和分析一个相当大的网络文本数据库。大约 10,000 个文件,每个文件平均相当于大约 500 个单词左右(尽管围绕这个平均值存在很大差异)。第一步是提取某些关键短语并使用 GenSim 进行相当简单的相似性分析。这需要我的电脑一段时间,但如果我很温柔,它可以处理它。其次,一旦我确定了候选者的简短列表,我就会对每个候选文档进行指纹识别,以更密切地评估相似性。每个文件都需要对 2-10 个其他文件进行指纹识别和比较 - 所以它并不是真正的 n 对 n 比较,我认为不需要几个月的计算机时间。
这是我的计算机开始挣扎的第二步。我正在考虑在 EC2 环境中运行脚本,但是当我开始在这里阅读有关该脚本的内容时,我看到了一条评论,大意是有效地这样做需要 linux sys 管理员级别的复杂性——我离那个级别还差得很远与本网站的任何成员一样复杂。
那么还有其他选择吗?或者在 ES2 上运行一个相当简单的 python 脚本并不难。
看起来最耗费资源的脚本部分如下所示。对于每个文本文件,它通过根据 PossDupes_1 中的标准(两者都是列表)从 amdt_word_bags trim 中选择某些文本文件来创建指纹列表。它使用我在这里找到的指纹生成器模块:https ://github.com/kailashbuki/fingerprint 。
fingerprints_hold=[]
counter=0
error_count=0
for amdt, sims in zip(amdt_word_bags_trim, PossDupes_1):
counter+=1
if counter%100==0:
print counter
if len(sims)>1:
poss_sim=[sim for sim in sims if sim !=(counter-1)]
fpg_orig = FingerprintGenerator(input_string=amdt)
try:
fpg_orig.generate_fingerprints()
orig_prints=fpg_orig.fingerprints
except IndexError as s:
orig_prints=["small"]
print s
error_count+=1
print error_count
cand_text=[[cand for cand in amdt_word_bags_trim[num]] for num in poss_sim]
cand_text=[''.join(c) for c in cand_text]
fing_cands_hold=[]
for text in cand_text:
fpg_cands = FingerprintGenerator(input_string=text)
try:
fpg_cands.generate_fingerprints()
fing_cands_pre=[int(a[0]) for a in fpg_cands.fingerprints]
fing_cands_hold.append(fing_cands_pre)
except IndexError as s2:
fing_cands_hold.append('small cand')
except TypeError as s3:
fing_cands_hold.append("none")
fingerprints_hold.append([orig_prints, fing_cands_hold])
else: fingerprints_hold.append("no potential matches")