File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 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+
181210print ('' )
182211print ('' )
183212print ('' )
You can’t perform that action at this time.
0 commit comments