Use imap instead of map

This commit is contained in:
simon987 2021-08-28 20:09:00 -04:00
parent 67c09cc10c
commit 60273fb6bd

View File

@ -24,11 +24,12 @@ nltk.download("wordnet", quiet=True)
lemmatizer = WordNetLemmatizer()
def clean_multicore(texts, processes, **kwargs):
def clean_multicore(texts, processes, chunk_size=10000, **kwargs):
pool = Pool(processes=processes)
return pool.map(
yield from pool.imap(
func=partial(preprocess, **kwargs),
iterable=texts,
chunksize=chunk_size
)