Skip to content

Commit 7252296

Browse files
author
Julien Salinas
committed
Add target to sentiment analysis
1 parent 301554e commit 7252296

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ The above command returns an object.
318318
Call the `question()` method and pass the following:
319319

320320
1. Your question
321-
1. A context that the model will use to try to answer your question
321+
1. (Optional) A context that the model will use to try to answer your question
322322

323323
```php
324324
echo json_encode($client->question('<Your question>','<Your context>'));
@@ -358,10 +358,14 @@ The above command returns an object.
358358

359359
### Sentiment Analysis Endpoint
360360

361-
Call the `sentiment()` method and pass the text you want to analyze the sentiment of:
361+
Call the `sentiment()` method and pass the following:
362+
363+
1. The text you want to analyze and get the sentiment of
364+
1. (Optional) The target element that the sentiment should apply to
365+
362366

363367
```php
364-
echo json_encode($client->sentiment('<Your block of text>'));
368+
echo json_encode($client->sentiment('<Your block of text>', '<Your target element>'));
365369
```
366370

367371
The above command returns an object.

src/NLPCloud.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,11 @@ public function sentenceDependencies($text)
432432
return $response->body;
433433
}
434434

435-
public function sentiment($text)
435+
public function sentiment($text, $target = NULL)
436436
{
437437
$payload = array(
438-
'text' => $text
438+
'text' => $text,
439+
'target' => $target
439440
);
440441
$response = \Httpful\Request::post($this->rootURL . '/' . 'sentiment', $payload)
441442
->expectsJson()

0 commit comments

Comments
 (0)