-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentiment_analysis_test.py
More file actions
21 lines (17 loc) · 922 Bytes
/
sentiment_analysis_test.py
File metadata and controls
21 lines (17 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from __future__ import print_function
import json
from watson_developer_cloud import NaturalLanguageUnderstandingV1
# from watson_developer_cloud.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions, SentimentOptions
from watson_developer_cloud.natural_language_understanding_v1 import Features, SentimentOptions
natural_language_understanding = NaturalLanguageUnderstandingV1(
version='',
username='',
password='')
response = natural_language_understanding.analyze(
text='Bruce Banner is the Hulk and Bruce Wayne is BATMAN! '
'Superman fears not Banner, but Wayne.',
# features=Features(entities=EntitiesOptions(), keywords=KeywordsOptions(), sentiment=SentimentOptions()))
features=Features(sentiment=SentimentOptions()))
# print(json.dumps(response, indent=2))
# print(json.dumps(response['sentiment']['document']['label']))
print(response['sentiment']['document']['label'])