Created
June 1, 2019 16:21
-
-
Save brianray/9c4ba626f7d66a0ddb419a4554d02646 to your computer and use it in GitHub Desktop.
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
from google.cloud import language | |
from google.cloud.language import enums | |
from google.cloud.language import types | |
def analyze(request): | |
request_json = request.get_json() | |
client = language.LanguageServiceClient() | |
sentance = request_json['content'] | |
document = types.Document( | |
content=sentance, | |
type=enums.Document.Type.PLAIN_TEXT) | |
annotations = client.analyze_sentiment( | |
document=document) | |
return str(annotations.document_sentiment.score) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment