In this recipe, similar to the previous one, we'll extract some data from Twitter using the Twitter API. When the tweets are received as a stream, the Translation API is called to identify the language of the tweet. If the tweet is not in our target language, we will invoke the Translation API to perform the translation:
- Navigate to the Chapter20/translateTweets folder.
- To execute the program in an isolated environment, create a virtualenv and install the dependent packages:
$ virtualenv ENV$ source ENV/bin/activate$ pip install -r requirements.txt
The following is the contents of the requirements.txt file:
google-cloud-translate==1.3.0tweepy==3.6.0
- The Python code extracts data from Twitter and invokes the Translation ...