From bcf00b81b499f605b9b3456c3d3e211dde3ee2de Mon Sep 17 00:00:00 2001 From: Julien Salinas Date: Wed, 27 Nov 2024 09:56:49 +0100 Subject: [PATCH] Support target in sentiment analysis --- README.md | 9 ++++++--- nlpcloud/__init__.py | 5 +++-- setup.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 98b025d..4e83263 100644 --- a/README.md +++ b/README.md @@ -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("", "") @@ -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("") +client.sentiment("", "") ``` The above command returns a JSON object. diff --git a/nlpcloud/__init__.py b/nlpcloud/__init__.py index c782e72..e7cfeb8 100644 --- a/nlpcloud/__init__.py +++ b/nlpcloud/__init__.py @@ -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( diff --git a/setup.py b/setup.py index 31b2901..fb6bc47 100644 --- a/setup.py +++ b/setup.py @@ -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'],