Reputation: 93
I want to use the Python-SDK for Emotion Analysis using the AlchemyAPI
.
from alchemyapi import AlchemyAPI
alchemyapi = AlchemyAPI()
demo_text = 'I am happy'
alchemyapi.emotion('text', demo_text)
gives this error:
AttributeError: AlchemyAPI instance has no attribute 'emotion'
How do I make an API call to detect emotions as mentioned here?
Upvotes: 0
Views: 1702
Reputation: 1166
Please follow all the steps above:
SDK
for short.Hint:
mkdir -p ~/src/test
cd ~/src/test
git clone https://github.com/AlchemyAPI/alchemyapi_python.git
cd alchemyapi_python/
3. Configure the Python SDK to use your API Key - all you need to do is configure it to use your API key:
python alchemyapi.py YOUR_API_KEY
4. Run a simple Example:
python example.py
At this point you should get lots of output in the terminal window as each function is called and the output is parsed.
Now, to be able to use AlchemyAPI
functionality just copy and paste the alchemyapi.py
file into your project, and in the file that will handle the text analysis include the following lines:
from alchemyapi import AlchemyAPI
alchemyapi = AlchemyAPI()
Now you can use the alchemyapi object to access any of the text analysis functions:
myText = "I'm excited to get started with AlchemyAPI!"
response = alchemyapi.sentiment("text", myText)
print "Sentiment: ", response["docSentiment"]["type"]
Disclaimer: make sure that you follow all these steps in order to be able to access the API.
Upvotes: 2