Google\Cloud\NaturalLanguage\NaturalLanguageClient::analyzeSentiment PHP Method

analyzeSentiment() public method

Example: $annotation = $language->analyzeSentiment('Google Cloud Platform is a powerful tool.'); $sentiment = $annotation->sentiment(); if ($sentiment['score'] > 0) { echo 'This is a positive message.'; }
See also: https://cloud.google.com/natural-language/reference/rest/v1beta1/documents/analyzeSentiment Analyze Sentiment API documentation
public analyzeSentiment ( string | StorageObject $content, array $options = [] ) : Annotation
$content string | Google\Cloud\Storage\StorageObject The content to analyze.
$options array [optional] { Configuration options. @type string $type The document type. Acceptable values are `PLAIN_TEXT` or `HTML`. **Defaults to** `"PLAIN_TEXT"`. @type string $language The language of the document. Both ISO (e.g., en, es) and BCP-47 (e.g., en-US, es-ES) language codes are accepted. If no value is provided, the language will be detected by the service. @type string $encodingType The text encoding type used by the API to calculate offsets. Acceptable values are `"NONE"`, `"UTF8"`, `"UTF16"` and `"UTF32"`. **Defaults to** `"UTF8"`. }
return Annotation
    public function analyzeSentiment($content, array $options = [])
    {
        return new Annotation($this->connection->analyzeSentiment($this->formatRequest($content, $options)));
    }