Skip to content

Commit

Permalink
Add target to sentiment analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
juliensalinas committed Nov 27, 2024
1 parent 301554e commit 7252296
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ The above command returns an object.
Call the `question()` method and pass the following:

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

```php
echo json_encode($client->question('<Your question>','<Your context>'));
Expand Down Expand Up @@ -358,10 +358,14 @@ The above command returns an 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


```php
echo json_encode($client->sentiment('<Your block of text>'));
echo json_encode($client->sentiment('<Your block of text>', '<Your target element>'));
```

The above command returns an object.
Expand Down
5 changes: 3 additions & 2 deletions src/NLPCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,11 @@ public function sentenceDependencies($text)
return $response->body;
}

public function sentiment($text)
public function sentiment($text, $target = NULL)
{
$payload = array(
'text' => $text
'text' => $text,
'target' => $target
);
$response = \Httpful\Request::post($this->rootURL . '/' . 'sentiment', $payload)
->expectsJson()
Expand Down

0 comments on commit 7252296

Please sign in to comment.