Reputation: 143
I thought what I was trying to do would be simple, but that seems to not be the case.
I've found that using the Natural Language API with Google Compute Engine is fairly straightforward, as I can simply import the needed libraries in Python.
This does not seem to be the case with App Engine, as I am plagued by import errors, as soon as I fix one, another arises.
Have any of you ever worked to combine these two services, and if so, how?
Thank you
Upvotes: 0
Views: 341
Reputation: 8178
App Engine Standard does not yet support Google Client Libraries (which I assume you are trying to import into your application), it is work in the development, so by now you can try with the following alternatives:
google-api-python-client
library appropriately.UPDATE:
Actually, I have looked deeper into your issue and have been able to solve it using App Engine Standard by using the Google API Client Library (not Google Client Libraries), which is an alternative version that is available for the Standard environment. Below I leave a small working piece of code which you can populate with your own data and try in App Engine environment or even with the Local Development server.
from apiclient.discovery import build
service = build('language', 'v1', developerKey='<YOUR_API_KEY>')
collection = service.documents()
data = {}
data['document'] = {}
data['document']['language'] = 'en'
data['document']['content'] = 'I am really happy'
data['document']['type'] = 'PLAIN_TEXT'
request = collection.analyzeSentiment(body=data)
res = request.execute()
You will have to obtain an API key for authentication, as explained in the documentation, and you will also need to add the library as explained in the other link I shared.
Last, here you have the documentation on the available methods from the API. The example I provided is using analyzeSentiment()
, but you can go with the one you need.
Hope it helps!
Upvotes: 1