X Tutup
Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit cde4659

Browse files
author
Steve Herschleb
committed
add targeted sentiment to example
1 parent 3f9a4a0 commit cde4659

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

example.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,35 @@
178178

179179

180180

181+
print('')
182+
print('')
183+
print('')
184+
print('############################################')
185+
print('# Targeted Sentiment Analysis Example #')
186+
print('############################################')
187+
print('')
188+
print('')
189+
190+
print('Processing text: ', demo_text)
191+
print('')
192+
193+
response = alchemyapi.sentiment_targeted('text',demo_text, 'Denver')
194+
195+
if response['status'] == 'OK':
196+
print('## Response Object ##')
197+
print(json.dumps(response, indent=4))
198+
199+
print('')
200+
print('## Targeted Sentiment ##')
201+
print('type: ', response['docSentiment']['type'])
202+
203+
if 'score' in response['docSentiment']:
204+
print('score: ', response['docSentiment']['score'])
205+
else:
206+
print('Error in targeted sentiment analysis call: ', response['statusInfo'])
207+
208+
209+
181210
print('')
182211
print('')
183212
print('')

0 commit comments

Comments
 (0)
X Tutup