【发布时间】:2019-11-18 15:32:40
【问题描述】:
我目前有大约 400K+ 文档,每个文档都有一个关联的组和 ID 号。它们平均大约有 24K 个字符和 350 行。总共有大约 25 GB 的数据。目前,它们按组进行拆分,一次需要处理的文档数量减少到 15K 左右。在具有 128GB 内存的机器上运行时,我遇到了内存使用和分段错误的问题(我相信后者是前者的结果)。我已经改变了我处理文档的方式,使用批处理来一次处理它们。
批号
def batchGetDoc(raw_documents):
out = []
reports = []
infos = []
# Each item in raw_documents is a tuple of 2 items, where the first item is all
# information (report number, tags) that correlate with said document. The second
# item is the raw text of the document itself
for info, report in raw_documents:
reports.append(report)
infos.append(info)
# Using en_core_web_sm as the model
docs = list(SPACY_PARSER.pipe(reports))
for i in range(len(infos)):
out.append([infos[i],docs[i]])
return out
我使用 500 的批量大小,即使这样,仍然需要一段时间。由于在完整文档而不是句子上使用.pipe(),这些速度和内存问题是否存在?单独通过并运行SPACY_PARSER(report)会更好吗?
我正在使用 spaCy 从每个文档中获取命名实体、它们的链接实体、依赖图和知识库。这样做会不会有丢失对 spaCy 以后获取所述数据很重要的信息的风险?
编辑:我应该提一下,我确实需要文档信息以供以后根据文档文本预测准确性
【问题讨论】:
-
您可以尝试丢失初学者的 for 循环
-
@pissall 会的。我应该如何将文档信息与 spaCy 返回的文档匹配?
标签: python nlp spacy named-entity-recognition