Skip to content

Commit

Permalink
Support target in sentiment analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
juliensalinas committed Nov 27, 2024
1 parent f40e52b commit bcf00b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ The above command returns a JSON object.

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

1. A context that the model will use to try to answer your question
1. Your question
1. (Optional) A context that the model will use to try to answer your question

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

### Sentiment Analysis Endpoint

Call the `sentiment()` method and pass the text you want to analyze the sentiment of:
Call the `sentiment()` method and pass the following:

1. The text you want to analyze and get the sentiment of
1. (Optional) The target element that the sentiment should apply to

```python
client.sentiment("<Your block of text>")
client.sentiment("<Your block of text>", "<Your target element>")
```

The above command returns a JSON object.
Expand Down
5 changes: 3 additions & 2 deletions nlpcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,10 @@ def sentence_dependencies(self, text):

return r.json()

def sentiment(self, text):
def sentiment(self, text, target=None):
payload = {
"text": text
"text": text,
"target": target
}

r = requests.post(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='nlpcloud',
version='1.1.46',
version='1.1.47',
description='Python client for the NLP Cloud API',
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",
packages=['nlpcloud'],
Expand Down

0 comments on commit bcf00b8

Please sign in to comment.