Skip to content

Commit 6ac6a0c

Browse files
committed
- analytics: sentiment endpoint accepts two possible classification models
- analytics: added ner endpoint
1 parent afa4c6a commit 6ac6a0c

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

eventregistry/Analytics.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ def categorize(self, text):
3838
return self._er.jsonRequestAnalytics("/api/v1/categorize", { "text": text })
3939

4040

41-
def sentiment(self, text):
41+
def sentiment(self, text, method = "vocabulary"):
4242
"""
43-
determine the sentiment of the provided text
43+
determine the sentiment of the provided text in English language
4444
@param text: input text to categorize
45+
@param method: method to use to compute the sentiment. possible values are "vocabulary" (vocabulary based sentiment analysis)
46+
and "rnn" (neural network based sentiment classification)
4547
"""
46-
return self._er.jsonRequestAnalytics("/api/v1/sentiment", { "text": text })
48+
assert method == "vocabulary" or method == "rnn"
49+
endpoint = method == "vocabulary" and "sentiment" or "sentimentRNN"
50+
return self._er.jsonRequestAnalytics("/api/v1/" + endpoint, { "text": text })
4751

4852

4953
def semanticSimilarity(self, text1, text2, distanceMeasure = "cosine"):
@@ -70,3 +74,10 @@ def extractArticleInfo(self, url):
7074
article title, body, authors, links in the articles, ...
7175
"""
7276
return self._er.jsonRequestAnalytics("/api/v1/extractArticleInfo", { "url": url })
77+
78+
79+
def ner(self, text):
80+
"""
81+
extract named entities from the provided text. Supported languages are English, German, Spanish and Chinese.
82+
"""
83+
return self._er.jsonRequestAnalytics("/api/v1/ner", { "text": text })

0 commit comments

Comments
 (0)