Skip to content

Commit f926c60

Browse files
committed
Adding emotion analysis
1 parent 9d78da7 commit f926c60

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

examples/alchemy_language_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
# print(json.dumps(alchemy_language.microformats(url='http://microformats.org/wiki/hcard-examples'), indent=2))
2323
# print(json.dumps(alchemy_language.publication_date(url=url), indent=2))
2424
# print(json.dumps(alchemy_language.taxonomy(url=url), indent=2))
25-
combined_operations = ['page-image', 'entity', 'keyword', 'title', 'author', 'taxonomy', 'concept']
25+
combined_operations = ['page-image', 'entity', 'keyword', 'title', 'author', 'taxonomy', 'concept', 'doc-emotion']
2626
print(json.dumps(alchemy_language.combined(url=url, extract=combined_operations), indent=2))

watson_developer_cloud/alchemy_language_v1.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ def entities(self, html=None, text=None, url=None, disambiguate=True, linked_dat
5656
'maxRetrieve': max_items}
5757
return self._alchemy_html_request('GetRankedNamedEntities', html=html, text=text, url=url, params=params)
5858

59+
def emotion(self, html=None, text=None, url=None, show_source_text=False, source_text_type=None,
60+
constraint_query=None, xpath_query=None):
61+
params = {'showSourceText': show_source_text,
62+
'sourceText': source_text_type,
63+
'cquery': constraint_query,
64+
'xpath': xpath_query}
65+
return self._alchemy_html_request('GetEmotion', html=html, text=text, url=url, params=params)
66+
5967
def relations(self, html=None, text=None, url=None, sentiment=False, keywords=False, entities=False,
6068
require_entities=False, sentiment_excludes_entities=True, disambiguate=True, linked_data=True,
6169
coreference=True, show_source_text=False, max_items=50):
@@ -135,7 +143,7 @@ def combined(self, html=None, text=None, url=None, extract=None, disambiguate=Tr
135143
coreference=True, quotations=False, sentiment=False, show_source_text=False, max_items=50,
136144
base_url=None):
137145
"""
138-
Combined call for page-image, entity, keyword, title, author, taxonomy, concept.
146+
Combined call for page-image, entity, keyword, title, author, taxonomy, concept, doc-emotion.
139147
INPUT:
140148
extract ->
141149
List or comma separated string

0 commit comments

Comments
 (0)