Reference documentation and code samples for the Cloud Natural Language Client class Annotation.
Annotations represent the result of a request against the Google Cloud Natural Language API.
This class is created internally by Google\Cloud\Language\LanguageClient and is used to represent various document analyzation results. It should not be instantiated externally.
Annotations are returned by Google\Cloud\Language\LanguageClient::analyzeEntities(), Google\Cloud\Language\LanguageClient::analyzeSentiment(), Google\Cloud\Language\LanguageClient::analyzeEntitySentiment(), Google\Cloud\Language\LanguageClient::analyzeSyntax() and Google\Cloud\Language\LanguageClient::annotateText().
Example:
use Google\Cloud\Language\LanguageClient;
$language = new LanguageClient();
$annotation = $language->annotateText('Google Cloud Platform is a powerful tool.');
Namespace
Google \ Cloud \ LanguageMethods
__construct
Create an annotation.
Parameter | |
---|---|
Name | Description |
info |
array
[optional] The annotation's metadata. |
info
See also:
Returns | |
---|---|
Type | Description |
array |
sentiment
See also:
Returns | |
---|---|
Type | Description |
array|null |
tokensByTag
See also:
Parameter | |
---|---|
Name | Description |
tag |
mixed
|
Returns | |
---|---|
Type | Description |
array|null |
tokensByLabel
See also:
Parameter | |
---|---|
Name | Description |
label |
mixed
|
Returns | |
---|---|
Type | Description |
array|null |
entitiesByType
See also:
Parameter | |
---|---|
Name | Description |
type |
mixed
|
Returns | |
---|---|
Type | Description |
array|null |
sentences
{ Returns an array of sentences found in the document.
Example:
```php
foreach ($annotation->sentences() as $sentence) {
echo $sentence['text']['content'];
}
```
@see https://cloud.google.com/natural-language/docs/reference/rest/v1/Sentence Sentence type documentation
@return array|null
}
Returns | |
---|---|
Type | Description |
void |
tokens
{ Returns an array of tokens found in the document.
Example:
```php
foreach ($annotation->tokens() as $token) {
echo $token['text']['content'];
}
```
@see https://cloud.google.com/natural-language/docs/reference/rest/v1/Token Token type documentation
@return array|null
}
Returns | |
---|---|
Type | Description |
void |
entities
{ Returns an array of entities found in the document.
Example:
```php
foreach ($annotation->entities() as $entity) {
echo $entity['type'];
}
```
@see https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity Entity type documentation
@return array|null
}
Returns | |
---|---|
Type | Description |
void |
categories
{ Returns an array of categories representing the input document.
Example:
```php
foreach ($annotation->categories() as $category) {
echo $category['name'];
}
```
@codingStandardsIgnoreStart
@see https://cloud.google.com/natural-language/docs/reference/rest/v1beta2/ClassificationCategory Classification category documentation
@codingStandardsIgnoreEnd
@return array|null
}
Returns | |
---|---|
Type | Description |
void |
language
{ Returns the language of the document.
Example:
```php
echo $annotation->language();
```
@return string|null
}
Returns | |
---|---|
Type | Description |
void |