1

我正在使用一个中等大小的文本数据集——大约 1GB 的单个文本列,我已将其作为 pandas 系列(对象类型)加载。它被称为textData

我想为每个文本行创建文档,然后进行标记。但我想使用我的自定义标记器。

from joblib import Parallel, delayed
from spacy.en import English


nlp = English()
docs = nlp.pipe([text for text in textData], batch_size=batchSize, n_threads=n_threads)

# This runs without any errors, but results is empty
results1 = Parallel(n_jobs=-1,)(delayed(clean_tokens)(doc) for doc in docs)
# This runs, and returns expected result
results2 = [clean_tokens(doc) for doc in docs]

def clean_tokens(doc):
    # clean tokens and POS tags
    exclusions = [token.i for token in doc if token.dep in [punct, det, agent, prep, aux, auxpass, cc, expl, quantmod]]
    tokens = [token.lemma_ for token in doc if token.i not in exclusions]        
    return tokens

我在 main() 中运行上述函数,并使用脚本调用 main()。

任何理由这不应该工作?如果有酸洗问题 - 它不会被提出。

有什么办法可以使这项工作?

4

0 回答 0