Created
August 31, 2020 21:54
-
-
Save XWilliamY/69378925bb5f9a9213db37883f83ebab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#0 import libraries | |
from googletrans import Translator | |
import multiprocessing | |
import workers | |
#1 create Translator object | |
translator = Translator() | |
#2 create multiprocessing pool | |
pool = multiprocessing.Pool(processes=multiprocessing.cpu_count()) | |
#3 texts to translate | |
texts = ["The quick brown fox jumps over the lazy dog."] | |
#4 using multiprocessing in Jupyter notebook | |
results = pool.map(workers.google_translate, texts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment