Skip to content

Commit bcf00b8

Browse files
author
Julien Salinas
committed
Support target in sentiment analysis
1 parent f40e52b commit bcf00b8

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ The above command returns a JSON object.
301301

302302
Call the `question()` method and pass the following:
303303

304-
1. A context that the model will use to try to answer your question
305304
1. Your question
305+
1. (Optional) A context that the model will use to try to answer your question
306306

307307
```python
308308
client.question("<Your question>", "<Your context>")
@@ -342,10 +342,13 @@ The above command returns a JSON object.
342342

343343
### Sentiment Analysis Endpoint
344344

345-
Call the `sentiment()` method and pass the text you want to analyze the sentiment of:
345+
Call the `sentiment()` method and pass the following:
346+
347+
1. The text you want to analyze and get the sentiment of
348+
1. (Optional) The target element that the sentiment should apply to
346349

347350
```python
348-
client.sentiment("<Your block of text>")
351+
client.sentiment("<Your block of text>", "<Your target element>")
349352
```
350353

351354
The above command returns a JSON object.

nlpcloud/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,10 @@ def sentence_dependencies(self, text):
395395

396396
return r.json()
397397

398-
def sentiment(self, text):
398+
def sentiment(self, text, target=None):
399399
payload = {
400-
"text": text
400+
"text": text,
401+
"target": target
401402
}
402403

403404
r = requests.post(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='nlpcloud',
5-
version='1.1.46',
5+
version='1.1.47',
66
description='Python client for the NLP Cloud API',
77
long_description="NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, speech synthesis, tokenization, POS tagging, embeddings, and dependency parsing. It is ready for production, served through a REST API.\n\nThis is the Python client for the API.\n\nMore details here: https://nlpcloud.com\n\nDocumentation: https://docs.nlpcloud.com\n\nGithub: https://github.com/nlpcloud/nlpcloud-python",
88
packages=['nlpcloud'],

0 commit comments

Comments
 (0)