Reference documentation and code samples for the Cloud Natural Language Client class LanguageClient.
Google Cloud Natural Language provides natural language understanding technologies to developers, including sentiment analysis, entity recognition, and syntax analysis. Currently only English, Spanish, and Japanese textual context are supported. Find more information at the Google Cloud Natural Language docs.
Example:
use Google\Cloud\Language\LanguageClient;
$language = new LanguageClient();
Namespace
Google \ Cloud \ LanguageMethods
__construct
Create a Language client.
Note that when creating a LanguageClient instance, setting
$config.projectId
is not supported. To switch between projects, you
must provide credentials with access to the project.
Parameters | |
---|---|
Name | Description |
config |
array
Configuration Options. |
↳ apiEndpoint |
string
A hostname with optional port to use in place of the service's default endpoint. |
↳ authCache |
CacheItemPoolInterface
A cache for storing access tokens. Defaults to a simple in memory implementation. |
↳ authCacheOptions |
array
Cache configuration options. |
↳ authHttpHandler |
callable
A handler used to deliver Psr7 requests specifically for authentication. |
↳ credentialsFetcher |
FetchAuthTokenInterface
A credentials fetcher instance. |
↳ httpHandler |
callable
A handler used to deliver Psr7 requests. Only valid for requests sent over REST. |
↳ keyFile |
array
The contents of the service account credentials .json file retrieved from the Google Developer's Console. Ex: |
↳ keyFilePath |
string
The full path to your service account credentials .json file retrieved from the Google Developers Console. |
↳ requestTimeout |
float
Seconds to wait before timing out the request. Defaults to |
↳ retries |
int
Number of retries for a failed request. Defaults to |
↳ scopes |
array
Scopes to be used for the request. |
↳ quotaProject |
string
Specifies a user project to bill for access charges associated with the request. |
analyzeEntities
See also:
Parameters | |
---|---|
Name | Description |
content |
string|Google\Cloud\Storage\StorageObject
The content to analyze. May be
either a string of UTF-8 encoded content, a URI pointing to a
Google Cloud Storage object in the format of
|
options |
array
Configuration options. |
↳ detectGcsUri |
bool
When providing $content as a string, this flag determines whether or not to attempt to detect if the string represents a Google Cloud Storage URI in the format of |
↳ type |
string
The document type. Acceptable values are |
↳ language |
string
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. |
↳ encodingType |
string
The text encoding type used by the API to calculate offsets. Acceptable values are |
Returns | |
---|---|
Type | Description |
Google\Cloud\Language\Annotation |
analyzeSentiment
See also:
Parameters | |
---|---|
Name | Description |
content |
string|Google\Cloud\Storage\StorageObject
The content to analyze. May be
either a string of UTF-8 encoded content, a URI pointing to a
Google Cloud Storage object in the format of
|
options |
array
Configuration options. |
↳ detectGcsUri |
bool
When providing $content as a string, this flag determines whether or not to attempt to detect if the string represents a Google Cloud Storage URI in the format of |
↳ type |
string
The document type. Acceptable values are |
↳ language |
string
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. |
↳ encodingType |
string
The text encoding type used by the API to calculate offsets. Acceptable values are |
Returns | |
---|---|
Type | Description |
Google\Cloud\Language\Annotation |
analyzeEntitySentiment
Parameters | |
---|---|
Name | Description |
content |
string|Google\Cloud\Storage\StorageObject
The content to analyze. May be
either a string of UTF-8 encoded content, a URI pointing to a
Google Cloud Storage object in the format of
|
options |
array
Configuration options. |
↳ detectGcsUri |
bool
When providing $content as a string, this flag determines whether or not to attempt to detect if the string represents a Google Cloud Storage URI in the format of |
↳ type |
string
The document type. Acceptable values are |
↳ language |
string
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. |
↳ encodingType |
string
The text encoding type used by the API to calculate offsets. Acceptable values are |
Returns | |
---|---|
Type | Description |
Google\Cloud\Language\Annotation |
analyzeSyntax
See also:
Parameters | |
---|---|
Name | Description |
content |
string|Google\Cloud\Storage\StorageObject
The content to analyze. May be
either a string of UTF-8 encoded content, a URI pointing to a
Google Cloud Storage object in the format of
|
options |
array
Configuration options. |
↳ detectGcsUri |
bool
When providing $content as a string, this flag determines whether or not to attempt to detect if the string represents a Google Cloud Storage URI in the format of |
↳ type |
string
The document type. Acceptable values are |
↳ language |
string
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. |
↳ encodingType |
string
The text encoding type used by the API to calculate offsets. Acceptable values are |
Returns | |
---|---|
Type | Description |
Google\Cloud\Language\Annotation |
classifyText
See also:
Parameters | |
---|---|
Name | Description |
content |
string|Google\Cloud\Storage\StorageObject
The content to analyze. May be
either a string of UTF-8 encoded content, a URI pointing to a
Google Cloud Storage object in the format of
|
options |
array
Configuration options. |
↳ detectGcsUri |
bool
When providing $content as a string, this flag determines whether or not to attempt to detect if the string represents a Google Cloud Storage URI in the format of |
↳ type |
string
The document type. Acceptable values are |
↳ language |
string
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. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Language\Annotation |
annotateText
See also:
Parameters | |
---|---|
Name | Description |
content |
string|Google\Cloud\Storage\StorageObject
The content to analyze. May be
either a string of UTF-8 encoded content, a URI pointing to a
Google Cloud Storage object in the format of
|
options |
array
Configuration options. |
↳ detectGcsUri |
bool
When providing $content as a string, this flag determines whether or not to attempt to detect if the string represents a Google Cloud Storage URI in the format of |
↳ features |
array
Features to apply to the request. Valid values are |
↳ type |
string
The document type. Acceptable values are |
↳ language |
string
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. |
↳ encodingType |
string
The text encoding type used by the API to calculate offsets. Acceptable values are |
Returns | |
---|---|
Type | Description |
Google\Cloud\Language\Annotation |
Constants
VERSION
Value: '0.32.6'
FULL_CONTROL_SCOPE
Value: 'https://www.googleapis.com/auth/cloud-platform'