PHP 클래스 Google\Cloud\NaturalLanguage\NaturalLanguageClient

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $language = $cloud->naturalLanguage(); NaturalLanguage can be instantiated directly. use Google\Cloud\NaturalLanguage\NaturalLanguageClient; $language = new NaturalLanguageClient();
상속: use trait Google\Cloud\ClientTrait
파일 보기 프로젝트 열기: GoogleCloudPlatform/gcloud-php

보호된 프로퍼티들

프로퍼티 타입 설명
$connection Google\Cloud\NaturalLanguage\Connection\ConnectionInterface

공개 메소드들

메소드 설명
__construct ( array $config = [] ) Create a NaturalLanguage client.
analyzeEntities ( string | StorageObject $content, array $options = [] ) : Annotation Finds named entities (currently finds proper names) in the text, entity types, salience, mentions for each entity, and other properties in the document.
analyzeSentiment ( string | StorageObject $content, array $options = [] ) : Annotation Analyzes the sentiment of the provided document.
analyzeSyntax ( string | StorageObject $content, array $options = [] ) : Annotation Analyzes the document and provides a full set of text annotations.
annotateText ( string | StorageObject $content, array $options = [] ) : Annotation Analyzes the document and provides a full set of text annotations, including semantic, syntactic, and sentiment information.

비공개 메소드들

메소드 설명
formatRequest ( string | StorageObject $content, array $options ) : array Formats the request for the API.
normalizeFeatures ( array $features ) : array Configures features in a way the API expects.

메소드 상세

__construct() 공개 메소드

Create a NaturalLanguage client.
public __construct ( array $config = [] )
$config array [optional] { Configuration Options. @type string $projectId The project ID from the Google Developer's Console. @type CacheItemPoolInterface $authCache A cache for storing access tokens. **Defaults to** a simple in memory implementation. @type array $authCacheOptions Cache configuration options. @type callable $authHttpHandler A handler used to deliver Psr7 requests specifically for authentication. @type callable $httpHandler A handler used to deliver Psr7 requests. Only valid for requests sent over REST. @type string $keyFile The contents of the service account credentials .json file retrieved from the Google Developers Console. @type string $keyFilePath The full path to your service account credentials .json file retrieved from the Google Developers Console. @type int $retries Number of retries for a failed request. **Defaults to** `3`. @type array $scopes Scopes to be used for the request. }

analyzeEntities() 공개 메소드

Example: $annotation = $language->analyzeEntities('Google Cloud Platform is a powerful tool.'); foreach ($annotation->entities() as $entity) { echo $entity['type']; }
또한 보기: https://cloud.google.com/natural-language/reference/rest/v1beta1/documents/analyzeEntities Analyze Entities API documentation
public analyzeEntities ( 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. Defaults to `"en"` (English). @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"`. }
리턴 Annotation

analyzeSentiment() 공개 메소드

Example: $annotation = $language->analyzeSentiment('Google Cloud Platform is a powerful tool.'); $sentiment = $annotation->sentiment(); if ($sentiment['score'] > 0) { echo 'This is a positive message.'; }
또한 보기: 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"`. }
리턴 Annotation

analyzeSyntax() 공개 메소드

Example: $annotation = $language->analyzeSyntax('Google Cloud Platform is a powerful tool.'); foreach ($annotation->sentences() as $sentence) { echo $sentence['text']['beginOffset']; }
또한 보기: https://cloud.google.com/natural-language/reference/rest/v1beta1/documents/analyzeSyntax Analyze Syntax API documentation
public analyzeSyntax ( 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"`. }
리턴 Annotation

annotateText() 공개 메소드

Example: Annotate text with all features enabled. $annotation = $language->annotateText('Google Cloud Platform is a powerful tool.'); $sentiment = $annotation->sentiment(); echo $sentiment['magnitude']; Annotate text with syntax and sentiment features enabled. $annotation = $language->annotateText('Google Cloud Platform is a powerful tool.', [ 'features' => ['syntax', 'sentiment'] ]); foreach ($annotation->tokens() as $token) { echo $token['text']['beginOffset']; }
또한 보기: https://cloud.google.com/natural-language/reference/rest/v1beta1/documents/annotateText Annotate Text API documentation
public annotateText ( string | StorageObject $content, array $options = [] ) : Annotation
$content string | Google\Cloud\Storage\StorageObject The content to annotate.
$options array [optional] { Configuration options. @type array $features Features to apply to the request. Valid values are `syntax`, `sentiment`, and `entities`. If no features are provided the request will run with all three enabled. @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"`. }
리턴 Annotation

프로퍼티 상세

$connection 보호되어 있는 프로퍼티

protected ConnectionInterface,Google\Cloud\NaturalLanguage\Connection $connection
리턴 Google\Cloud\NaturalLanguage\Connection\ConnectionInterface