Last active
March 23, 2021 08:14
-
-
Save VioletVivirand/386ef6c1d7525f93e27b73d1587b9a7e to your computer and use it in GitHub Desktop.
Revision list for Qwiklabs Lab: Classify Text into Categories with the Natural Language API (https://google.qwiklabs.com/focuses/1749?parent=catalog)
This file contains 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
Revision list for Qwiklabs Lab: Classify Text into Categories with the Natural Language API (https://google.qwiklabs.com/focuses/1749?parent=catalog) |
This file contains 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
# Execute these otherwise it won't work | |
# Install Pip | |
sudo apt-get update && sudo apt-get install python3-pip | |
# Install Virtualenv | |
python3 -m pip install virtualenv | |
# Create a new virtual environment with Virtualenv | |
python3 -m virtualenv -p python3 venv | |
# Activate the new virtual environment | |
source ./venv/bin/activate | |
# Install dependencies | |
pip install google-cloud google-cloud-storage google-cloud-language google-cloud-bigquery |
This file contains 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
# Update this function with the following lines | |
def classify_text(article): | |
response = nl_client.classify_text( | |
document=language.types.Document( | |
content=article, | |
type="PLAIN_TEXT" | |
) | |
) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment