diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json index 40202a1b114..1d18d2cea65 100644 --- a/.repo-metadata-full.json +++ b/.repo-metadata-full.json @@ -810,7 +810,7 @@ "Language": { "language": "php", "distribution_name": "google/cloud-language", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-language/latest", "library_type": "GAPIC_COMBO", "api_shortname": "language" diff --git a/Core/src/ServiceBuilder.php b/Core/src/ServiceBuilder.php index 9a5ac3f4f82..17af1a58ed8 100644 --- a/Core/src/ServiceBuilder.php +++ b/Core/src/ServiceBuilder.php @@ -22,7 +22,7 @@ use Google\Cloud\BigQuery\BigQueryClient; use Google\Cloud\Datastore\DatastoreClient; use Google\Cloud\Firestore\FirestoreClient; -use Google\Cloud\Language\LanguageClient; +use Google\Cloud\Language\V2\Client\LanguageServiceClient; use Google\Cloud\Logging\LoggingClient; use Google\Cloud\PubSub\PubSubClient; use Google\Cloud\Spanner\SpannerClient; @@ -211,11 +211,11 @@ public function logging(array $config = []) * * @param array $config [optional] Configuration options. See * {@see \Google\Cloud\Core\ServiceBuilder::__construct()} for the available options. - * @return LanguageClient + * @return LanguageServiceClient */ public function language(array $config = []) { - return $this->createClient(LanguageClient::class, 'language', $config); + return $this->createClient(LanguageServiceClient::class, 'language', $config); } /** diff --git a/Language/.OwlBot.yaml b/Language/.OwlBot.yaml index 578fe9831b3..3dcfdaf2bd0 100644 --- a/Language/.OwlBot.yaml +++ b/Language/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/language/(.*)/.*-php/(.*) + - source: /google/cloud/language/(v2|v1)/.*-php/(.*) dest: /owl-bot-staging/Language/$1/$2 api-name: Language diff --git a/Language/README.md b/Language/README.md index 2e8488ad081..c47147b7b13 100644 --- a/Language/README.md +++ b/Language/README.md @@ -62,9 +62,8 @@ foreach ($tokens as $token) { ### Version -This component is considered beta. As such, it should be expected to be mostly -stable and we're working towards a release candidate. We will address issues -and requests with a higher priority. +This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in +any minor or patch releases. We will address issues and requests with the highest priority. ### Next Steps diff --git a/Language/owlbot.py b/Language/owlbot.py index 5d014c17eb4..0321b303165 100644 --- a/Language/owlbot.py +++ b/Language/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2018 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,48 +30,33 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main(src=src, dest=dest) - - -# Fix class references in gapic samples -for version in ['V1', 'V1beta2']: - pathExpr = 'src/' + version + '/Gapic/LanguageServiceGapicClient.php' - - types = { - 'new LanguageServiceClient': r'new Google\\Cloud\\Language\\'+ version + r'\\LanguageServiceClient', - 'new Document': r'new Google\\Cloud\\Language\\'+ version + r'\\Document', - 'new Features': r'new Google\\Cloud\\Language\\'+ version + r'\\AnnotateTextRequest\\Features', - } - - for search, replace in types.items(): - s.replace( - pathExpr, - search, - replace -) - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" +php.owlbot_main( + src=src, + dest=dest, + copy_excludes=[ + src / "**/[A-Z]*_*.php", + ] ) -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links +# remove class_alias code s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/Language/phpunit-snippets.xml.dist b/Language/phpunit-snippets.xml.dist deleted file mode 100644 index 319673b50fe..00000000000 --- a/Language/phpunit-snippets.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - src - - - src/V[!a-zA-Z]* - - - - - tests/Snippet - - - diff --git a/Language/src/Annotation.php b/Language/src/Annotation.php deleted file mode 100644 index 54ead42f3b3..00000000000 --- a/Language/src/Annotation.php +++ /dev/null @@ -1,285 +0,0 @@ -annotateText('Google Cloud Platform is a powerful tool.'); - * ``` - * - * @method sentences() { - * Returns an array of sentences found in the document. - * - * Example: - * ``` - * 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 - * } - * @method tokens() { - * Returns an array of tokens found in the document. - * - * Example: - * ``` - * 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 - * } - * @method entities() { - * Returns an array of entities found in the document. - * - * Example: - * ``` - * 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 - * } - * @method categories() { - * Returns an array of categories representing the input document. - * - * Example: - * ``` - * 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 - * } - * @method language() { - * Returns the language of the document. - * - * Example: - * ``` - * echo $annotation->language(); - * ``` - * - * @return string|null - * } - * @deprecated See {@see \Google\Cloud\Language\V2\Client\LanguageServiceClient}. - */ -class Annotation -{ - use CallTrait; - - /** - * @var array The annotation's metadata. - */ - private $info; - - /** - * Create an annotation. - * - * @param array $info [optional] The annotation's metadata. - */ - public function __construct(array $info = []) - { - $this->info = $info; - } - - /** - * Returns the full response from the API. - * - * Example: - * ``` - * $info = $annotation->info(); - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#response-body Annotate Text documentation - * @codingStandardsIgnoreEnd - * - * @return array - */ - public function info() - { - return $this->info; - } - - /** - * Returns the sentiment of the document. - * - * Example: - * ``` - * $sentiment = $annotation->sentiment(); - * - * if ($sentiment['score'] > 0) { - * echo 'This is a positive message.'; - * } - * ``` - * - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Sentiment Sentiment type documentation - * - * @return array|null - */ - public function sentiment() - { - return isset($this->info['documentSentiment']) ? $this->info['documentSentiment'] : null; - } - - /** - * Returns an array of tokens filtered by the given tag. - * - * Example: - * ``` - * $tokens = $annotation->tokensByTag('NOUN'); - * - * foreach ($tokens as $token) { - * echo $token['lemma']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Token#Tag Token tags documentation - * @codingStandardsIgnoreEnd - * - * @return array|null - */ - public function tokensByTag($tag) - { - return $this->filter( - $this->tokens(), - ['partOfSpeech', 'tag'], - $tag - ); - } - - /** - * Returns an array of tokens filtered by the given label. - * - * Example: - * ``` - * $tokens = $annotation->tokensByLabel('P'); - * - * foreach ($tokens as $token) { - * echo $token['lemma']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Token#Label Token labels documentation - * @codingStandardsIgnoreEnd - * - * @return array|null - */ - public function tokensByLabel($label) - { - return $this->filter( - $this->tokens(), - ['dependencyEdge', 'label'], - $label - ); - } - - /** - * Returns an array of entities filtered by the given type. - * - * Example: - * ``` - * $entities = $annotation->entitiesByType('PERSON'); - * - * foreach ($entities as $entity) { - * echo $entity['name']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity#Type Entity types documentation - * @codingStandardsIgnoreEnd - * - * @return array|null - */ - public function entitiesByType($type) - { - return $this->filter( - $this->entities(), - ['type'], - $type - ); - } - - /** - * Filters an array of items based on the provided type. - * - * @param array $items The items to iterate. - * @param array $path The path to the value to compare against the provided - * type. - * @param string $type The type to filter on. - * @return array|null - */ - private function filter($items, $path, $type) - { - if (!$items) { - return null; - } - - return array_filter($items, function ($item) use ($path, $type) { - $itemCopy = $item; - - // key into the value with the given path - foreach ($path as $key) { - $itemCopy = $itemCopy[$key]; - } - - if (strtolower($itemCopy) === strtolower($type)) { - return $item; - } - }); - } -} diff --git a/Language/src/Connection/ConnectionInterface.php b/Language/src/Connection/ConnectionInterface.php deleted file mode 100644 index f0391346d08..00000000000 --- a/Language/src/Connection/ConnectionInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - __DIR__ . '/ServiceDefinition/language-v1.json', - 'componentVersion' => LanguageClient::VERSION - ]; - - $this->setRequestWrapper(new RequestWrapper($config)); - $this->setRequestBuilder(new RequestBuilder( - $config['serviceDefinitionPath'], - $this->getApiEndpoint(self::BASE_URI, $config) - )); - } - - /** - * @param array $args - * @return array - */ - public function analyzeEntities(array $args = []) - { - return $this->send('documents', 'analyzeEntities', $args); - } - - /** - * @param array $args - * @return array - */ - public function analyzeSentiment(array $args = []) - { - return $this->send('documents', 'analyzeSentiment', $args); - } - - /** - * @param array $args - * @return array - */ - public function analyzeEntitySentiment(array $args = []) - { - return $this->send('documents', 'analyzeEntitySentiment', $args); - } - - /** - * @param array $args - * @return array - */ - public function analyzeSyntax(array $args = []) - { - return $this->send('documents', 'analyzeSyntax', $args); - } - - /** - * @param array $args - * @return array - */ - public function annotateText(array $args = []) - { - return $this->send('documents', 'annotateText', $args); - } - - /** - * @param array $args - * @return array - */ - public function classifyText(array $args = []) - { - return $this->send('documents', 'classifyText', $args); - } -} diff --git a/Language/src/Connection/ServiceDefinition/language-v1.json b/Language/src/Connection/ServiceDefinition/language-v1.json deleted file mode 100644 index 85599cf91a0..00000000000 --- a/Language/src/Connection/ServiceDefinition/language-v1.json +++ /dev/null @@ -1,1251 +0,0 @@ -{ - "title": "Google Cloud Natural Language API", - "ownerName": "Google", - "resources": { - "documents": { - "methods": { - "analyzeEntitySentiment": { - "httpMethod": "POST", - "parameterOrder": [], - "response": { - "$ref": "AnalyzeEntitySentimentResponse" - }, - "parameters": {}, - "scopes": [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ], - "flatPath": "v1/documents:analyzeEntitySentiment", - "id": "language.documents.analyzeEntitySentiment", - "path": "v1/documents:analyzeEntitySentiment", - "request": { - "$ref": "AnalyzeEntitySentimentRequest" - }, - "description": "Finds entities, similar to AnalyzeEntities in the text and analyzes\nsentiment associated with each entity and its mentions." - }, - "analyzeEntities": { - "response": { - "$ref": "AnalyzeEntitiesResponse" - }, - "parameterOrder": [], - "httpMethod": "POST", - "parameters": {}, - "scopes": [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ], - "flatPath": "v1/documents:analyzeEntities", - "path": "v1/documents:analyzeEntities", - "id": "language.documents.analyzeEntities", - "request": { - "$ref": "AnalyzeEntitiesRequest" - }, - "description": "Finds named entities (currently proper names and common nouns) in the text\nalong with entity types, salience, mentions for each entity, and\nother properties." - }, - "analyzeSyntax": { - "path": "v1/documents:analyzeSyntax", - "id": "language.documents.analyzeSyntax", - "description": "Analyzes the syntax of the text and provides sentence boundaries and\ntokenization along with part of speech tags, dependency trees, and other\nproperties.", - "request": { - "$ref": "AnalyzeSyntaxRequest" - }, - "response": { - "$ref": "AnalyzeSyntaxResponse" - }, - "parameterOrder": [], - "httpMethod": "POST", - "scopes": [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ], - "parameters": {}, - "flatPath": "v1/documents:analyzeSyntax" - }, - "annotateText": { - "httpMethod": "POST", - "parameterOrder": [], - "response": { - "$ref": "AnnotateTextResponse" - }, - "parameters": {}, - "scopes": [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ], - "flatPath": "v1/documents:annotateText", - "id": "language.documents.annotateText", - "path": "v1/documents:annotateText", - "request": { - "$ref": "AnnotateTextRequest" - }, - "description": "A convenience method that provides all the features that analyzeSentiment,\nanalyzeEntities, and analyzeSyntax provide in one call." - }, - "classifyText": { - "path": "v1/documents:classifyText", - "id": "language.documents.classifyText", - "request": { - "$ref": "ClassifyTextRequest" - }, - "description": "Classifies a document into categories.", - "response": { - "$ref": "ClassifyTextResponse" - }, - "parameterOrder": [], - "httpMethod": "POST", - "parameters": {}, - "scopes": [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ], - "flatPath": "v1/documents:classifyText" - }, - "analyzeSentiment": { - "response": { - "$ref": "AnalyzeSentimentResponse" - }, - "parameterOrder": [], - "httpMethod": "POST", - "parameters": {}, - "scopes": [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ], - "flatPath": "v1/documents:analyzeSentiment", - "path": "v1/documents:analyzeSentiment", - "id": "language.documents.analyzeSentiment", - "request": { - "$ref": "AnalyzeSentimentRequest" - }, - "description": "Analyzes the sentiment of the provided text." - } - } - } - }, - "parameters": { - "upload_protocol": { - "description": "Upload protocol for media (e.g. \"raw\", \"multipart\").", - "type": "string", - "location": "query" - }, - "prettyPrint": { - "description": "Returns response with indentations and line breaks.", - "type": "boolean", - "default": "true", - "location": "query" - }, - "uploadType": { - "description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\").", - "type": "string", - "location": "query" - }, - "fields": { - "location": "query", - "description": "Selector specifying which fields to include in a partial response.", - "type": "string" - }, - "$.xgafv": { - "enumDescriptions": [ - "v1 error format", - "v2 error format" - ], - "location": "query", - "enum": [ - "1", - "2" - ], - "description": "V1 error format.", - "type": "string" - }, - "callback": { - "location": "query", - "description": "JSONP", - "type": "string" - }, - "alt": { - "enum": [ - "json", - "media", - "proto" - ], - "type": "string", - "enumDescriptions": [ - "Responses with Content-Type of application/json", - "Media download with context-dependent Content-Type", - "Responses with Content-Type of application/x-protobuf" - ], - "location": "query", - "description": "Data format for response.", - "default": "json" - }, - "key": { - "location": "query", - "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.", - "type": "string" - }, - "access_token": { - "location": "query", - "description": "OAuth access token.", - "type": "string" - }, - "quotaUser": { - "location": "query", - "description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.", - "type": "string" - }, - "pp": { - "description": "Pretty-print response.", - "type": "boolean", - "default": "true", - "location": "query" - }, - "oauth_token": { - "location": "query", - "description": "OAuth 2.0 token for the current user.", - "type": "string" - }, - "bearer_token": { - "location": "query", - "description": "OAuth bearer token.", - "type": "string" - } - }, - "version": "v1", - "baseUrl": "https://language.googleapis.com/", - "kind": "discovery#restDescription", - "description": "Provides natural language understanding technologies to developers. Examples include sentiment analysis, entity recognition, entity sentiment analysis, and text annotations.", - "servicePath": "", - "basePath": "", - "id": "language:v1", - "documentationLink": "https://cloud.google.com/natural-language/", - "revision": "20171031", - "discoveryVersion": "v1", - "version_module": true, - "schemas": { - "AnalyzeEntitySentimentRequest": { - "description": "The entity-level sentiment analysis request message.", - "type": "object", - "properties": { - "encodingType": { - "enum": [ - "NONE", - "UTF8", - "UTF16", - "UTF32" - ], - "description": "The encoding type used by the API to calculate offsets.", - "type": "string", - "enumDescriptions": [ - "If `EncodingType` is not specified, encoding-dependent information (such as\n`begin_offset`) will be set at `-1`.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-8 encoding of the input. C++ and Go are examples of languages\nthat use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-16 encoding of the input. Java and Javascript are examples of\nlanguages that use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-32 encoding of the input. Python is an example of a language\nthat uses this encoding natively." - ] - }, - "document": { - "description": "Input document.", - "$ref": "Document" - } - }, - "id": "AnalyzeEntitySentimentRequest" - }, - "PartOfSpeech": { - "description": "Represents part of speech information for a token. Parts of speech\nare as defined in\nhttp://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf", - "type": "object", - "properties": { - "person": { - "enum": [ - "PERSON_UNKNOWN", - "FIRST", - "SECOND", - "THIRD", - "REFLEXIVE_PERSON" - ], - "description": "The grammatical person.", - "type": "string", - "enumDescriptions": [ - "Person is not applicable in the analyzed language or is not predicted.", - "First", - "Second", - "Third", - "Reflexive" - ] - }, - "proper": { - "enum": [ - "PROPER_UNKNOWN", - "PROPER", - "NOT_PROPER" - ], - "description": "The grammatical properness.", - "type": "string", - "enumDescriptions": [ - "Proper is not applicable in the analyzed language or is not predicted.", - "Proper", - "Not proper" - ] - }, - "case": { - "enum": [ - "CASE_UNKNOWN", - "ACCUSATIVE", - "ADVERBIAL", - "COMPLEMENTIVE", - "DATIVE", - "GENITIVE", - "INSTRUMENTAL", - "LOCATIVE", - "NOMINATIVE", - "OBLIQUE", - "PARTITIVE", - "PREPOSITIONAL", - "REFLEXIVE_CASE", - "RELATIVE_CASE", - "VOCATIVE" - ], - "description": "The grammatical case.", - "type": "string", - "enumDescriptions": [ - "Case is not applicable in the analyzed language or is not predicted.", - "Accusative", - "Adverbial", - "Complementive", - "Dative", - "Genitive", - "Instrumental", - "Locative", - "Nominative", - "Oblique", - "Partitive", - "Prepositional", - "Reflexive", - "Relative", - "Vocative" - ] - }, - "tense": { - "enum": [ - "TENSE_UNKNOWN", - "CONDITIONAL_TENSE", - "FUTURE", - "PAST", - "PRESENT", - "IMPERFECT", - "PLUPERFECT" - ], - "description": "The grammatical tense.", - "type": "string", - "enumDescriptions": [ - "Tense is not applicable in the analyzed language or is not predicted.", - "Conditional", - "Future", - "Past", - "Present", - "Imperfect", - "Pluperfect" - ] - }, - "reciprocity": { - "enum": [ - "RECIPROCITY_UNKNOWN", - "RECIPROCAL", - "NON_RECIPROCAL" - ], - "description": "The grammatical reciprocity.", - "type": "string", - "enumDescriptions": [ - "Reciprocity is not applicable in the analyzed language or is not\npredicted.", - "Reciprocal", - "Non-reciprocal" - ] - }, - "form": { - "enum": [ - "FORM_UNKNOWN", - "ADNOMIAL", - "AUXILIARY", - "COMPLEMENTIZER", - "FINAL_ENDING", - "GERUND", - "REALIS", - "IRREALIS", - "SHORT", - "LONG", - "ORDER", - "SPECIFIC" - ], - "description": "The grammatical form.", - "type": "string", - "enumDescriptions": [ - "Form is not applicable in the analyzed language or is not predicted.", - "Adnomial", - "Auxiliary", - "Complementizer", - "Final ending", - "Gerund", - "Realis", - "Irrealis", - "Short form", - "Long form", - "Order form", - "Specific form" - ] - }, - "number": { - "enumDescriptions": [ - "Number is not applicable in the analyzed language or is not predicted.", - "Singular", - "Plural", - "Dual" - ], - "enum": [ - "NUMBER_UNKNOWN", - "SINGULAR", - "PLURAL", - "DUAL" - ], - "description": "The grammatical number.", - "type": "string" - }, - "voice": { - "enumDescriptions": [ - "Voice is not applicable in the analyzed language or is not predicted.", - "Active", - "Causative", - "Passive" - ], - "enum": [ - "VOICE_UNKNOWN", - "ACTIVE", - "CAUSATIVE", - "PASSIVE" - ], - "description": "The grammatical voice.", - "type": "string" - }, - "aspect": { - "enumDescriptions": [ - "Aspect is not applicable in the analyzed language or is not predicted.", - "Perfective", - "Imperfective", - "Progressive" - ], - "enum": [ - "ASPECT_UNKNOWN", - "PERFECTIVE", - "IMPERFECTIVE", - "PROGRESSIVE" - ], - "description": "The grammatical aspect.", - "type": "string" - }, - "mood": { - "enum": [ - "MOOD_UNKNOWN", - "CONDITIONAL_MOOD", - "IMPERATIVE", - "INDICATIVE", - "INTERROGATIVE", - "JUSSIVE", - "SUBJUNCTIVE" - ], - "description": "The grammatical mood.", - "type": "string", - "enumDescriptions": [ - "Mood is not applicable in the analyzed language or is not predicted.", - "Conditional", - "Imperative", - "Indicative", - "Interrogative", - "Jussive", - "Subjunctive" - ] - }, - "tag": { - "enumDescriptions": [ - "Unknown", - "Adjective", - "Adposition (preposition and postposition)", - "Adverb", - "Conjunction", - "Determiner", - "Noun (common and proper)", - "Cardinal number", - "Pronoun", - "Particle or other function word", - "Punctuation", - "Verb (all tenses and modes)", - "Other: foreign words, typos, abbreviations", - "Affix" - ], - "enum": [ - "UNKNOWN", - "ADJ", - "ADP", - "ADV", - "CONJ", - "DET", - "NOUN", - "NUM", - "PRON", - "PRT", - "PUNCT", - "VERB", - "X", - "AFFIX" - ], - "description": "The part of speech tag.", - "type": "string" - }, - "gender": { - "enum": [ - "GENDER_UNKNOWN", - "FEMININE", - "MASCULINE", - "NEUTER" - ], - "description": "The grammatical gender.", - "type": "string", - "enumDescriptions": [ - "Gender is not applicable in the analyzed language or is not predicted.", - "Feminine", - "Masculine", - "Neuter" - ] - } - }, - "id": "PartOfSpeech" - }, - "ClassificationCategory": { - "description": "Represents a category returned from the text classifier.", - "type": "object", - "properties": { - "confidence": { - "description": "The classifier's confidence of the category. Number represents how certain\nthe classifier is that this category represents the given text.", - "format": "float", - "type": "number" - }, - "name": { - "description": "The name of the category representing the document.", - "type": "string" - } - }, - "id": "ClassificationCategory" - }, - "AnalyzeSyntaxRequest": { - "properties": { - "encodingType": { - "enum": [ - "NONE", - "UTF8", - "UTF16", - "UTF32" - ], - "description": "The encoding type used by the API to calculate offsets.", - "type": "string", - "enumDescriptions": [ - "If `EncodingType` is not specified, encoding-dependent information (such as\n`begin_offset`) will be set at `-1`.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-8 encoding of the input. C++ and Go are examples of languages\nthat use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-16 encoding of the input. Java and Javascript are examples of\nlanguages that use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-32 encoding of the input. Python is an example of a language\nthat uses this encoding natively." - ] - }, - "document": { - "description": "Input document.", - "$ref": "Document" - } - }, - "id": "AnalyzeSyntaxRequest", - "description": "The syntax analysis request message.", - "type": "object" - }, - "AnalyzeEntitiesResponse": { - "properties": { - "entities": { - "description": "The recognized entities in the input document.", - "type": "array", - "items": { - "$ref": "Entity" - } - }, - "language": { - "description": "The language of the text, which will be the same as the language specified\nin the request or, if not specified, the automatically-detected language.\nSee Document.language field for more details.", - "type": "string" - } - }, - "id": "AnalyzeEntitiesResponse", - "description": "The entity analysis response message.", - "type": "object" - }, - "Entity": { - "description": "Represents a phrase in the text that is a known entity, such as\na person, an organization, or location. The API associates information, such\nas salience and mentions, with entities.", - "type": "object", - "properties": { - "mentions": { - "description": "The mentions of this entity in the input document. The API currently\nsupports proper noun mentions.", - "type": "array", - "items": { - "$ref": "EntityMention" - } - }, - "name": { - "description": "The representative name for the entity.", - "type": "string" - }, - "type": { - "enum": [ - "UNKNOWN", - "PERSON", - "LOCATION", - "ORGANIZATION", - "EVENT", - "WORK_OF_ART", - "CONSUMER_GOOD", - "OTHER" - ], - "description": "The entity type.", - "type": "string", - "enumDescriptions": [ - "Unknown", - "Person", - "Location", - "Organization", - "Event", - "Work of art", - "Consumer goods", - "Other types" - ] - }, - "metadata": { - "additionalProperties": { - "type": "string" - }, - "description": "Metadata associated with the entity.\n\nCurrently, Wikipedia URLs and Knowledge Graph MIDs are provided, if\navailable. The associated keys are \"wikipedia_url\" and \"mid\", respectively.", - "type": "object" - }, - "salience": { - "description": "The salience score associated with the entity in the [0, 1.0] range.\n\nThe salience score for an entity provides information about the\nimportance or centrality of that entity to the entire document text.\nScores closer to 0 are less salient, while scores closer to 1.0 are highly\nsalient.", - "format": "float", - "type": "number" - }, - "sentiment": { - "description": "For calls to AnalyzeEntitySentiment or if\nAnnotateTextRequest.Features.extract_entity_sentiment is set to\ntrue, this field will contain the aggregate sentiment expressed for this\nentity in the provided document.", - "$ref": "Sentiment" - } - }, - "id": "Entity" - }, - "AnnotateTextRequest": { - "properties": { - "encodingType": { - "enum": [ - "NONE", - "UTF8", - "UTF16", - "UTF32" - ], - "description": "The encoding type used by the API to calculate offsets.", - "type": "string", - "enumDescriptions": [ - "If `EncodingType` is not specified, encoding-dependent information (such as\n`begin_offset`) will be set at `-1`.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-8 encoding of the input. C++ and Go are examples of languages\nthat use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-16 encoding of the input. Java and Javascript are examples of\nlanguages that use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-32 encoding of the input. Python is an example of a language\nthat uses this encoding natively." - ] - }, - "document": { - "description": "Input document.", - "$ref": "Document" - }, - "features": { - "description": "The enabled features.", - "$ref": "Features" - } - }, - "id": "AnnotateTextRequest", - "description": "The request message for the text annotation API, which can perform multiple\nanalysis types (sentiment, entities, and syntax) in one call.", - "type": "object" - }, - "AnalyzeSentimentRequest": { - "description": "The sentiment analysis request message.", - "type": "object", - "properties": { - "encodingType": { - "enum": [ - "NONE", - "UTF8", - "UTF16", - "UTF32" - ], - "description": "The encoding type used by the API to calculate sentence offsets.", - "type": "string", - "enumDescriptions": [ - "If `EncodingType` is not specified, encoding-dependent information (such as\n`begin_offset`) will be set at `-1`.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-8 encoding of the input. C++ and Go are examples of languages\nthat use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-16 encoding of the input. Java and Javascript are examples of\nlanguages that use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-32 encoding of the input. Python is an example of a language\nthat uses this encoding natively." - ] - }, - "document": { - "$ref": "Document", - "description": "Input document." - } - }, - "id": "AnalyzeSentimentRequest" - }, - "Status": { - "properties": { - "details": { - "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use.", - "type": "array", - "items": { - "additionalProperties": { - "description": "Properties of the object. Contains field @type with type URL.", - "type": "any" - }, - "type": "object" - } - }, - "code": { - "description": "The status code, which should be an enum value of google.rpc.Code.", - "format": "int32", - "type": "integer" - }, - "message": { - "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\ngoogle.rpc.Status.details field, or localized by the client.", - "type": "string" - } - }, - "id": "Status", - "description": "The `Status` type defines a logical error model that is suitable for different\nprogramming environments, including REST APIs and RPC APIs. It is used by\n[gRPC](https://github.com/grpc). The error model is designed to be:\n\n- Simple to use and understand for most users\n- Flexible enough to meet unexpected needs\n\n# Overview\n\nThe `Status` message contains three pieces of data: error code, error message,\nand error details. The error code should be an enum value of\ngoogle.rpc.Code, but it may accept additional error codes if needed. The\nerror message should be a developer-facing English message that helps\ndevelopers *understand* and *resolve* the error. If a localized user-facing\nerror message is needed, put the localized message in the error details or\nlocalize it in the client. The optional error details may contain arbitrary\ninformation about the error. There is a predefined set of error detail types\nin the package `google.rpc` that can be used for common error conditions.\n\n# Language mapping\n\nThe `Status` message is the logical representation of the error model, but it\nis not necessarily the actual wire format. When the `Status` message is\nexposed in different client libraries and different wire protocols, it can be\nmapped differently. For example, it will likely be mapped to some exceptions\nin Java, but more likely mapped to some error codes in C.\n\n# Other uses\n\nThe error model and the `Status` message can be used in a variety of\nenvironments, either with or without APIs, to provide a\nconsistent developer experience across different environments.\n\nExample uses of this error model include:\n\n- Partial errors. If a service needs to return partial errors to the client,\n it may embed the `Status` in the normal response to indicate the partial\n errors.\n\n- Workflow errors. A typical workflow has multiple steps. Each step may\n have a `Status` message for error reporting.\n\n- Batch operations. If a client uses batch request and batch response, the\n `Status` message should be used directly inside batch response, one for\n each error sub-response.\n\n- Asynchronous operations. If an API call embeds asynchronous operation\n results in its response, the status of those operations should be\n represented directly using the `Status` message.\n\n- Logging. If some API errors are stored in logs, the message `Status` could\n be used directly after any stripping needed for security/privacy reasons.", - "type": "object" - }, - "Features": { - "description": "All available features for sentiment, syntax, and semantic analysis.\nSetting each one to true will enable that specific analysis for the input.", - "type": "object", - "properties": { - "classifyText": { - "description": "Classify the full document into categories.", - "type": "boolean" - }, - "extractSyntax": { - "description": "Extract syntax information.", - "type": "boolean" - }, - "extractDocumentSentiment": { - "description": "Extract document-level sentiment.", - "type": "boolean" - }, - "extractEntitySentiment": { - "description": "Extract entities and their associated sentiment.", - "type": "boolean" - }, - "extractEntities": { - "description": "Extract entities.", - "type": "boolean" - } - }, - "id": "Features" - }, - "Document": { - "description": "################################################################ #\n\nRepresents the input to API methods.", - "type": "object", - "properties": { - "language": { - "description": "The language of the document (if not specified, the language is\nautomatically detected). Both ISO and BCP-47 language codes are\naccepted.\u003cbr\u003e\n[Language Support](/natural-language/docs/languages)\nlists currently supported languages for each API method.\nIf the language (either specified by the caller or automatically detected)\nis not supported by the called API method, an `INVALID_ARGUMENT` error\nis returned.", - "type": "string" - }, - "type": { - "enumDescriptions": [ - "The content type is not specified.", - "Plain text", - "HTML" - ], - "enum": [ - "TYPE_UNSPECIFIED", - "PLAIN_TEXT", - "HTML" - ], - "description": "Required. If the type is not set or is `TYPE_UNSPECIFIED`,\nreturns an `INVALID_ARGUMENT` error.", - "type": "string" - }, - "content": { - "description": "The content of the input in string format.", - "type": "string" - }, - "gcsContentUri": { - "description": "The Google Cloud Storage URI where the file content is located.\nThis URI must be of the form: gs://bucket_name/object_name. For more\ndetails, see https://cloud.google.com/storage/docs/reference-uris.\nNOTE: Cloud Storage object versioning is not supported.", - "type": "string" - } - }, - "id": "Document" - }, - "AnalyzeEntitiesRequest": { - "description": "The entity analysis request message.", - "type": "object", - "properties": { - "encodingType": { - "enumDescriptions": [ - "If `EncodingType` is not specified, encoding-dependent information (such as\n`begin_offset`) will be set at `-1`.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-8 encoding of the input. C++ and Go are examples of languages\nthat use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-16 encoding of the input. Java and Javascript are examples of\nlanguages that use this encoding natively.", - "Encoding-dependent information (such as `begin_offset`) is calculated based\non the UTF-32 encoding of the input. Python is an example of a language\nthat uses this encoding natively." - ], - "enum": [ - "NONE", - "UTF8", - "UTF16", - "UTF32" - ], - "description": "The encoding type used by the API to calculate offsets.", - "type": "string" - }, - "document": { - "description": "Input document.", - "$ref": "Document" - } - }, - "id": "AnalyzeEntitiesRequest" - }, - "ClassifyTextRequest": { - "description": "The document classification request message.", - "type": "object", - "properties": { - "document": { - "description": "Input document.", - "$ref": "Document" - } - }, - "id": "ClassifyTextRequest" - }, - "AnalyzeEntitySentimentResponse": { - "properties": { - "language": { - "description": "The language of the text, which will be the same as the language specified\nin the request or, if not specified, the automatically-detected language.\nSee Document.language field for more details.", - "type": "string" - }, - "entities": { - "description": "The recognized entities in the input document with associated sentiments.", - "type": "array", - "items": { - "$ref": "Entity" - } - } - }, - "id": "AnalyzeEntitySentimentResponse", - "description": "The entity-level sentiment analysis response message.", - "type": "object" - }, - "AnalyzeSentimentResponse": { - "description": "The sentiment analysis response message.", - "type": "object", - "properties": { - "language": { - "description": "The language of the text, which will be the same as the language specified\nin the request or, if not specified, the automatically-detected language.\nSee Document.language field for more details.", - "type": "string" - }, - "sentences": { - "description": "The sentiment for all the sentences in the document.", - "type": "array", - "items": { - "$ref": "Sentence" - } - }, - "documentSentiment": { - "$ref": "Sentiment", - "description": "The overall sentiment of the input document." - } - }, - "id": "AnalyzeSentimentResponse" - }, - "AnalyzeSyntaxResponse": { - "description": "The syntax analysis response message.", - "type": "object", - "properties": { - "language": { - "description": "The language of the text, which will be the same as the language specified\nin the request or, if not specified, the automatically-detected language.\nSee Document.language field for more details.", - "type": "string" - }, - "sentences": { - "description": "Sentences in the input document.", - "type": "array", - "items": { - "$ref": "Sentence" - } - }, - "tokens": { - "description": "Tokens, along with their syntactic information, in the input document.", - "type": "array", - "items": { - "$ref": "Token" - } - } - }, - "id": "AnalyzeSyntaxResponse" - }, - "AnnotateTextResponse": { - "properties": { - "language": { - "description": "The language of the text, which will be the same as the language specified\nin the request or, if not specified, the automatically-detected language.\nSee Document.language field for more details.", - "type": "string" - }, - "entities": { - "description": "Entities, along with their semantic information, in the input document.\nPopulated if the user enables\nAnnotateTextRequest.Features.extract_entities.", - "type": "array", - "items": { - "$ref": "Entity" - } - }, - "sentences": { - "description": "Sentences in the input document. Populated if the user enables\nAnnotateTextRequest.Features.extract_syntax.", - "type": "array", - "items": { - "$ref": "Sentence" - } - }, - "tokens": { - "description": "Tokens, along with their syntactic information, in the input document.\nPopulated if the user enables\nAnnotateTextRequest.Features.extract_syntax.", - "type": "array", - "items": { - "$ref": "Token" - } - }, - "categories": { - "description": "Categories identified in the input document.", - "type": "array", - "items": { - "$ref": "ClassificationCategory" - } - }, - "documentSentiment": { - "$ref": "Sentiment", - "description": "The overall sentiment for the document. Populated if the user enables\nAnnotateTextRequest.Features.extract_document_sentiment." - } - }, - "id": "AnnotateTextResponse", - "description": "The text annotations response message.", - "type": "object" - }, - "DependencyEdge": { - "properties": { - "headTokenIndex": { - "description": "Represents the head of this token in the dependency tree.\nThis is the index of the token which has an arc going to this token.\nThe index is the position of the token in the array of tokens returned\nby the API method. If this token is a root token, then the\n`head_token_index` is its own index.", - "format": "int32", - "type": "integer" - }, - "label": { - "enum": [ - "UNKNOWN", - "ABBREV", - "ACOMP", - "ADVCL", - "ADVMOD", - "AMOD", - "APPOS", - "ATTR", - "AUX", - "AUXPASS", - "CC", - "CCOMP", - "CONJ", - "CSUBJ", - "CSUBJPASS", - "DEP", - "DET", - "DISCOURSE", - "DOBJ", - "EXPL", - "GOESWITH", - "IOBJ", - "MARK", - "MWE", - "MWV", - "NEG", - "NN", - "NPADVMOD", - "NSUBJ", - "NSUBJPASS", - "NUM", - "NUMBER", - "P", - "PARATAXIS", - "PARTMOD", - "PCOMP", - "POBJ", - "POSS", - "POSTNEG", - "PRECOMP", - "PRECONJ", - "PREDET", - "PREF", - "PREP", - "PRONL", - "PRT", - "PS", - "QUANTMOD", - "RCMOD", - "RCMODREL", - "RDROP", - "REF", - "REMNANT", - "REPARANDUM", - "ROOT", - "SNUM", - "SUFF", - "TMOD", - "TOPIC", - "VMOD", - "VOCATIVE", - "XCOMP", - "SUFFIX", - "TITLE", - "ADVPHMOD", - "AUXCAUS", - "AUXVV", - "DTMOD", - "FOREIGN", - "KW", - "LIST", - "NOMC", - "NOMCSUBJ", - "NOMCSUBJPASS", - "NUMC", - "COP", - "DISLOCATED", - "ASP", - "GMOD", - "GOBJ", - "INFMOD", - "MES", - "NCOMP" - ], - "description": "The parse label for the token.", - "type": "string", - "enumDescriptions": [ - "Unknown", - "Abbreviation modifier", - "Adjectival complement", - "Adverbial clause modifier", - "Adverbial modifier", - "Adjectival modifier of an NP", - "Appositional modifier of an NP", - "Attribute dependent of a copular verb", - "Auxiliary (non-main) verb", - "Passive auxiliary", - "Coordinating conjunction", - "Clausal complement of a verb or adjective", - "Conjunct", - "Clausal subject", - "Clausal passive subject", - "Dependency (unable to determine)", - "Determiner", - "Discourse", - "Direct object", - "Expletive", - "Goes with (part of a word in a text not well edited)", - "Indirect object", - "Marker (word introducing a subordinate clause)", - "Multi-word expression", - "Multi-word verbal expression", - "Negation modifier", - "Noun compound modifier", - "Noun phrase used as an adverbial modifier", - "Nominal subject", - "Passive nominal subject", - "Numeric modifier of a noun", - "Element of compound number", - "Punctuation mark", - "Parataxis relation", - "Participial modifier", - "The complement of a preposition is a clause", - "Object of a preposition", - "Possession modifier", - "Postverbal negative particle", - "Predicate complement", - "Preconjunt", - "Predeterminer", - "Prefix", - "Prepositional modifier", - "The relationship between a verb and verbal morpheme", - "Particle", - "Associative or possessive marker", - "Quantifier phrase modifier", - "Relative clause modifier", - "Complementizer in relative clause", - "Ellipsis without a preceding predicate", - "Referent", - "Remnant", - "Reparandum", - "Root", - "Suffix specifying a unit of number", - "Suffix", - "Temporal modifier", - "Topic marker", - "Clause headed by an infinite form of the verb that modifies a noun", - "Vocative", - "Open clausal complement", - "Name suffix", - "Name title", - "Adverbial phrase modifier", - "Causative auxiliary", - "Helper auxiliary", - "Rentaishi (Prenominal modifier)", - "Foreign words", - "Keyword", - "List for chains of comparable items", - "Nominalized clause", - "Nominalized clausal subject", - "Nominalized clausal passive", - "Compound of numeric modifier", - "Copula", - "Dislocated relation (for fronted/topicalized elements)", - "Aspect marker", - "Genitive modifier", - "Genitive object", - "Infinitival modifier", - "Measure", - "Nominal complement of a noun" - ] - } - }, - "id": "DependencyEdge", - "description": "Represents dependency parse tree information for a token. (For more\ninformation on dependency labels, see\nhttp://www.aclweb.org/anthology/P13-2017", - "type": "object" - }, - "TextSpan": { - "properties": { - "beginOffset": { - "description": "The API calculates the beginning offset of the content in the original\ndocument according to the EncodingType specified in the API request.", - "format": "int32", - "type": "integer" - }, - "content": { - "description": "The content of the output text.", - "type": "string" - } - }, - "id": "TextSpan", - "description": "Represents an output piece of text.", - "type": "object" - }, - "Token": { - "properties": { - "lemma": { - "description": "[Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token.", - "type": "string" - }, - "partOfSpeech": { - "description": "Parts of speech tag for this token.", - "$ref": "PartOfSpeech" - }, - "text": { - "$ref": "TextSpan", - "description": "The token text." - }, - "dependencyEdge": { - "$ref": "DependencyEdge", - "description": "Dependency tree parse for this token." - } - }, - "id": "Token", - "description": "Represents the smallest syntactic building block of the text.", - "type": "object" - }, - "EntityMention": { - "properties": { - "sentiment": { - "$ref": "Sentiment", - "description": "For calls to AnalyzeEntitySentiment or if\nAnnotateTextRequest.Features.extract_entity_sentiment is set to\ntrue, this field will contain the sentiment expressed for this mention of\nthe entity in the provided document." - }, - "text": { - "$ref": "TextSpan", - "description": "The mention text." - }, - "type": { - "enumDescriptions": [ - "Unknown", - "Proper name", - "Common noun (or noun compound)" - ], - "enum": [ - "TYPE_UNKNOWN", - "PROPER", - "COMMON" - ], - "description": "The type of the entity mention.", - "type": "string" - } - }, - "id": "EntityMention", - "description": "Represents a mention for an entity in the text. Currently, proper noun\nmentions are supported.", - "type": "object" - }, - "ClassifyTextResponse": { - "properties": { - "categories": { - "description": "Categories representing the input document.", - "type": "array", - "items": { - "$ref": "ClassificationCategory" - } - } - }, - "id": "ClassifyTextResponse", - "description": "The document classification response message.", - "type": "object" - }, - "Sentence": { - "description": "Represents a sentence in the input document.", - "type": "object", - "properties": { - "sentiment": { - "description": "For calls to AnalyzeSentiment or if\nAnnotateTextRequest.Features.extract_document_sentiment is set to\ntrue, this field will contain the sentiment for the sentence.", - "$ref": "Sentiment" - }, - "text": { - "description": "The sentence text.", - "$ref": "TextSpan" - } - }, - "id": "Sentence" - }, - "Sentiment": { - "description": "Represents the feeling associated with the entire text or entities in\nthe text.", - "type": "object", - "properties": { - "magnitude": { - "description": "A non-negative number in the [0, +inf) range, which represents\nthe absolute magnitude of sentiment regardless of score (positive or\nnegative).", - "format": "float", - "type": "number" - }, - "score": { - "description": "Sentiment score between -1.0 (negative sentiment) and 1.0\n(positive sentiment).", - "format": "float", - "type": "number" - } - }, - "id": "Sentiment" - } - }, - "icons": { - "x16": "http://www.google.com/images/icons/product/search-16.gif", - "x32": "http://www.google.com/images/icons/product/search-32.gif" - }, - "protocol": "rest", - "canonicalName": "Cloud Natural Language", - "auth": { - "oauth2": { - "scopes": { - "https://www.googleapis.com/auth/cloud-platform": { - "description": "View and manage your data across Google Cloud Platform services" - }, - "https://www.googleapis.com/auth/cloud-language": { - "description": "Apply machine learning models to reveal the structure and meaning of text" - } - } - } - }, - "rootUrl": "https://language.googleapis.com/", - "ownerDomain": "google.com", - "name": "language", - "batchPath": "batch" -} diff --git a/Language/src/LanguageClient.php b/Language/src/LanguageClient.php deleted file mode 100644 index 0642f499351..00000000000 --- a/Language/src/LanguageClient.php +++ /dev/null @@ -1,526 +0,0 @@ - 'extractSyntax', - 'entities' => 'extractEntities', - 'sentiment' => 'extractDocumentSentiment', - 'entitySentiment' => 'extractEntitySentiment', - 'classify' => 'classifyText' - ]; - - /** - * @var ConnectionInterface - * @internal - */ - protected $connection; - - /** - * 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. - * - * @param array $config [optional] { - * Configuration Options. - * - * @type string $apiEndpoint A hostname with optional port to use in - * place of the service's default endpoint. - * @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 FetchAuthTokenInterface $credentialsFetcher A credentials - * fetcher instance. - * @type callable $httpHandler A handler used to deliver Psr7 requests. - * Only valid for requests sent over REST. - * @type array $keyFile The contents of the service account credentials - * .json file retrieved from the Google Developer's Console. - * Ex: `json_decode(file_get_contents($path), true)`. - * @type string $keyFilePath The full path to your service account - * credentials .json file retrieved from the Google Developers - * Console. - * @type float $requestTimeout Seconds to wait before timing out the - * request. **Defaults to** `0` with REST and `60` with gRPC. - * @type int $retries Number of retries for a failed request. - * **Defaults to** `3`. - * @type array $scopes Scopes to be used for the request. - * @type string $quotaProject Specifies a user project to bill for - * access charges associated with the request. - * } - * @throws \InvalidArgumentException - */ - public function __construct(array $config = []) - { - $config += [ - 'scopes' => [self::FULL_CONTROL_SCOPE], - 'restRetryFunction' => $this->getRetryFunction(false) - ]; - - $this->connection = new Rest($this->configureAuthentication($config)); - } - - /** - * Finds named entities (currently finds proper names) in the text, entity - * types, salience, mentions for each entity, and other properties in the - * document. - * - * Example: - * ``` - * $annotation = $language->analyzeEntities('Google Cloud Platform is a powerful tool.'); - * - * foreach ($annotation->entities() as $entity) { - * echo $entity['type']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/analyzeEntities Analyze Entities API documentation - * @codingStandardsIgnoreEnd - * - * @param string|StorageObject $content 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 - * `gs://{bucket-name}/{object-name}` or a - * {@see \Google\Cloud\Storage\StorageObject}. - * @param array $options [optional] { - * Configuration options. - * - * @type bool $detectGcsUri 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 - * `gs://{bucket-name}/{object-name}`. **Defaults to** `true`. - * @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"`. Please note - * the following behaviors for the encoding type setting: `"NONE"` - * will return a value of "-1" for offsets. `"UTF8"` will - * return byte offsets. `"UTF16"` will return - * [code unit](http://unicode.org/glossary/#code_unit) offsets. - * `"UTF32"` will return - * [unicode character](http://unicode.org/glossary/#character) - * offsets. - * } - * @return Annotation - */ - public function analyzeEntities($content, array $options = []) - { - return new Annotation( - $this->connection->analyzeEntities( - $this->formatRequest($content, $options) - ) - ); - } - - /** - * Analyzes the sentiment of the provided document. - * - * Example: - * ``` - * $annotation = $language->analyzeSentiment('Google Cloud Platform is a powerful tool.'); - * $sentiment = $annotation->sentiment(); - * - * if ($sentiment['score'] > 0) { - * echo 'This is a positive message.'; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/analyzeSentiment Analyze Sentiment API documentation - * @codingStandardsIgnoreEnd - * - * @param string|StorageObject $content 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 - * `gs://{bucket-name}/{object-name}` or a - * {@see \Google\Cloud\Storage\StorageObject}. - * @param array $options [optional] { - * Configuration options. - * - * @type bool $detectGcsUri 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 - * `gs://{bucket-name}/{object-name}`. **Defaults to** `true`. - * @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"`. Please note - * the following behaviors for the encoding type setting: `"NONE"` - * will return a value of "-1" for offsets. `"UTF8"` will - * return byte offsets. `"UTF16"` will return - * [code unit](http://unicode.org/glossary/#code_unit) offsets. - * `"UTF32"` will return - * [unicode character](http://unicode.org/glossary/#character) - * offsets. - * } - * @return Annotation - */ - public function analyzeSentiment($content, array $options = []) - { - return new Annotation( - $this->connection->analyzeSentiment( - $this->formatRequest($content, $options) - ) - ); - } - - /** - * Finds entities in the text and analyzes sentiment associated with each - * entity and its mentions. - * - * Example: - * ``` - * $annotation = $language->analyzeEntitySentiment('Google Cloud Platform is a powerful tool.'); - * $entities = $annotation->entities(); - * - * echo 'Entity name: ' . $entities[0]['name'] . PHP_EOL; - * if ($entities[0]['sentiment']['score'] > 0) { - * echo 'This is a positive message.'; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/analyzeEntitySentiment Analyze Entity Sentiment API documentation - * @codingStandardsIgnoreEnd - * - * @param string|StorageObject $content 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 - * `gs://{bucket-name}/{object-name}` or a - * {@see \Google\Cloud\Storage\StorageObject}. - * @param array $options [optional] { - * Configuration options. - * - * @type bool $detectGcsUri 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 - * `gs://{bucket-name}/{object-name}`. **Defaults to** `true`. - * @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"`. Please note - * the following behaviors for the encoding type setting: `"NONE"` - * will return a value of "-1" for offsets. `"UTF8"` will - * return byte offsets. `"UTF16"` will return - * [code unit](http://unicode.org/glossary/#code_unit) offsets. - * `"UTF32"` will return - * [unicode character](http://unicode.org/glossary/#character) - * offsets. - * } - * @return Annotation - */ - public function analyzeEntitySentiment($content, array $options = []) - { - return new Annotation( - $this->connection->analyzeEntitySentiment( - $this->formatRequest($content, $options) - ) - ); - } - - /** - * Analyzes the document and provides a full set of text annotations. - * - * Example: - * ``` - * $annotation = $language->analyzeSyntax('Google Cloud Platform is a powerful tool.'); - * - * foreach ($annotation->sentences() as $sentence) { - * echo $sentence['text']['beginOffset']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/analyzeSyntax Analyze Syntax API documentation - * @codingStandardsIgnoreEnd - * - * @param string|StorageObject $content 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 - * `gs://{bucket-name}/{object-name}` or a - * {@see \Google\Cloud\Storage\StorageObject}. - * @param array $options [optional] { - * Configuration options. - * - * @type bool $detectGcsUri 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 - * `gs://{bucket-name}/{object-name}`. **Defaults to** `true`. - * @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"`. Please note - * the following behaviors for the encoding type setting: `"NONE"` - * will return a value of "-1" for offsets. `"UTF8"` will - * return byte offsets. `"UTF16"` will return - * [code unit](http://unicode.org/glossary/#code_unit) offsets. - * `"UTF32"` will return - * [unicode character](http://unicode.org/glossary/#character) - * offsets. - * } - * @return Annotation - */ - public function analyzeSyntax($content, array $options = []) - { - $syntaxResponse = $this->connection->analyzeSyntax( - $this->formatRequest($content, $options) - ); - - return new Annotation($syntaxResponse + ['entities' => []]); - } - - /** - * Analyzes the document and provides a full set of text annotations, - * including semantic, syntactic, and sentiment information. - * - * Example: - * ``` - * $annotation = $language->classifyText('Google Cloud Platform is a powerful tool.'); - * - * foreach ($annotation->categories() as $category) { - * echo $category['name']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta2/documents/classifyText Classify Text API documentation - * @codingStandardsIgnoreEnd - * - * @param string|StorageObject $content 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 - * `gs://{bucket-name}/{object-name}` or a - * {@see \Google\Cloud\Storage\StorageObject}. - * @param array $options [optional] { - * Configuration options. - * - * @type bool $detectGcsUri 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 - * `gs://{bucket-name}/{object-name}`. **Defaults to** `true`. - * @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. - * } - * @return Annotation - */ - public function classifyText($content, array $options = []) - { - return new Annotation( - $this->connection->classifyText( - $this->formatRequest($content, $options) - ) - ); - } - - /** - * Analyzes the document and provides a full set of text annotations, - * including semantic, syntactic, and sentiment information. - * - * 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']; - * } - * ``` - * - * @codingStandardsIgnoreStart - * @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText Annotate Text API documentation - * @codingStandardsIgnoreEnd - * - * @param string|StorageObject $content 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 - * `gs://{bucket-name}/{object-name}` or a - * {@see \Google\Cloud\Storage\StorageObject}. - * @param array $options [optional] { - * Configuration options. - * - * @type bool $detectGcsUri 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 - * `gs://{bucket-name}/{object-name}`. **Defaults to** `true`. - * @type array $features Features to apply to the request. Valid values - * are `syntax`, `sentiment`, `entities`, `entitySentiment`, and - * `classify`. If no features are provided the request will run - * with all features 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"`. Please note - * the following behaviors for the encoding type setting: `"NONE"` - * will return a value of "-1" for offsets. `"UTF8"` will - * return byte offsets. `"UTF16"` will return - * [code unit](http://unicode.org/glossary/#code_unit) offsets. - * `"UTF32"` will return - * [unicode character](http://unicode.org/glossary/#character) - * offsets. - * } - * @return Annotation - */ - public function annotateText($content, array $options = []) - { - $features = $options['features'] ?? array_values($this->featureShortNames); - $options['features'] = $this->normalizeFeatures($features); - - return new Annotation( - $this->connection->annotateText( - $this->formatRequest($content, $options) - ) - ); - } - - /** - * Configures features in a way the API expects. - * - * @param array $features An array of features to normalize. - * @return array - */ - private function normalizeFeatures(array $features) - { - $results = []; - - foreach ($features as $feature) { - $featureName = array_key_exists($feature, $this->featureShortNames) - ? $this->featureShortNames[$feature] - : $feature; - - $results[$featureName] = true; - } - - return $results; - } - - /** - * Formats the request for the API. - * - * @param string|StorageObject $content The content to analyze. - * @param array $options [optional] Configuration Options. - * @return array - */ - private function formatRequest($content, array $options) - { - $docOptions = ['type', 'language', 'content', 'gcsContentUri']; - $options += [ - 'encodingType' => 'UTF8', - 'type' => 'PLAIN_TEXT', - 'detectGcsUri' => true - ]; - - if ($content instanceof StorageObject) { - $options['gcsContentUri'] = $content->gcsUri(); - } elseif ($options['detectGcsUri'] && substr($content, 0, 5) === 'gs://') { - $options['gcsContentUri'] = $content; - } else { - $options['content'] = $content; - } - - unset($options['detectGcsUri']); - - foreach ($options as $option => $value) { - if (in_array($option, $docOptions)) { - $options['document'][$option] = $value; - unset($options[$option]); - } - } - - return $options; - } -} diff --git a/Language/src/V1/AnnotateTextRequest_Features.php b/Language/src/V1/AnnotateTextRequest_Features.php deleted file mode 100644 index e02aca7493e..00000000000 --- a/Language/src/V1/AnnotateTextRequest_Features.php +++ /dev/null @@ -1,16 +0,0 @@ -analyzeEntities($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @deprecated Please use the new service client {@see \Google\Cloud\Language\V1\Client\LanguageServiceClient}. - */ -class LanguageServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.language.v1.LanguageService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'language.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'language.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/language_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/language_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/language_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/language_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'language.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $response = $languageServiceClient->analyzeEntities($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\AnalyzeEntitiesResponse - * - * @throws ApiException if the remote call fails - */ - public function analyzeEntities($document, array $optionalArgs = []) - { - $request = new AnalyzeEntitiesRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeEntities', AnalyzeEntitiesResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Finds entities, similar to - * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $response = $languageServiceClient->analyzeEntitySentiment($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\AnalyzeEntitySentimentResponse - * - * @throws ApiException if the remote call fails - */ - public function analyzeEntitySentiment($document, array $optionalArgs = []) - { - $request = new AnalyzeEntitySentimentRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeEntitySentiment', AnalyzeEntitySentimentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Analyzes the sentiment of the provided text. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $response = $languageServiceClient->analyzeSentiment($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate sentence offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\AnalyzeSentimentResponse - * - * @throws ApiException if the remote call fails - */ - public function analyzeSentiment($document, array $optionalArgs = []) - { - $request = new AnalyzeSentimentRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeSentiment', AnalyzeSentimentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $response = $languageServiceClient->analyzeSyntax($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\AnalyzeSyntaxResponse - * - * @throws ApiException if the remote call fails - */ - public function analyzeSyntax($document, array $optionalArgs = []) - { - $request = new AnalyzeSyntaxRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeSyntax', AnalyzeSyntaxResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * A convenience method that provides all the features that analyzeSentiment, - * analyzeEntities, and analyzeSyntax provide in one call. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $features = new Google\Cloud\Language\V1\AnnotateTextRequest\Features(); - * $response = $languageServiceClient->annotateText($document, $features); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param Features $features Required. The enabled features. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\AnnotateTextResponse - * - * @throws ApiException if the remote call fails - */ - public function annotateText($document, $features, array $optionalArgs = []) - { - $request = new AnnotateTextRequest(); - $request->setDocument($document); - $request->setFeatures($features); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnnotateText', AnnotateTextResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Classifies a document into categories. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $response = $languageServiceClient->classifyText($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type ClassificationModelOptions $classificationModelOptions - * Model options to use for classification. Defaults to v1 options if not - * specified. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\ClassifyTextResponse - * - * @throws ApiException if the remote call fails - */ - public function classifyText($document, array $optionalArgs = []) - { - $request = new ClassifyTextRequest(); - $request->setDocument($document); - if (isset($optionalArgs['classificationModelOptions'])) { - $request->setClassificationModelOptions($optionalArgs['classificationModelOptions']); - } - - return $this->startCall('ClassifyText', ClassifyTextResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Moderates a document for harmful and sensitive categories. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1\Document(); - * $response = $languageServiceClient->moderateText($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1\ModerateTextResponse - * - * @throws ApiException if the remote call fails - */ - public function moderateText($document, array $optionalArgs = []) - { - $request = new ModerateTextRequest(); - $request->setDocument($document); - return $this->startCall('ModerateText', ModerateTextResponse::class, $optionalArgs, $request)->wait(); - } -} diff --git a/Language/src/V1/LanguageServiceClient.php b/Language/src/V1/LanguageServiceClient.php deleted file mode 100644 index 4259a16440b..00000000000 --- a/Language/src/V1/LanguageServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeSentiment', - $argument, - ['\Google\Cloud\Language\V1\AnalyzeSentimentResponse', 'decode'], - $metadata, $options); - } - - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * @param \Google\Cloud\Language\V1\AnalyzeEntitiesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnalyzeEntities(\Google\Cloud\Language\V1\AnalyzeEntitiesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeEntities', - $argument, - ['\Google\Cloud\Language\V1\AnalyzeEntitiesResponse', 'decode'], - $metadata, $options); - } - - /** - * Finds entities, similar to - * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * @param \Google\Cloud\Language\V1\AnalyzeEntitySentimentRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnalyzeEntitySentiment(\Google\Cloud\Language\V1\AnalyzeEntitySentimentRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment', - $argument, - ['\Google\Cloud\Language\V1\AnalyzeEntitySentimentResponse', 'decode'], - $metadata, $options); - } - - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * @param \Google\Cloud\Language\V1\AnalyzeSyntaxRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnalyzeSyntax(\Google\Cloud\Language\V1\AnalyzeSyntaxRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeSyntax', - $argument, - ['\Google\Cloud\Language\V1\AnalyzeSyntaxResponse', 'decode'], - $metadata, $options); - } - - /** - * Classifies a document into categories. - * @param \Google\Cloud\Language\V1\ClassifyTextRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ClassifyText(\Google\Cloud\Language\V1\ClassifyTextRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/ClassifyText', - $argument, - ['\Google\Cloud\Language\V1\ClassifyTextResponse', 'decode'], - $metadata, $options); - } - - /** - * Moderates a document for harmful and sensitive categories. - * @param \Google\Cloud\Language\V1\ModerateTextRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ModerateText(\Google\Cloud\Language\V1\ModerateTextRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/ModerateText', - $argument, - ['\Google\Cloud\Language\V1\ModerateTextResponse', 'decode'], - $metadata, $options); - } - - /** - * A convenience method that provides all the features that analyzeSentiment, - * analyzeEntities, and analyzeSyntax provide in one call. - * @param \Google\Cloud\Language\V1\AnnotateTextRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnnotateText(\Google\Cloud\Language\V1\AnnotateTextRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnnotateText', - $argument, - ['\Google\Cloud\Language\V1\AnnotateTextResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/Language/src/V1/PartOfSpeech_Aspect.php b/Language/src/V1/PartOfSpeech_Aspect.php deleted file mode 100644 index 87d4732dd0e..00000000000 --- a/Language/src/V1/PartOfSpeech_Aspect.php +++ /dev/null @@ -1,16 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeEntitiesRequest - */ -class AnalyzeEntitiesRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - */ - private $encoding_type = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * @type int $encoding_type - * The encoding type used by the API to calculate offsets. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @return int - */ - public function getEncodingType() - { - return $this->encoding_type; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @param int $var - * @return $this - */ - public function setEncodingType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\EncodingType::class); - $this->encoding_type = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeEntitiesResponse.php b/Language/src/V1beta2/AnalyzeEntitiesResponse.php deleted file mode 100644 index 7c7281ac259..00000000000 --- a/Language/src/V1beta2/AnalyzeEntitiesResponse.php +++ /dev/null @@ -1,113 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeEntitiesResponse - */ -class AnalyzeEntitiesResponse extends \Google\Protobuf\Internal\Message -{ - /** - * The recognized entities in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 1; - */ - private $entities; - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - */ - private $language = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Language\V1beta2\Entity>|\Google\Protobuf\Internal\RepeatedField $entities - * The recognized entities in the input document. - * @type string $language - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The recognized entities in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getEntities() - { - return $this->entities; - } - - /** - * The recognized entities in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 1; - * @param array<\Google\Cloud\Language\V1beta2\Entity>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setEntities($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Entity::class); - $this->entities = $arr; - - return $this; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - * @param string $var - * @return $this - */ - public function setLanguage($var) - { - GPBUtil::checkString($var, True); - $this->language = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeEntitySentimentRequest.php b/Language/src/V1beta2/AnalyzeEntitySentimentRequest.php deleted file mode 100644 index 8726b8f681f..00000000000 --- a/Language/src/V1beta2/AnalyzeEntitySentimentRequest.php +++ /dev/null @@ -1,111 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest - */ -class AnalyzeEntitySentimentRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - */ - private $encoding_type = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * @type int $encoding_type - * The encoding type used by the API to calculate offsets. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @return int - */ - public function getEncodingType() - { - return $this->encoding_type; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @param int $var - * @return $this - */ - public function setEncodingType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\EncodingType::class); - $this->encoding_type = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeEntitySentimentResponse.php b/Language/src/V1beta2/AnalyzeEntitySentimentResponse.php deleted file mode 100644 index 09de485979c..00000000000 --- a/Language/src/V1beta2/AnalyzeEntitySentimentResponse.php +++ /dev/null @@ -1,113 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse - */ -class AnalyzeEntitySentimentResponse extends \Google\Protobuf\Internal\Message -{ - /** - * The recognized entities in the input document with associated sentiments. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 1; - */ - private $entities; - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - */ - private $language = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Language\V1beta2\Entity>|\Google\Protobuf\Internal\RepeatedField $entities - * The recognized entities in the input document with associated sentiments. - * @type string $language - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The recognized entities in the input document with associated sentiments. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getEntities() - { - return $this->entities; - } - - /** - * The recognized entities in the input document with associated sentiments. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 1; - * @param array<\Google\Cloud\Language\V1beta2\Entity>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setEntities($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Entity::class); - $this->entities = $arr; - - return $this; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - * @param string $var - * @return $this - */ - public function setLanguage($var) - { - GPBUtil::checkString($var, True); - $this->language = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeSentimentRequest.php b/Language/src/V1beta2/AnalyzeSentimentRequest.php deleted file mode 100644 index 75fc7448926..00000000000 --- a/Language/src/V1beta2/AnalyzeSentimentRequest.php +++ /dev/null @@ -1,115 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeSentimentRequest - */ -class AnalyzeSentimentRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - /** - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - */ - private $encoding_type = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * @type int $encoding_type - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - - /** - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @return int - */ - public function getEncodingType() - { - return $this->encoding_type; - } - - /** - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @param int $var - * @return $this - */ - public function setEncodingType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\EncodingType::class); - $this->encoding_type = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeSentimentResponse.php b/Language/src/V1beta2/AnalyzeSentimentResponse.php deleted file mode 100644 index d00eea99cff..00000000000 --- a/Language/src/V1beta2/AnalyzeSentimentResponse.php +++ /dev/null @@ -1,157 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeSentimentResponse - */ -class AnalyzeSentimentResponse extends \Google\Protobuf\Internal\Message -{ - /** - * The overall sentiment of the input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment document_sentiment = 1; - */ - private $document_sentiment = null; - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - */ - private $language = ''; - /** - * The sentiment for all the sentences in the document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 3; - */ - private $sentences; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Sentiment $document_sentiment - * The overall sentiment of the input document. - * @type string $language - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * @type array<\Google\Cloud\Language\V1beta2\Sentence>|\Google\Protobuf\Internal\RepeatedField $sentences - * The sentiment for all the sentences in the document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The overall sentiment of the input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment document_sentiment = 1; - * @return \Google\Cloud\Language\V1beta2\Sentiment|null - */ - public function getDocumentSentiment() - { - return $this->document_sentiment; - } - - public function hasDocumentSentiment() - { - return isset($this->document_sentiment); - } - - public function clearDocumentSentiment() - { - unset($this->document_sentiment); - } - - /** - * The overall sentiment of the input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment document_sentiment = 1; - * @param \Google\Cloud\Language\V1beta2\Sentiment $var - * @return $this - */ - public function setDocumentSentiment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Sentiment::class); - $this->document_sentiment = $var; - - return $this; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 2; - * @param string $var - * @return $this - */ - public function setLanguage($var) - { - GPBUtil::checkString($var, True); - $this->language = $var; - - return $this; - } - - /** - * The sentiment for all the sentences in the document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 3; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getSentences() - { - return $this->sentences; - } - - /** - * The sentiment for all the sentences in the document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 3; - * @param array<\Google\Cloud\Language\V1beta2\Sentence>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setSentences($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Sentence::class); - $this->sentences = $arr; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeSyntaxRequest.php b/Language/src/V1beta2/AnalyzeSyntaxRequest.php deleted file mode 100644 index 7c2fb8221e3..00000000000 --- a/Language/src/V1beta2/AnalyzeSyntaxRequest.php +++ /dev/null @@ -1,111 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeSyntaxRequest - */ -class AnalyzeSyntaxRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - */ - private $encoding_type = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * @type int $encoding_type - * The encoding type used by the API to calculate offsets. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @return int - */ - public function getEncodingType() - { - return $this->encoding_type; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 2; - * @param int $var - * @return $this - */ - public function setEncodingType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\EncodingType::class); - $this->encoding_type = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnalyzeSyntaxResponse.php b/Language/src/V1beta2/AnalyzeSyntaxResponse.php deleted file mode 100644 index d4c20adb6a9..00000000000 --- a/Language/src/V1beta2/AnalyzeSyntaxResponse.php +++ /dev/null @@ -1,147 +0,0 @@ -google.cloud.language.v1beta2.AnalyzeSyntaxResponse - */ -class AnalyzeSyntaxResponse extends \Google\Protobuf\Internal\Message -{ - /** - * Sentences in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 1; - */ - private $sentences; - /** - * Tokens, along with their syntactic information, in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Token tokens = 2; - */ - private $tokens; - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 3; - */ - private $language = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Language\V1beta2\Sentence>|\Google\Protobuf\Internal\RepeatedField $sentences - * Sentences in the input document. - * @type array<\Google\Cloud\Language\V1beta2\Token>|\Google\Protobuf\Internal\RepeatedField $tokens - * Tokens, along with their syntactic information, in the input document. - * @type string $language - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Sentences in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getSentences() - { - return $this->sentences; - } - - /** - * Sentences in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 1; - * @param array<\Google\Cloud\Language\V1beta2\Sentence>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setSentences($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Sentence::class); - $this->sentences = $arr; - - return $this; - } - - /** - * Tokens, along with their syntactic information, in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Token tokens = 2; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTokens() - { - return $this->tokens; - } - - /** - * Tokens, along with their syntactic information, in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Token tokens = 2; - * @param array<\Google\Cloud\Language\V1beta2\Token>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTokens($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Token::class); - $this->tokens = $arr; - - return $this; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 3; - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 3; - * @param string $var - * @return $this - */ - public function setLanguage($var) - { - GPBUtil::checkString($var, True); - $this->language = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnnotateTextRequest.php b/Language/src/V1beta2/AnnotateTextRequest.php deleted file mode 100644 index c719feae240..00000000000 --- a/Language/src/V1beta2/AnnotateTextRequest.php +++ /dev/null @@ -1,156 +0,0 @@ -google.cloud.language.v1beta2.AnnotateTextRequest - */ -class AnnotateTextRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - /** - * Required. The enabled features. - * - * Generated from protobuf field .google.cloud.language.v1beta2.AnnotateTextRequest.Features features = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $features = null; - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 3; - */ - private $encoding_type = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * @type \Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features $features - * Required. The enabled features. - * @type int $encoding_type - * The encoding type used by the API to calculate offsets. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - - /** - * Required. The enabled features. - * - * Generated from protobuf field .google.cloud.language.v1beta2.AnnotateTextRequest.Features features = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features|null - */ - public function getFeatures() - { - return $this->features; - } - - public function hasFeatures() - { - return isset($this->features); - } - - public function clearFeatures() - { - unset($this->features); - } - - /** - * Required. The enabled features. - * - * Generated from protobuf field .google.cloud.language.v1beta2.AnnotateTextRequest.Features features = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features $var - * @return $this - */ - public function setFeatures($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features::class); - $this->features = $var; - - return $this; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 3; - * @return int - */ - public function getEncodingType() - { - return $this->encoding_type; - } - - /** - * The encoding type used by the API to calculate offsets. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EncodingType encoding_type = 3; - * @param int $var - * @return $this - */ - public function setEncodingType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\EncodingType::class); - $this->encoding_type = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/AnnotateTextRequest/Features.php b/Language/src/V1beta2/AnnotateTextRequest/Features.php deleted file mode 100644 index 2d1108fe91c..00000000000 --- a/Language/src/V1beta2/AnnotateTextRequest/Features.php +++ /dev/null @@ -1,302 +0,0 @@ -google.cloud.language.v1beta2.AnnotateTextRequest.Features - */ -class Features extends \Google\Protobuf\Internal\Message -{ - /** - * Extract syntax information. - * - * Generated from protobuf field bool extract_syntax = 1; - */ - private $extract_syntax = false; - /** - * Extract entities. - * - * Generated from protobuf field bool extract_entities = 2; - */ - private $extract_entities = false; - /** - * Extract document-level sentiment. - * - * Generated from protobuf field bool extract_document_sentiment = 3; - */ - private $extract_document_sentiment = false; - /** - * Extract entities and their associated sentiment. - * - * Generated from protobuf field bool extract_entity_sentiment = 4; - */ - private $extract_entity_sentiment = false; - /** - * Classify the full document into categories. If this is true, - * the API will use the default model which classifies into a - * [predefined - * taxonomy](https://cloud.google.com/natural-language/docs/categories). - * - * Generated from protobuf field bool classify_text = 6; - */ - private $classify_text = false; - /** - * Moderate the document for harmful and sensitive categories. - * - * Generated from protobuf field bool moderate_text = 11; - */ - private $moderate_text = false; - /** - * The model options to use for classification. Defaults to v1 options - * if not specified. Only used if `classify_text` is set to true. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions classification_model_options = 10; - */ - private $classification_model_options = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type bool $extract_syntax - * Extract syntax information. - * @type bool $extract_entities - * Extract entities. - * @type bool $extract_document_sentiment - * Extract document-level sentiment. - * @type bool $extract_entity_sentiment - * Extract entities and their associated sentiment. - * @type bool $classify_text - * Classify the full document into categories. If this is true, - * the API will use the default model which classifies into a - * [predefined - * taxonomy](https://cloud.google.com/natural-language/docs/categories). - * @type bool $moderate_text - * Moderate the document for harmful and sensitive categories. - * @type \Google\Cloud\Language\V1beta2\ClassificationModelOptions $classification_model_options - * The model options to use for classification. Defaults to v1 options - * if not specified. Only used if `classify_text` is set to true. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Extract syntax information. - * - * Generated from protobuf field bool extract_syntax = 1; - * @return bool - */ - public function getExtractSyntax() - { - return $this->extract_syntax; - } - - /** - * Extract syntax information. - * - * Generated from protobuf field bool extract_syntax = 1; - * @param bool $var - * @return $this - */ - public function setExtractSyntax($var) - { - GPBUtil::checkBool($var); - $this->extract_syntax = $var; - - return $this; - } - - /** - * Extract entities. - * - * Generated from protobuf field bool extract_entities = 2; - * @return bool - */ - public function getExtractEntities() - { - return $this->extract_entities; - } - - /** - * Extract entities. - * - * Generated from protobuf field bool extract_entities = 2; - * @param bool $var - * @return $this - */ - public function setExtractEntities($var) - { - GPBUtil::checkBool($var); - $this->extract_entities = $var; - - return $this; - } - - /** - * Extract document-level sentiment. - * - * Generated from protobuf field bool extract_document_sentiment = 3; - * @return bool - */ - public function getExtractDocumentSentiment() - { - return $this->extract_document_sentiment; - } - - /** - * Extract document-level sentiment. - * - * Generated from protobuf field bool extract_document_sentiment = 3; - * @param bool $var - * @return $this - */ - public function setExtractDocumentSentiment($var) - { - GPBUtil::checkBool($var); - $this->extract_document_sentiment = $var; - - return $this; - } - - /** - * Extract entities and their associated sentiment. - * - * Generated from protobuf field bool extract_entity_sentiment = 4; - * @return bool - */ - public function getExtractEntitySentiment() - { - return $this->extract_entity_sentiment; - } - - /** - * Extract entities and their associated sentiment. - * - * Generated from protobuf field bool extract_entity_sentiment = 4; - * @param bool $var - * @return $this - */ - public function setExtractEntitySentiment($var) - { - GPBUtil::checkBool($var); - $this->extract_entity_sentiment = $var; - - return $this; - } - - /** - * Classify the full document into categories. If this is true, - * the API will use the default model which classifies into a - * [predefined - * taxonomy](https://cloud.google.com/natural-language/docs/categories). - * - * Generated from protobuf field bool classify_text = 6; - * @return bool - */ - public function getClassifyText() - { - return $this->classify_text; - } - - /** - * Classify the full document into categories. If this is true, - * the API will use the default model which classifies into a - * [predefined - * taxonomy](https://cloud.google.com/natural-language/docs/categories). - * - * Generated from protobuf field bool classify_text = 6; - * @param bool $var - * @return $this - */ - public function setClassifyText($var) - { - GPBUtil::checkBool($var); - $this->classify_text = $var; - - return $this; - } - - /** - * Moderate the document for harmful and sensitive categories. - * - * Generated from protobuf field bool moderate_text = 11; - * @return bool - */ - public function getModerateText() - { - return $this->moderate_text; - } - - /** - * Moderate the document for harmful and sensitive categories. - * - * Generated from protobuf field bool moderate_text = 11; - * @param bool $var - * @return $this - */ - public function setModerateText($var) - { - GPBUtil::checkBool($var); - $this->moderate_text = $var; - - return $this; - } - - /** - * The model options to use for classification. Defaults to v1 options - * if not specified. Only used if `classify_text` is set to true. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions classification_model_options = 10; - * @return \Google\Cloud\Language\V1beta2\ClassificationModelOptions|null - */ - public function getClassificationModelOptions() - { - return $this->classification_model_options; - } - - public function hasClassificationModelOptions() - { - return isset($this->classification_model_options); - } - - public function clearClassificationModelOptions() - { - unset($this->classification_model_options); - } - - /** - * The model options to use for classification. Defaults to v1 options - * if not specified. Only used if `classify_text` is set to true. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions classification_model_options = 10; - * @param \Google\Cloud\Language\V1beta2\ClassificationModelOptions $var - * @return $this - */ - public function setClassificationModelOptions($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\ClassificationModelOptions::class); - $this->classification_model_options = $var; - - return $this; - } - -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Features::class, \Google\Cloud\Language\V1beta2\AnnotateTextRequest_Features::class); - diff --git a/Language/src/V1beta2/AnnotateTextRequest_Features.php b/Language/src/V1beta2/AnnotateTextRequest_Features.php deleted file mode 100644 index e1f981a3475..00000000000 --- a/Language/src/V1beta2/AnnotateTextRequest_Features.php +++ /dev/null @@ -1,16 +0,0 @@ -google.cloud.language.v1beta2.AnnotateTextResponse - */ -class AnnotateTextResponse extends \Google\Protobuf\Internal\Message -{ - /** - * Sentences in the input document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 1; - */ - private $sentences; - /** - * Tokens, along with their syntactic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Token tokens = 2; - */ - private $tokens; - /** - * Entities, along with their semantic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 3; - */ - private $entities; - /** - * The overall sentiment for the document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment document_sentiment = 4; - */ - private $document_sentiment = null; - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 5; - */ - private $language = ''; - /** - * Categories identified in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory categories = 6; - */ - private $categories; - /** - * Harmful and sensitive categories identified in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory moderation_categories = 8; - */ - private $moderation_categories; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Language\V1beta2\Sentence>|\Google\Protobuf\Internal\RepeatedField $sentences - * Sentences in the input document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * @type array<\Google\Cloud\Language\V1beta2\Token>|\Google\Protobuf\Internal\RepeatedField $tokens - * Tokens, along with their syntactic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * @type array<\Google\Cloud\Language\V1beta2\Entity>|\Google\Protobuf\Internal\RepeatedField $entities - * Entities, along with their semantic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. - * @type \Google\Cloud\Language\V1beta2\Sentiment $document_sentiment - * The overall sentiment for the document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. - * @type string $language - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * @type array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $categories - * Categories identified in the input document. - * @type array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $moderation_categories - * Harmful and sensitive categories identified in the input document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Sentences in the input document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getSentences() - { - return $this->sentences; - } - - /** - * Sentences in the input document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Sentence sentences = 1; - * @param array<\Google\Cloud\Language\V1beta2\Sentence>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setSentences($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Sentence::class); - $this->sentences = $arr; - - return $this; - } - - /** - * Tokens, along with their syntactic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Token tokens = 2; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTokens() - { - return $this->tokens; - } - - /** - * Tokens, along with their syntactic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Token tokens = 2; - * @param array<\Google\Cloud\Language\V1beta2\Token>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTokens($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Token::class); - $this->tokens = $arr; - - return $this; - } - - /** - * Entities, along with their semantic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 3; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getEntities() - { - return $this->entities; - } - - /** - * Entities, along with their semantic information, in the input document. - * Populated if the user enables - * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.Entity entities = 3; - * @param array<\Google\Cloud\Language\V1beta2\Entity>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setEntities($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\Entity::class); - $this->entities = $arr; - - return $this; - } - - /** - * The overall sentiment for the document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment document_sentiment = 4; - * @return \Google\Cloud\Language\V1beta2\Sentiment|null - */ - public function getDocumentSentiment() - { - return $this->document_sentiment; - } - - public function hasDocumentSentiment() - { - return isset($this->document_sentiment); - } - - public function clearDocumentSentiment() - { - unset($this->document_sentiment); - } - - /** - * The overall sentiment for the document. Populated if the user enables - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment document_sentiment = 4; - * @param \Google\Cloud\Language\V1beta2\Sentiment $var - * @return $this - */ - public function setDocumentSentiment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Sentiment::class); - $this->document_sentiment = $var; - - return $this; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 5; - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * The language of the text, which will be the same as the language specified - * in the request or, if not specified, the automatically-detected language. - * See [Document.language][google.cloud.language.v1beta2.Document.language] - * field for more details. - * - * Generated from protobuf field string language = 5; - * @param string $var - * @return $this - */ - public function setLanguage($var) - { - GPBUtil::checkString($var, True); - $this->language = $var; - - return $this; - } - - /** - * Categories identified in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory categories = 6; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getCategories() - { - return $this->categories; - } - - /** - * Categories identified in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory categories = 6; - * @param array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setCategories($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\ClassificationCategory::class); - $this->categories = $arr; - - return $this; - } - - /** - * Harmful and sensitive categories identified in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory moderation_categories = 8; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getModerationCategories() - { - return $this->moderation_categories; - } - - /** - * Harmful and sensitive categories identified in the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory moderation_categories = 8; - * @param array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setModerationCategories($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\ClassificationCategory::class); - $this->moderation_categories = $arr; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/ClassificationCategory.php b/Language/src/V1beta2/ClassificationCategory.php deleted file mode 100644 index c25b901358e..00000000000 --- a/Language/src/V1beta2/ClassificationCategory.php +++ /dev/null @@ -1,105 +0,0 @@ -google.cloud.language.v1beta2.ClassificationCategory - */ -class ClassificationCategory extends \Google\Protobuf\Internal\Message -{ - /** - * The name of the category representing the document. - * - * Generated from protobuf field string name = 1; - */ - private $name = ''; - /** - * The classifier's confidence of the category. Number represents how certain - * the classifier is that this category represents the given text. - * - * Generated from protobuf field float confidence = 2; - */ - private $confidence = 0.0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * The name of the category representing the document. - * @type float $confidence - * The classifier's confidence of the category. Number represents how certain - * the classifier is that this category represents the given text. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The name of the category representing the document. - * - * Generated from protobuf field string name = 1; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * The name of the category representing the document. - * - * Generated from protobuf field string name = 1; - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * The classifier's confidence of the category. Number represents how certain - * the classifier is that this category represents the given text. - * - * Generated from protobuf field float confidence = 2; - * @return float - */ - public function getConfidence() - { - return $this->confidence; - } - - /** - * The classifier's confidence of the category. Number represents how certain - * the classifier is that this category represents the given text. - * - * Generated from protobuf field float confidence = 2; - * @param float $var - * @return $this - */ - public function setConfidence($var) - { - GPBUtil::checkFloat($var); - $this->confidence = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/ClassificationModelOptions.php b/Language/src/V1beta2/ClassificationModelOptions.php deleted file mode 100644 index 75c27dd8879..00000000000 --- a/Language/src/V1beta2/ClassificationModelOptions.php +++ /dev/null @@ -1,117 +0,0 @@ -google.cloud.language.v1beta2.ClassificationModelOptions - */ -class ClassificationModelOptions extends \Google\Protobuf\Internal\Message -{ - protected $model_type; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V1Model $v1_model - * Setting this field will use the V1 model and V1 content categories - * version. The V1 model is a legacy model; support for this will be - * discontinued in the future. - * @type \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V2Model $v2_model - * Setting this field will use the V2 model with the appropriate content - * categories version. The V2 model is a better performing model. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Setting this field will use the V1 model and V1 content categories - * version. The V1 model is a legacy model; support for this will be - * discontinued in the future. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V1Model v1_model = 1; - * @return \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V1Model|null - */ - public function getV1Model() - { - return $this->readOneof(1); - } - - public function hasV1Model() - { - return $this->hasOneof(1); - } - - /** - * Setting this field will use the V1 model and V1 content categories - * version. The V1 model is a legacy model; support for this will be - * discontinued in the future. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V1Model v1_model = 1; - * @param \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V1Model $var - * @return $this - */ - public function setV1Model($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V1Model::class); - $this->writeOneof(1, $var); - - return $this; - } - - /** - * Setting this field will use the V2 model with the appropriate content - * categories version. The V2 model is a better performing model. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V2Model v2_model = 2; - * @return \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V2Model|null - */ - public function getV2Model() - { - return $this->readOneof(2); - } - - public function hasV2Model() - { - return $this->hasOneof(2); - } - - /** - * Setting this field will use the V2 model with the appropriate content - * categories version. The V2 model is a better performing model. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V2Model v2_model = 2; - * @param \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V2Model $var - * @return $this - */ - public function setV2Model($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V2Model::class); - $this->writeOneof(2, $var); - - return $this; - } - - /** - * @return string - */ - public function getModelType() - { - return $this->whichOneof("model_type"); - } - -} - diff --git a/Language/src/V1beta2/ClassificationModelOptions/V1Model.php b/Language/src/V1beta2/ClassificationModelOptions/V1Model.php deleted file mode 100644 index ae781d4d3d4..00000000000 --- a/Language/src/V1beta2/ClassificationModelOptions/V1Model.php +++ /dev/null @@ -1,36 +0,0 @@ -google.cloud.language.v1beta2.ClassificationModelOptions.V1Model - */ -class V1Model extends \Google\Protobuf\Internal\Message -{ - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(V1Model::class, \Google\Cloud\Language\V1beta2\ClassificationModelOptions_V1Model::class); - diff --git a/Language/src/V1beta2/ClassificationModelOptions/V2Model.php b/Language/src/V1beta2/ClassificationModelOptions/V2Model.php deleted file mode 100644 index 2a8b459e848..00000000000 --- a/Language/src/V1beta2/ClassificationModelOptions/V2Model.php +++ /dev/null @@ -1,70 +0,0 @@ -google.cloud.language.v1beta2.ClassificationModelOptions.V2Model - */ -class V2Model extends \Google\Protobuf\Internal\Message -{ - /** - * The content categories used for classification. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion content_categories_version = 1; - */ - private $content_categories_version = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $content_categories_version - * The content categories used for classification. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The content categories used for classification. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion content_categories_version = 1; - * @return int - */ - public function getContentCategoriesVersion() - { - return $this->content_categories_version; - } - - /** - * The content categories used for classification. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion content_categories_version = 1; - * @param int $var - * @return $this - */ - public function setContentCategoriesVersion($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\ClassificationModelOptions\V2Model\ContentCategoriesVersion::class); - $this->content_categories_version = $var; - - return $this; - } - -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(V2Model::class, \Google\Cloud\Language\V1beta2\ClassificationModelOptions_V2Model::class); - diff --git a/Language/src/V1beta2/ClassificationModelOptions/V2Model/ContentCategoriesVersion.php b/Language/src/V1beta2/ClassificationModelOptions/V2Model/ContentCategoriesVersion.php deleted file mode 100644 index 7b495d2a084..00000000000 --- a/Language/src/V1beta2/ClassificationModelOptions/V2Model/ContentCategoriesVersion.php +++ /dev/null @@ -1,65 +0,0 @@ -google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion - */ -class ContentCategoriesVersion -{ - /** - * If `ContentCategoriesVersion` is not specified, this option will - * default to `V1`. - * - * Generated from protobuf enum CONTENT_CATEGORIES_VERSION_UNSPECIFIED = 0; - */ - const CONTENT_CATEGORIES_VERSION_UNSPECIFIED = 0; - /** - * Legacy content categories of our initial launch in 2017. - * - * Generated from protobuf enum V1 = 1; - */ - const V1 = 1; - /** - * Updated content categories in 2022. - * - * Generated from protobuf enum V2 = 2; - */ - const V2 = 2; - - private static $valueToName = [ - self::CONTENT_CATEGORIES_VERSION_UNSPECIFIED => 'CONTENT_CATEGORIES_VERSION_UNSPECIFIED', - self::V1 => 'V1', - self::V2 => 'V2', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ContentCategoriesVersion::class, \Google\Cloud\Language\V1beta2\ClassificationModelOptions_V2Model_ContentCategoriesVersion::class); - diff --git a/Language/src/V1beta2/ClassificationModelOptions_V1Model.php b/Language/src/V1beta2/ClassificationModelOptions_V1Model.php deleted file mode 100644 index 8d869319c8e..00000000000 --- a/Language/src/V1beta2/ClassificationModelOptions_V1Model.php +++ /dev/null @@ -1,16 +0,0 @@ -google.cloud.language.v1beta2.ClassifyTextRequest - */ -class ClassifyTextRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - /** - * Model options to use for classification. Defaults to v1 options if not - * specified. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions classification_model_options = 3; - */ - private $classification_model_options = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * @type \Google\Cloud\Language\V1beta2\ClassificationModelOptions $classification_model_options - * Model options to use for classification. Defaults to v1 options if not - * specified. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - - /** - * Model options to use for classification. Defaults to v1 options if not - * specified. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions classification_model_options = 3; - * @return \Google\Cloud\Language\V1beta2\ClassificationModelOptions|null - */ - public function getClassificationModelOptions() - { - return $this->classification_model_options; - } - - public function hasClassificationModelOptions() - { - return isset($this->classification_model_options); - } - - public function clearClassificationModelOptions() - { - unset($this->classification_model_options); - } - - /** - * Model options to use for classification. Defaults to v1 options if not - * specified. - * - * Generated from protobuf field .google.cloud.language.v1beta2.ClassificationModelOptions classification_model_options = 3; - * @param \Google\Cloud\Language\V1beta2\ClassificationModelOptions $var - * @return $this - */ - public function setClassificationModelOptions($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\ClassificationModelOptions::class); - $this->classification_model_options = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/ClassifyTextResponse.php b/Language/src/V1beta2/ClassifyTextResponse.php deleted file mode 100644 index a919aba1e73..00000000000 --- a/Language/src/V1beta2/ClassifyTextResponse.php +++ /dev/null @@ -1,67 +0,0 @@ -google.cloud.language.v1beta2.ClassifyTextResponse - */ -class ClassifyTextResponse extends \Google\Protobuf\Internal\Message -{ - /** - * Categories representing the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory categories = 1; - */ - private $categories; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $categories - * Categories representing the input document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Categories representing the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory categories = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getCategories() - { - return $this->categories; - } - - /** - * Categories representing the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory categories = 1; - * @param array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setCategories($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\ClassificationCategory::class); - $this->categories = $arr; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/DependencyEdge.php b/Language/src/V1beta2/DependencyEdge.php deleted file mode 100644 index c6e2bd23cef..00000000000 --- a/Language/src/V1beta2/DependencyEdge.php +++ /dev/null @@ -1,117 +0,0 @@ -google.cloud.language.v1beta2.DependencyEdge - */ -class DependencyEdge extends \Google\Protobuf\Internal\Message -{ - /** - * Represents the head of this token in the dependency tree. - * This is the index of the token which has an arc going to this token. - * The index is the position of the token in the array of tokens returned - * by the API method. If this token is a root token, then the - * `head_token_index` is its own index. - * - * Generated from protobuf field int32 head_token_index = 1; - */ - private $head_token_index = 0; - /** - * The parse label for the token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.DependencyEdge.Label label = 2; - */ - private $label = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $head_token_index - * Represents the head of this token in the dependency tree. - * This is the index of the token which has an arc going to this token. - * The index is the position of the token in the array of tokens returned - * by the API method. If this token is a root token, then the - * `head_token_index` is its own index. - * @type int $label - * The parse label for the token. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Represents the head of this token in the dependency tree. - * This is the index of the token which has an arc going to this token. - * The index is the position of the token in the array of tokens returned - * by the API method. If this token is a root token, then the - * `head_token_index` is its own index. - * - * Generated from protobuf field int32 head_token_index = 1; - * @return int - */ - public function getHeadTokenIndex() - { - return $this->head_token_index; - } - - /** - * Represents the head of this token in the dependency tree. - * This is the index of the token which has an arc going to this token. - * The index is the position of the token in the array of tokens returned - * by the API method. If this token is a root token, then the - * `head_token_index` is its own index. - * - * Generated from protobuf field int32 head_token_index = 1; - * @param int $var - * @return $this - */ - public function setHeadTokenIndex($var) - { - GPBUtil::checkInt32($var); - $this->head_token_index = $var; - - return $this; - } - - /** - * The parse label for the token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.DependencyEdge.Label label = 2; - * @return int - */ - public function getLabel() - { - return $this->label; - } - - /** - * The parse label for the token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.DependencyEdge.Label label = 2; - * @param int $var - * @return $this - */ - public function setLabel($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\DependencyEdge\Label::class); - $this->label = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/DependencyEdge/Label.php b/Language/src/V1beta2/DependencyEdge/Label.php deleted file mode 100644 index 81e822ce529..00000000000 --- a/Language/src/V1beta2/DependencyEdge/Label.php +++ /dev/null @@ -1,628 +0,0 @@ -google.cloud.language.v1beta2.DependencyEdge.Label - */ -class Label -{ - /** - * Unknown - * - * Generated from protobuf enum UNKNOWN = 0; - */ - const UNKNOWN = 0; - /** - * Abbreviation modifier - * - * Generated from protobuf enum ABBREV = 1; - */ - const ABBREV = 1; - /** - * Adjectival complement - * - * Generated from protobuf enum ACOMP = 2; - */ - const ACOMP = 2; - /** - * Adverbial clause modifier - * - * Generated from protobuf enum ADVCL = 3; - */ - const ADVCL = 3; - /** - * Adverbial modifier - * - * Generated from protobuf enum ADVMOD = 4; - */ - const ADVMOD = 4; - /** - * Adjectival modifier of an NP - * - * Generated from protobuf enum AMOD = 5; - */ - const AMOD = 5; - /** - * Appositional modifier of an NP - * - * Generated from protobuf enum APPOS = 6; - */ - const APPOS = 6; - /** - * Attribute dependent of a copular verb - * - * Generated from protobuf enum ATTR = 7; - */ - const ATTR = 7; - /** - * Auxiliary (non-main) verb - * - * Generated from protobuf enum AUX = 8; - */ - const AUX = 8; - /** - * Passive auxiliary - * - * Generated from protobuf enum AUXPASS = 9; - */ - const AUXPASS = 9; - /** - * Coordinating conjunction - * - * Generated from protobuf enum CC = 10; - */ - const CC = 10; - /** - * Clausal complement of a verb or adjective - * - * Generated from protobuf enum CCOMP = 11; - */ - const CCOMP = 11; - /** - * Conjunct - * - * Generated from protobuf enum CONJ = 12; - */ - const CONJ = 12; - /** - * Clausal subject - * - * Generated from protobuf enum CSUBJ = 13; - */ - const CSUBJ = 13; - /** - * Clausal passive subject - * - * Generated from protobuf enum CSUBJPASS = 14; - */ - const CSUBJPASS = 14; - /** - * Dependency (unable to determine) - * - * Generated from protobuf enum DEP = 15; - */ - const DEP = 15; - /** - * Determiner - * - * Generated from protobuf enum DET = 16; - */ - const DET = 16; - /** - * Discourse - * - * Generated from protobuf enum DISCOURSE = 17; - */ - const DISCOURSE = 17; - /** - * Direct object - * - * Generated from protobuf enum DOBJ = 18; - */ - const DOBJ = 18; - /** - * Expletive - * - * Generated from protobuf enum EXPL = 19; - */ - const EXPL = 19; - /** - * Goes with (part of a word in a text not well edited) - * - * Generated from protobuf enum GOESWITH = 20; - */ - const GOESWITH = 20; - /** - * Indirect object - * - * Generated from protobuf enum IOBJ = 21; - */ - const IOBJ = 21; - /** - * Marker (word introducing a subordinate clause) - * - * Generated from protobuf enum MARK = 22; - */ - const MARK = 22; - /** - * Multi-word expression - * - * Generated from protobuf enum MWE = 23; - */ - const MWE = 23; - /** - * Multi-word verbal expression - * - * Generated from protobuf enum MWV = 24; - */ - const MWV = 24; - /** - * Negation modifier - * - * Generated from protobuf enum NEG = 25; - */ - const NEG = 25; - /** - * Noun compound modifier - * - * Generated from protobuf enum NN = 26; - */ - const NN = 26; - /** - * Noun phrase used as an adverbial modifier - * - * Generated from protobuf enum NPADVMOD = 27; - */ - const NPADVMOD = 27; - /** - * Nominal subject - * - * Generated from protobuf enum NSUBJ = 28; - */ - const NSUBJ = 28; - /** - * Passive nominal subject - * - * Generated from protobuf enum NSUBJPASS = 29; - */ - const NSUBJPASS = 29; - /** - * Numeric modifier of a noun - * - * Generated from protobuf enum NUM = 30; - */ - const NUM = 30; - /** - * Element of compound number - * - * Generated from protobuf enum NUMBER = 31; - */ - const NUMBER = 31; - /** - * Punctuation mark - * - * Generated from protobuf enum P = 32; - */ - const P = 32; - /** - * Parataxis relation - * - * Generated from protobuf enum PARATAXIS = 33; - */ - const PARATAXIS = 33; - /** - * Participial modifier - * - * Generated from protobuf enum PARTMOD = 34; - */ - const PARTMOD = 34; - /** - * The complement of a preposition is a clause - * - * Generated from protobuf enum PCOMP = 35; - */ - const PCOMP = 35; - /** - * Object of a preposition - * - * Generated from protobuf enum POBJ = 36; - */ - const POBJ = 36; - /** - * Possession modifier - * - * Generated from protobuf enum POSS = 37; - */ - const POSS = 37; - /** - * Postverbal negative particle - * - * Generated from protobuf enum POSTNEG = 38; - */ - const POSTNEG = 38; - /** - * Predicate complement - * - * Generated from protobuf enum PRECOMP = 39; - */ - const PRECOMP = 39; - /** - * Preconjunt - * - * Generated from protobuf enum PRECONJ = 40; - */ - const PRECONJ = 40; - /** - * Predeterminer - * - * Generated from protobuf enum PREDET = 41; - */ - const PREDET = 41; - /** - * Prefix - * - * Generated from protobuf enum PREF = 42; - */ - const PREF = 42; - /** - * Prepositional modifier - * - * Generated from protobuf enum PREP = 43; - */ - const PREP = 43; - /** - * The relationship between a verb and verbal morpheme - * - * Generated from protobuf enum PRONL = 44; - */ - const PRONL = 44; - /** - * Particle - * - * Generated from protobuf enum PRT = 45; - */ - const PRT = 45; - /** - * Associative or possessive marker - * - * Generated from protobuf enum PS = 46; - */ - const PS = 46; - /** - * Quantifier phrase modifier - * - * Generated from protobuf enum QUANTMOD = 47; - */ - const QUANTMOD = 47; - /** - * Relative clause modifier - * - * Generated from protobuf enum RCMOD = 48; - */ - const RCMOD = 48; - /** - * Complementizer in relative clause - * - * Generated from protobuf enum RCMODREL = 49; - */ - const RCMODREL = 49; - /** - * Ellipsis without a preceding predicate - * - * Generated from protobuf enum RDROP = 50; - */ - const RDROP = 50; - /** - * Referent - * - * Generated from protobuf enum REF = 51; - */ - const REF = 51; - /** - * Remnant - * - * Generated from protobuf enum REMNANT = 52; - */ - const REMNANT = 52; - /** - * Reparandum - * - * Generated from protobuf enum REPARANDUM = 53; - */ - const REPARANDUM = 53; - /** - * Root - * - * Generated from protobuf enum ROOT = 54; - */ - const ROOT = 54; - /** - * Suffix specifying a unit of number - * - * Generated from protobuf enum SNUM = 55; - */ - const SNUM = 55; - /** - * Suffix - * - * Generated from protobuf enum SUFF = 56; - */ - const SUFF = 56; - /** - * Temporal modifier - * - * Generated from protobuf enum TMOD = 57; - */ - const TMOD = 57; - /** - * Topic marker - * - * Generated from protobuf enum TOPIC = 58; - */ - const TOPIC = 58; - /** - * Clause headed by an infinite form of the verb that modifies a noun - * - * Generated from protobuf enum VMOD = 59; - */ - const VMOD = 59; - /** - * Vocative - * - * Generated from protobuf enum VOCATIVE = 60; - */ - const VOCATIVE = 60; - /** - * Open clausal complement - * - * Generated from protobuf enum XCOMP = 61; - */ - const XCOMP = 61; - /** - * Name suffix - * - * Generated from protobuf enum SUFFIX = 62; - */ - const SUFFIX = 62; - /** - * Name title - * - * Generated from protobuf enum TITLE = 63; - */ - const TITLE = 63; - /** - * Adverbial phrase modifier - * - * Generated from protobuf enum ADVPHMOD = 64; - */ - const ADVPHMOD = 64; - /** - * Causative auxiliary - * - * Generated from protobuf enum AUXCAUS = 65; - */ - const AUXCAUS = 65; - /** - * Helper auxiliary - * - * Generated from protobuf enum AUXVV = 66; - */ - const AUXVV = 66; - /** - * Rentaishi (Prenominal modifier) - * - * Generated from protobuf enum DTMOD = 67; - */ - const DTMOD = 67; - /** - * Foreign words - * - * Generated from protobuf enum FOREIGN = 68; - */ - const FOREIGN = 68; - /** - * Keyword - * - * Generated from protobuf enum KW = 69; - */ - const KW = 69; - /** - * List for chains of comparable items - * - * Generated from protobuf enum LIST = 70; - */ - const PBLIST = 70; - /** - * Nominalized clause - * - * Generated from protobuf enum NOMC = 71; - */ - const NOMC = 71; - /** - * Nominalized clausal subject - * - * Generated from protobuf enum NOMCSUBJ = 72; - */ - const NOMCSUBJ = 72; - /** - * Nominalized clausal passive - * - * Generated from protobuf enum NOMCSUBJPASS = 73; - */ - const NOMCSUBJPASS = 73; - /** - * Compound of numeric modifier - * - * Generated from protobuf enum NUMC = 74; - */ - const NUMC = 74; - /** - * Copula - * - * Generated from protobuf enum COP = 75; - */ - const COP = 75; - /** - * Dislocated relation (for fronted/topicalized elements) - * - * Generated from protobuf enum DISLOCATED = 76; - */ - const DISLOCATED = 76; - /** - * Aspect marker - * - * Generated from protobuf enum ASP = 77; - */ - const ASP = 77; - /** - * Genitive modifier - * - * Generated from protobuf enum GMOD = 78; - */ - const GMOD = 78; - /** - * Genitive object - * - * Generated from protobuf enum GOBJ = 79; - */ - const GOBJ = 79; - /** - * Infinitival modifier - * - * Generated from protobuf enum INFMOD = 80; - */ - const INFMOD = 80; - /** - * Measure - * - * Generated from protobuf enum MES = 81; - */ - const MES = 81; - /** - * Nominal complement of a noun - * - * Generated from protobuf enum NCOMP = 82; - */ - const NCOMP = 82; - - private static $valueToName = [ - self::UNKNOWN => 'UNKNOWN', - self::ABBREV => 'ABBREV', - self::ACOMP => 'ACOMP', - self::ADVCL => 'ADVCL', - self::ADVMOD => 'ADVMOD', - self::AMOD => 'AMOD', - self::APPOS => 'APPOS', - self::ATTR => 'ATTR', - self::AUX => 'AUX', - self::AUXPASS => 'AUXPASS', - self::CC => 'CC', - self::CCOMP => 'CCOMP', - self::CONJ => 'CONJ', - self::CSUBJ => 'CSUBJ', - self::CSUBJPASS => 'CSUBJPASS', - self::DEP => 'DEP', - self::DET => 'DET', - self::DISCOURSE => 'DISCOURSE', - self::DOBJ => 'DOBJ', - self::EXPL => 'EXPL', - self::GOESWITH => 'GOESWITH', - self::IOBJ => 'IOBJ', - self::MARK => 'MARK', - self::MWE => 'MWE', - self::MWV => 'MWV', - self::NEG => 'NEG', - self::NN => 'NN', - self::NPADVMOD => 'NPADVMOD', - self::NSUBJ => 'NSUBJ', - self::NSUBJPASS => 'NSUBJPASS', - self::NUM => 'NUM', - self::NUMBER => 'NUMBER', - self::P => 'P', - self::PARATAXIS => 'PARATAXIS', - self::PARTMOD => 'PARTMOD', - self::PCOMP => 'PCOMP', - self::POBJ => 'POBJ', - self::POSS => 'POSS', - self::POSTNEG => 'POSTNEG', - self::PRECOMP => 'PRECOMP', - self::PRECONJ => 'PRECONJ', - self::PREDET => 'PREDET', - self::PREF => 'PREF', - self::PREP => 'PREP', - self::PRONL => 'PRONL', - self::PRT => 'PRT', - self::PS => 'PS', - self::QUANTMOD => 'QUANTMOD', - self::RCMOD => 'RCMOD', - self::RCMODREL => 'RCMODREL', - self::RDROP => 'RDROP', - self::REF => 'REF', - self::REMNANT => 'REMNANT', - self::REPARANDUM => 'REPARANDUM', - self::ROOT => 'ROOT', - self::SNUM => 'SNUM', - self::SUFF => 'SUFF', - self::TMOD => 'TMOD', - self::TOPIC => 'TOPIC', - self::VMOD => 'VMOD', - self::VOCATIVE => 'VOCATIVE', - self::XCOMP => 'XCOMP', - self::SUFFIX => 'SUFFIX', - self::TITLE => 'TITLE', - self::ADVPHMOD => 'ADVPHMOD', - self::AUXCAUS => 'AUXCAUS', - self::AUXVV => 'AUXVV', - self::DTMOD => 'DTMOD', - self::FOREIGN => 'FOREIGN', - self::KW => 'KW', - self::PBLIST => 'LIST', - self::NOMC => 'NOMC', - self::NOMCSUBJ => 'NOMCSUBJ', - self::NOMCSUBJPASS => 'NOMCSUBJPASS', - self::NUMC => 'NUMC', - self::COP => 'COP', - self::DISLOCATED => 'DISLOCATED', - self::ASP => 'ASP', - self::GMOD => 'GMOD', - self::GOBJ => 'GOBJ', - self::INFMOD => 'INFMOD', - self::MES => 'MES', - self::NCOMP => 'NCOMP', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - $pbconst = __CLASS__. '::PB' . strtoupper($name); - if (!defined($pbconst)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($pbconst); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Label::class, \Google\Cloud\Language\V1beta2\DependencyEdge_Label::class); - diff --git a/Language/src/V1beta2/DependencyEdge_Label.php b/Language/src/V1beta2/DependencyEdge_Label.php deleted file mode 100644 index ec8b85fdba8..00000000000 --- a/Language/src/V1beta2/DependencyEdge_Label.php +++ /dev/null @@ -1,16 +0,0 @@ -google.cloud.language.v1beta2.Document - */ -class Document extends \Google\Protobuf\Internal\Message -{ - /** - * Required. If the type is not set or is `TYPE_UNSPECIFIED`, - * returns an `INVALID_ARGUMENT` error. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document.Type type = 1; - */ - private $type = 0; - /** - * The language of the document (if not specified, the language is - * automatically detected). Both ISO and BCP-47 language codes are - * accepted.
- * [Language - * Support](https://cloud.google.com/natural-language/docs/languages) lists - * currently supported languages for each API method. If the language (either - * specified by the caller or automatically detected) is not supported by the - * called API method, an `INVALID_ARGUMENT` error is returned. - * - * Generated from protobuf field string language = 4; - */ - private $language = ''; - /** - * The web URI where the document comes from. This URI is not used for - * fetching the content, but as a hint for analyzing the document. - * - * Generated from protobuf field string reference_web_uri = 5; - */ - private $reference_web_uri = ''; - /** - * Indicates how detected boilerplate(e.g. advertisements, copyright - * declarations, banners) should be handled for this document. If not - * specified, boilerplate will be treated the same as content. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document.BoilerplateHandling boilerplate_handling = 6; - */ - private $boilerplate_handling = 0; - protected $source; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $type - * Required. If the type is not set or is `TYPE_UNSPECIFIED`, - * returns an `INVALID_ARGUMENT` error. - * @type string $content - * The content of the input in string format. - * Cloud audit logging exempt since it is based on user data. - * @type string $gcs_content_uri - * The Google Cloud Storage URI where the file content is located. - * This URI must be of the form: gs://bucket_name/object_name. For more - * details, see https://cloud.google.com/storage/docs/reference-uris. - * NOTE: Cloud Storage object versioning is not supported. - * @type string $language - * The language of the document (if not specified, the language is - * automatically detected). Both ISO and BCP-47 language codes are - * accepted.
- * [Language - * Support](https://cloud.google.com/natural-language/docs/languages) lists - * currently supported languages for each API method. If the language (either - * specified by the caller or automatically detected) is not supported by the - * called API method, an `INVALID_ARGUMENT` error is returned. - * @type string $reference_web_uri - * The web URI where the document comes from. This URI is not used for - * fetching the content, but as a hint for analyzing the document. - * @type int $boilerplate_handling - * Indicates how detected boilerplate(e.g. advertisements, copyright - * declarations, banners) should be handled for this document. If not - * specified, boilerplate will be treated the same as content. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. If the type is not set or is `TYPE_UNSPECIFIED`, - * returns an `INVALID_ARGUMENT` error. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document.Type type = 1; - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * Required. If the type is not set or is `TYPE_UNSPECIFIED`, - * returns an `INVALID_ARGUMENT` error. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document.Type type = 1; - * @param int $var - * @return $this - */ - public function setType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\Document\Type::class); - $this->type = $var; - - return $this; - } - - /** - * The content of the input in string format. - * Cloud audit logging exempt since it is based on user data. - * - * Generated from protobuf field string content = 2; - * @return string - */ - public function getContent() - { - return $this->readOneof(2); - } - - public function hasContent() - { - return $this->hasOneof(2); - } - - /** - * The content of the input in string format. - * Cloud audit logging exempt since it is based on user data. - * - * Generated from protobuf field string content = 2; - * @param string $var - * @return $this - */ - public function setContent($var) - { - GPBUtil::checkString($var, True); - $this->writeOneof(2, $var); - - return $this; - } - - /** - * The Google Cloud Storage URI where the file content is located. - * This URI must be of the form: gs://bucket_name/object_name. For more - * details, see https://cloud.google.com/storage/docs/reference-uris. - * NOTE: Cloud Storage object versioning is not supported. - * - * Generated from protobuf field string gcs_content_uri = 3; - * @return string - */ - public function getGcsContentUri() - { - return $this->readOneof(3); - } - - public function hasGcsContentUri() - { - return $this->hasOneof(3); - } - - /** - * The Google Cloud Storage URI where the file content is located. - * This URI must be of the form: gs://bucket_name/object_name. For more - * details, see https://cloud.google.com/storage/docs/reference-uris. - * NOTE: Cloud Storage object versioning is not supported. - * - * Generated from protobuf field string gcs_content_uri = 3; - * @param string $var - * @return $this - */ - public function setGcsContentUri($var) - { - GPBUtil::checkString($var, True); - $this->writeOneof(3, $var); - - return $this; - } - - /** - * The language of the document (if not specified, the language is - * automatically detected). Both ISO and BCP-47 language codes are - * accepted.
- * [Language - * Support](https://cloud.google.com/natural-language/docs/languages) lists - * currently supported languages for each API method. If the language (either - * specified by the caller or automatically detected) is not supported by the - * called API method, an `INVALID_ARGUMENT` error is returned. - * - * Generated from protobuf field string language = 4; - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * The language of the document (if not specified, the language is - * automatically detected). Both ISO and BCP-47 language codes are - * accepted.
- * [Language - * Support](https://cloud.google.com/natural-language/docs/languages) lists - * currently supported languages for each API method. If the language (either - * specified by the caller or automatically detected) is not supported by the - * called API method, an `INVALID_ARGUMENT` error is returned. - * - * Generated from protobuf field string language = 4; - * @param string $var - * @return $this - */ - public function setLanguage($var) - { - GPBUtil::checkString($var, True); - $this->language = $var; - - return $this; - } - - /** - * The web URI where the document comes from. This URI is not used for - * fetching the content, but as a hint for analyzing the document. - * - * Generated from protobuf field string reference_web_uri = 5; - * @return string - */ - public function getReferenceWebUri() - { - return $this->reference_web_uri; - } - - /** - * The web URI where the document comes from. This URI is not used for - * fetching the content, but as a hint for analyzing the document. - * - * Generated from protobuf field string reference_web_uri = 5; - * @param string $var - * @return $this - */ - public function setReferenceWebUri($var) - { - GPBUtil::checkString($var, True); - $this->reference_web_uri = $var; - - return $this; - } - - /** - * Indicates how detected boilerplate(e.g. advertisements, copyright - * declarations, banners) should be handled for this document. If not - * specified, boilerplate will be treated the same as content. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document.BoilerplateHandling boilerplate_handling = 6; - * @return int - */ - public function getBoilerplateHandling() - { - return $this->boilerplate_handling; - } - - /** - * Indicates how detected boilerplate(e.g. advertisements, copyright - * declarations, banners) should be handled for this document. If not - * specified, boilerplate will be treated the same as content. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document.BoilerplateHandling boilerplate_handling = 6; - * @param int $var - * @return $this - */ - public function setBoilerplateHandling($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\Document\BoilerplateHandling::class); - $this->boilerplate_handling = $var; - - return $this; - } - - /** - * @return string - */ - public function getSource() - { - return $this->whichOneof("source"); - } - -} - diff --git a/Language/src/V1beta2/Document/BoilerplateHandling.php b/Language/src/V1beta2/Document/BoilerplateHandling.php deleted file mode 100644 index 0b2e8a4c21c..00000000000 --- a/Language/src/V1beta2/Document/BoilerplateHandling.php +++ /dev/null @@ -1,65 +0,0 @@ -google.cloud.language.v1beta2.Document.BoilerplateHandling - */ -class BoilerplateHandling -{ - /** - * The boilerplate handling is not specified. - * - * Generated from protobuf enum BOILERPLATE_HANDLING_UNSPECIFIED = 0; - */ - const BOILERPLATE_HANDLING_UNSPECIFIED = 0; - /** - * Do not analyze detected boilerplate. Reference web URI is required for - * detecting boilerplate. - * - * Generated from protobuf enum SKIP_BOILERPLATE = 1; - */ - const SKIP_BOILERPLATE = 1; - /** - * Treat boilerplate the same as content. - * - * Generated from protobuf enum KEEP_BOILERPLATE = 2; - */ - const KEEP_BOILERPLATE = 2; - - private static $valueToName = [ - self::BOILERPLATE_HANDLING_UNSPECIFIED => 'BOILERPLATE_HANDLING_UNSPECIFIED', - self::SKIP_BOILERPLATE => 'SKIP_BOILERPLATE', - self::KEEP_BOILERPLATE => 'KEEP_BOILERPLATE', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(BoilerplateHandling::class, \Google\Cloud\Language\V1beta2\Document_BoilerplateHandling::class); - diff --git a/Language/src/V1beta2/Document/Type.php b/Language/src/V1beta2/Document/Type.php deleted file mode 100644 index 382148db46a..00000000000 --- a/Language/src/V1beta2/Document/Type.php +++ /dev/null @@ -1,64 +0,0 @@ -google.cloud.language.v1beta2.Document.Type - */ -class Type -{ - /** - * The content type is not specified. - * - * Generated from protobuf enum TYPE_UNSPECIFIED = 0; - */ - const TYPE_UNSPECIFIED = 0; - /** - * Plain text - * - * Generated from protobuf enum PLAIN_TEXT = 1; - */ - const PLAIN_TEXT = 1; - /** - * HTML - * - * Generated from protobuf enum HTML = 2; - */ - const HTML = 2; - - private static $valueToName = [ - self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', - self::PLAIN_TEXT => 'PLAIN_TEXT', - self::HTML => 'HTML', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Type::class, \Google\Cloud\Language\V1beta2\Document_Type::class); - diff --git a/Language/src/V1beta2/Document_BoilerplateHandling.php b/Language/src/V1beta2/Document_BoilerplateHandling.php deleted file mode 100644 index 78002388595..00000000000 --- a/Language/src/V1beta2/Document_BoilerplateHandling.php +++ /dev/null @@ -1,16 +0,0 @@ -google.cloud.language.v1beta2.EncodingType - */ -class EncodingType -{ - /** - * If `EncodingType` is not specified, encoding-dependent information (such as - * `begin_offset`) will be set at `-1`. - * - * Generated from protobuf enum NONE = 0; - */ - const NONE = 0; - /** - * Encoding-dependent information (such as `begin_offset`) is calculated based - * on the UTF-8 encoding of the input. C++ and Go are examples of languages - * that use this encoding natively. - * - * Generated from protobuf enum UTF8 = 1; - */ - const UTF8 = 1; - /** - * Encoding-dependent information (such as `begin_offset`) is calculated based - * on the UTF-16 encoding of the input. Java and JavaScript are examples of - * languages that use this encoding natively. - * - * Generated from protobuf enum UTF16 = 2; - */ - const UTF16 = 2; - /** - * Encoding-dependent information (such as `begin_offset`) is calculated based - * on the UTF-32 encoding of the input. Python is an example of a language - * that uses this encoding natively. - * - * Generated from protobuf enum UTF32 = 3; - */ - const UTF32 = 3; - - private static $valueToName = [ - self::NONE => 'NONE', - self::UTF8 => 'UTF8', - self::UTF16 => 'UTF16', - self::UTF32 => 'UTF32', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - diff --git a/Language/src/V1beta2/Entity.php b/Language/src/V1beta2/Entity.php deleted file mode 100644 index fcc4eb42e60..00000000000 --- a/Language/src/V1beta2/Entity.php +++ /dev/null @@ -1,293 +0,0 @@ -google.cloud.language.v1beta2.Entity - */ -class Entity extends \Google\Protobuf\Internal\Message -{ - /** - * The representative name for the entity. - * - * Generated from protobuf field string name = 1; - */ - private $name = ''; - /** - * The entity type. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Entity.Type type = 2; - */ - private $type = 0; - /** - * Metadata associated with the entity. - * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) - * and Knowledge Graph MID (`mid`), if they are available. For the metadata - * associated with other entity types, see the Type table below. - * - * Generated from protobuf field map metadata = 3; - */ - private $metadata; - /** - * The salience score associated with the entity in the [0, 1.0] range. - * The salience score for an entity provides information about the - * importance or centrality of that entity to the entire document text. - * Scores closer to 0 are less salient, while scores closer to 1.0 are highly - * salient. - * - * Generated from protobuf field float salience = 4; - */ - private $salience = 0.0; - /** - * The mentions of this entity in the input document. The API currently - * supports proper noun mentions. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.EntityMention mentions = 5; - */ - private $mentions; - /** - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the aggregate sentiment expressed - * for this entity in the provided document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 6; - */ - private $sentiment = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * The representative name for the entity. - * @type int $type - * The entity type. - * @type array|\Google\Protobuf\Internal\MapField $metadata - * Metadata associated with the entity. - * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) - * and Knowledge Graph MID (`mid`), if they are available. For the metadata - * associated with other entity types, see the Type table below. - * @type float $salience - * The salience score associated with the entity in the [0, 1.0] range. - * The salience score for an entity provides information about the - * importance or centrality of that entity to the entire document text. - * Scores closer to 0 are less salient, while scores closer to 1.0 are highly - * salient. - * @type array<\Google\Cloud\Language\V1beta2\EntityMention>|\Google\Protobuf\Internal\RepeatedField $mentions - * The mentions of this entity in the input document. The API currently - * supports proper noun mentions. - * @type \Google\Cloud\Language\V1beta2\Sentiment $sentiment - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the aggregate sentiment expressed - * for this entity in the provided document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The representative name for the entity. - * - * Generated from protobuf field string name = 1; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * The representative name for the entity. - * - * Generated from protobuf field string name = 1; - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * The entity type. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Entity.Type type = 2; - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * The entity type. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Entity.Type type = 2; - * @param int $var - * @return $this - */ - public function setType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\Entity\Type::class); - $this->type = $var; - - return $this; - } - - /** - * Metadata associated with the entity. - * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) - * and Knowledge Graph MID (`mid`), if they are available. For the metadata - * associated with other entity types, see the Type table below. - * - * Generated from protobuf field map metadata = 3; - * @return \Google\Protobuf\Internal\MapField - */ - public function getMetadata() - { - return $this->metadata; - } - - /** - * Metadata associated with the entity. - * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) - * and Knowledge Graph MID (`mid`), if they are available. For the metadata - * associated with other entity types, see the Type table below. - * - * Generated from protobuf field map metadata = 3; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setMetadata($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); - $this->metadata = $arr; - - return $this; - } - - /** - * The salience score associated with the entity in the [0, 1.0] range. - * The salience score for an entity provides information about the - * importance or centrality of that entity to the entire document text. - * Scores closer to 0 are less salient, while scores closer to 1.0 are highly - * salient. - * - * Generated from protobuf field float salience = 4; - * @return float - */ - public function getSalience() - { - return $this->salience; - } - - /** - * The salience score associated with the entity in the [0, 1.0] range. - * The salience score for an entity provides information about the - * importance or centrality of that entity to the entire document text. - * Scores closer to 0 are less salient, while scores closer to 1.0 are highly - * salient. - * - * Generated from protobuf field float salience = 4; - * @param float $var - * @return $this - */ - public function setSalience($var) - { - GPBUtil::checkFloat($var); - $this->salience = $var; - - return $this; - } - - /** - * The mentions of this entity in the input document. The API currently - * supports proper noun mentions. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.EntityMention mentions = 5; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getMentions() - { - return $this->mentions; - } - - /** - * The mentions of this entity in the input document. The API currently - * supports proper noun mentions. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.EntityMention mentions = 5; - * @param array<\Google\Cloud\Language\V1beta2\EntityMention>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setMentions($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\EntityMention::class); - $this->mentions = $arr; - - return $this; - } - - /** - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the aggregate sentiment expressed - * for this entity in the provided document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 6; - * @return \Google\Cloud\Language\V1beta2\Sentiment|null - */ - public function getSentiment() - { - return $this->sentiment; - } - - public function hasSentiment() - { - return isset($this->sentiment); - } - - public function clearSentiment() - { - unset($this->sentiment); - } - - /** - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the aggregate sentiment expressed - * for this entity in the provided document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 6; - * @param \Google\Cloud\Language\V1beta2\Sentiment $var - * @return $this - */ - public function setSentiment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Sentiment::class); - $this->sentiment = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/Entity/Type.php b/Language/src/V1beta2/Entity/Type.php deleted file mode 100644 index 128bbb2c7e0..00000000000 --- a/Language/src/V1beta2/Entity/Type.php +++ /dev/null @@ -1,163 +0,0 @@ -google.cloud.language.v1beta2.Entity.Type - */ -class Type -{ - /** - * Unknown - * - * Generated from protobuf enum UNKNOWN = 0; - */ - const UNKNOWN = 0; - /** - * Person - * - * Generated from protobuf enum PERSON = 1; - */ - const PERSON = 1; - /** - * Location - * - * Generated from protobuf enum LOCATION = 2; - */ - const LOCATION = 2; - /** - * Organization - * - * Generated from protobuf enum ORGANIZATION = 3; - */ - const ORGANIZATION = 3; - /** - * Event - * - * Generated from protobuf enum EVENT = 4; - */ - const EVENT = 4; - /** - * Artwork - * - * Generated from protobuf enum WORK_OF_ART = 5; - */ - const WORK_OF_ART = 5; - /** - * Consumer product - * - * Generated from protobuf enum CONSUMER_GOOD = 6; - */ - const CONSUMER_GOOD = 6; - /** - * Other types of entities - * - * Generated from protobuf enum OTHER = 7; - */ - const OTHER = 7; - /** - * Phone number - * The metadata lists the phone number, formatted according to local - * convention, plus whichever additional elements appear in the text: - * * `number` - the actual number, broken down into sections as per local - * convention - * * `national_prefix` - country code, if detected - * * `area_code` - region or area code, if detected - * * `extension` - phone extension (to be dialed after connection), if - * detected - * - * Generated from protobuf enum PHONE_NUMBER = 9; - */ - const PHONE_NUMBER = 9; - /** - * Address - * The metadata identifies the street number and locality plus whichever - * additional elements appear in the text: - * * `street_number` - street number - * * `locality` - city or town - * * `street_name` - street/route name, if detected - * * `postal_code` - postal code, if detected - * * `country` - country, if detected< - * * `broad_region` - administrative area, such as the state, if detected - * * `narrow_region` - smaller administrative area, such as county, if - * detected - * * `sublocality` - used in Asian addresses to demark a district within a - * city, if detected - * - * Generated from protobuf enum ADDRESS = 10; - */ - const ADDRESS = 10; - /** - * Date - * The metadata identifies the components of the date: - * * `year` - four digit year, if detected - * * `month` - two digit month number, if detected - * * `day` - two digit day number, if detected - * - * Generated from protobuf enum DATE = 11; - */ - const DATE = 11; - /** - * Number - * The metadata is the number itself. - * - * Generated from protobuf enum NUMBER = 12; - */ - const NUMBER = 12; - /** - * Price - * The metadata identifies the `value` and `currency`. - * - * Generated from protobuf enum PRICE = 13; - */ - const PRICE = 13; - - private static $valueToName = [ - self::UNKNOWN => 'UNKNOWN', - self::PERSON => 'PERSON', - self::LOCATION => 'LOCATION', - self::ORGANIZATION => 'ORGANIZATION', - self::EVENT => 'EVENT', - self::WORK_OF_ART => 'WORK_OF_ART', - self::CONSUMER_GOOD => 'CONSUMER_GOOD', - self::OTHER => 'OTHER', - self::PHONE_NUMBER => 'PHONE_NUMBER', - self::ADDRESS => 'ADDRESS', - self::DATE => 'DATE', - self::NUMBER => 'NUMBER', - self::PRICE => 'PRICE', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Type::class, \Google\Cloud\Language\V1beta2\Entity_Type::class); - diff --git a/Language/src/V1beta2/EntityMention.php b/Language/src/V1beta2/EntityMention.php deleted file mode 100644 index aba86849888..00000000000 --- a/Language/src/V1beta2/EntityMention.php +++ /dev/null @@ -1,168 +0,0 @@ -google.cloud.language.v1beta2.EntityMention - */ -class EntityMention extends \Google\Protobuf\Internal\Message -{ - /** - * The mention text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - */ - private $text = null; - /** - * The type of the entity mention. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EntityMention.Type type = 2; - */ - private $type = 0; - /** - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the sentiment expressed for this - * mention of the entity in the provided document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 3; - */ - private $sentiment = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\TextSpan $text - * The mention text. - * @type int $type - * The type of the entity mention. - * @type \Google\Cloud\Language\V1beta2\Sentiment $sentiment - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the sentiment expressed for this - * mention of the entity in the provided document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The mention text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - * @return \Google\Cloud\Language\V1beta2\TextSpan|null - */ - public function getText() - { - return $this->text; - } - - public function hasText() - { - return isset($this->text); - } - - public function clearText() - { - unset($this->text); - } - - /** - * The mention text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - * @param \Google\Cloud\Language\V1beta2\TextSpan $var - * @return $this - */ - public function setText($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\TextSpan::class); - $this->text = $var; - - return $this; - } - - /** - * The type of the entity mention. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EntityMention.Type type = 2; - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * The type of the entity mention. - * - * Generated from protobuf field .google.cloud.language.v1beta2.EntityMention.Type type = 2; - * @param int $var - * @return $this - */ - public function setType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\EntityMention\Type::class); - $this->type = $var; - - return $this; - } - - /** - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the sentiment expressed for this - * mention of the entity in the provided document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 3; - * @return \Google\Cloud\Language\V1beta2\Sentiment|null - */ - public function getSentiment() - { - return $this->sentiment; - } - - public function hasSentiment() - { - return isset($this->sentiment); - } - - public function clearSentiment() - { - unset($this->sentiment); - } - - /** - * For calls to [AnalyzeEntitySentiment][] or if - * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] - * is set to true, this field will contain the sentiment expressed for this - * mention of the entity in the provided document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 3; - * @param \Google\Cloud\Language\V1beta2\Sentiment $var - * @return $this - */ - public function setSentiment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Sentiment::class); - $this->sentiment = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/EntityMention/Type.php b/Language/src/V1beta2/EntityMention/Type.php deleted file mode 100644 index 75131e71c1d..00000000000 --- a/Language/src/V1beta2/EntityMention/Type.php +++ /dev/null @@ -1,64 +0,0 @@ -google.cloud.language.v1beta2.EntityMention.Type - */ -class Type -{ - /** - * Unknown - * - * Generated from protobuf enum TYPE_UNKNOWN = 0; - */ - const TYPE_UNKNOWN = 0; - /** - * Proper name - * - * Generated from protobuf enum PROPER = 1; - */ - const PROPER = 1; - /** - * Common noun (or noun compound) - * - * Generated from protobuf enum COMMON = 2; - */ - const COMMON = 2; - - private static $valueToName = [ - self::TYPE_UNKNOWN => 'TYPE_UNKNOWN', - self::PROPER => 'PROPER', - self::COMMON => 'COMMON', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Type::class, \Google\Cloud\Language\V1beta2\EntityMention_Type::class); - diff --git a/Language/src/V1beta2/EntityMention_Type.php b/Language/src/V1beta2/EntityMention_Type.php deleted file mode 100644 index 1202dcaa1ec..00000000000 --- a/Language/src/V1beta2/EntityMention_Type.php +++ /dev/null @@ -1,16 +0,0 @@ -analyzeEntities($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @experimental - * - * @deprecated This class will be removed in the next major version update. - */ -class LanguageServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.language.v1beta2.LanguageService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'language.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'language.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/language_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/language_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/language_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/language_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'language.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $response = $languageServiceClient->analyzeEntities($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\AnalyzeEntitiesResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function analyzeEntities($document, array $optionalArgs = []) - { - $request = new AnalyzeEntitiesRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeEntities', AnalyzeEntitiesResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Finds entities, similar to - * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $response = $languageServiceClient->analyzeEntitySentiment($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function analyzeEntitySentiment($document, array $optionalArgs = []) - { - $request = new AnalyzeEntitySentimentRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeEntitySentiment', AnalyzeEntitySentimentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Analyzes the sentiment of the provided text. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $response = $languageServiceClient->analyzeSentiment($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\AnalyzeSentimentResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function analyzeSentiment($document, array $optionalArgs = []) - { - $request = new AnalyzeSentimentRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeSentiment', AnalyzeSentimentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $response = $languageServiceClient->analyzeSyntax($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\AnalyzeSyntaxResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function analyzeSyntax($document, array $optionalArgs = []) - { - $request = new AnalyzeSyntaxRequest(); - $request->setDocument($document); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnalyzeSyntax', AnalyzeSyntaxResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * A convenience method that provides all syntax, sentiment, entity, and - * classification features in one call. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $features = new Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features(); - * $response = $languageServiceClient->annotateText($document, $features); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param Features $features Required. The enabled features. - * @param array $optionalArgs { - * Optional. - * - * @type int $encodingType - * The encoding type used by the API to calculate offsets. - * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1beta2\EncodingType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\AnnotateTextResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function annotateText($document, $features, array $optionalArgs = []) - { - $request = new AnnotateTextRequest(); - $request->setDocument($document); - $request->setFeatures($features); - if (isset($optionalArgs['encodingType'])) { - $request->setEncodingType($optionalArgs['encodingType']); - } - - return $this->startCall('AnnotateText', AnnotateTextResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Classifies a document into categories. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $response = $languageServiceClient->classifyText($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type ClassificationModelOptions $classificationModelOptions - * Model options to use for classification. Defaults to v1 options if not - * specified. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\ClassifyTextResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function classifyText($document, array $optionalArgs = []) - { - $request = new ClassifyTextRequest(); - $request->setDocument($document); - if (isset($optionalArgs['classificationModelOptions'])) { - $request->setClassificationModelOptions($optionalArgs['classificationModelOptions']); - } - - return $this->startCall('ClassifyText', ClassifyTextResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Moderates a document for harmful and sensitive categories. - * - * Sample code: - * ``` - * $languageServiceClient = new Google\Cloud\Language\V1beta2\LanguageServiceClient(); - * try { - * $document = new Google\Cloud\Language\V1beta2\Document(); - * $response = $languageServiceClient->moderateText($document); - * } finally { - * $languageServiceClient->close(); - * } - * ``` - * - * @param Document $document Required. Input document. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Language\V1beta2\ModerateTextResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function moderateText($document, array $optionalArgs = []) - { - $request = new ModerateTextRequest(); - $request->setDocument($document); - return $this->startCall('ModerateText', ModerateTextResponse::class, $optionalArgs, $request)->wait(); - } -} diff --git a/Language/src/V1beta2/LanguageServiceClient.php b/Language/src/V1beta2/LanguageServiceClient.php deleted file mode 100644 index 4e633f3ec4e..00000000000 --- a/Language/src/V1beta2/LanguageServiceClient.php +++ /dev/null @@ -1,36 +0,0 @@ -_simpleRequest('/google.cloud.language.v1beta2.LanguageService/AnalyzeSentiment', - $argument, - ['\Google\Cloud\Language\V1beta2\AnalyzeSentimentResponse', 'decode'], - $metadata, $options); - } - - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * @param \Google\Cloud\Language\V1beta2\AnalyzeEntitiesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnalyzeEntities(\Google\Cloud\Language\V1beta2\AnalyzeEntitiesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1beta2.LanguageService/AnalyzeEntities', - $argument, - ['\Google\Cloud\Language\V1beta2\AnalyzeEntitiesResponse', 'decode'], - $metadata, $options); - } - - /** - * Finds entities, similar to - * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * @param \Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnalyzeEntitySentiment(\Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1beta2.LanguageService/AnalyzeEntitySentiment', - $argument, - ['\Google\Cloud\Language\V1beta2\AnalyzeEntitySentimentResponse', 'decode'], - $metadata, $options); - } - - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * @param \Google\Cloud\Language\V1beta2\AnalyzeSyntaxRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnalyzeSyntax(\Google\Cloud\Language\V1beta2\AnalyzeSyntaxRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1beta2.LanguageService/AnalyzeSyntax', - $argument, - ['\Google\Cloud\Language\V1beta2\AnalyzeSyntaxResponse', 'decode'], - $metadata, $options); - } - - /** - * Classifies a document into categories. - * @param \Google\Cloud\Language\V1beta2\ClassifyTextRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ClassifyText(\Google\Cloud\Language\V1beta2\ClassifyTextRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1beta2.LanguageService/ClassifyText', - $argument, - ['\Google\Cloud\Language\V1beta2\ClassifyTextResponse', 'decode'], - $metadata, $options); - } - - /** - * Moderates a document for harmful and sensitive categories. - * @param \Google\Cloud\Language\V1beta2\ModerateTextRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ModerateText(\Google\Cloud\Language\V1beta2\ModerateTextRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1beta2.LanguageService/ModerateText', - $argument, - ['\Google\Cloud\Language\V1beta2\ModerateTextResponse', 'decode'], - $metadata, $options); - } - - /** - * A convenience method that provides all syntax, sentiment, entity, and - * classification features in one call. - * @param \Google\Cloud\Language\V1beta2\AnnotateTextRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function AnnotateText(\Google\Cloud\Language\V1beta2\AnnotateTextRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.language.v1beta2.LanguageService/AnnotateText', - $argument, - ['\Google\Cloud\Language\V1beta2\AnnotateTextResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/Language/src/V1beta2/ModerateTextRequest.php b/Language/src/V1beta2/ModerateTextRequest.php deleted file mode 100644 index 6898261366b..00000000000 --- a/Language/src/V1beta2/ModerateTextRequest.php +++ /dev/null @@ -1,77 +0,0 @@ -google.cloud.language.v1beta2.ModerateTextRequest - */ -class ModerateTextRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $document = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\Document $document - * Required. Input document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Language\V1beta2\Document|null - */ - public function getDocument() - { - return $this->document; - } - - public function hasDocument() - { - return isset($this->document); - } - - public function clearDocument() - { - unset($this->document); - } - - /** - * Required. Input document. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Language\V1beta2\Document $var - * @return $this - */ - public function setDocument($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Document::class); - $this->document = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/ModerateTextResponse.php b/Language/src/V1beta2/ModerateTextResponse.php deleted file mode 100644 index 99c5faa0cf3..00000000000 --- a/Language/src/V1beta2/ModerateTextResponse.php +++ /dev/null @@ -1,67 +0,0 @@ -google.cloud.language.v1beta2.ModerateTextResponse - */ -class ModerateTextResponse extends \Google\Protobuf\Internal\Message -{ - /** - * Harmful and sensitive categories representing the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory moderation_categories = 1; - */ - private $moderation_categories; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $moderation_categories - * Harmful and sensitive categories representing the input document. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * Harmful and sensitive categories representing the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory moderation_categories = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getModerationCategories() - { - return $this->moderation_categories; - } - - /** - * Harmful and sensitive categories representing the input document. - * - * Generated from protobuf field repeated .google.cloud.language.v1beta2.ClassificationCategory moderation_categories = 1; - * @param array<\Google\Cloud\Language\V1beta2\ClassificationCategory>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setModerationCategories($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\ClassificationCategory::class); - $this->moderation_categories = $arr; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/PartOfSpeech.php b/Language/src/V1beta2/PartOfSpeech.php deleted file mode 100644 index 0ddf29f6087..00000000000 --- a/Language/src/V1beta2/PartOfSpeech.php +++ /dev/null @@ -1,441 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech - */ -class PartOfSpeech extends \Google\Protobuf\Internal\Message -{ - /** - * The part of speech tag. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Tag tag = 1; - */ - private $tag = 0; - /** - * The grammatical aspect. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Aspect aspect = 2; - */ - private $aspect = 0; - /** - * The grammatical case. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Case case = 3; - */ - private $case = 0; - /** - * The grammatical form. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Form form = 4; - */ - private $form = 0; - /** - * The grammatical gender. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Gender gender = 5; - */ - private $gender = 0; - /** - * The grammatical mood. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Mood mood = 6; - */ - private $mood = 0; - /** - * The grammatical number. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Number number = 7; - */ - private $number = 0; - /** - * The grammatical person. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Person person = 8; - */ - private $person = 0; - /** - * The grammatical properness. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Proper proper = 9; - */ - private $proper = 0; - /** - * The grammatical reciprocity. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Reciprocity reciprocity = 10; - */ - private $reciprocity = 0; - /** - * The grammatical tense. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Tense tense = 11; - */ - private $tense = 0; - /** - * The grammatical voice. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Voice voice = 12; - */ - private $voice = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $tag - * The part of speech tag. - * @type int $aspect - * The grammatical aspect. - * @type int $case - * The grammatical case. - * @type int $form - * The grammatical form. - * @type int $gender - * The grammatical gender. - * @type int $mood - * The grammatical mood. - * @type int $number - * The grammatical number. - * @type int $person - * The grammatical person. - * @type int $proper - * The grammatical properness. - * @type int $reciprocity - * The grammatical reciprocity. - * @type int $tense - * The grammatical tense. - * @type int $voice - * The grammatical voice. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The part of speech tag. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Tag tag = 1; - * @return int - */ - public function getTag() - { - return $this->tag; - } - - /** - * The part of speech tag. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Tag tag = 1; - * @param int $var - * @return $this - */ - public function setTag($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Tag::class); - $this->tag = $var; - - return $this; - } - - /** - * The grammatical aspect. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Aspect aspect = 2; - * @return int - */ - public function getAspect() - { - return $this->aspect; - } - - /** - * The grammatical aspect. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Aspect aspect = 2; - * @param int $var - * @return $this - */ - public function setAspect($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Aspect::class); - $this->aspect = $var; - - return $this; - } - - /** - * The grammatical case. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Case case = 3; - * @return int - */ - public function getCase() - { - return $this->case; - } - - /** - * The grammatical case. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Case case = 3; - * @param int $var - * @return $this - */ - public function setCase($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\PBCase::class); - $this->case = $var; - - return $this; - } - - /** - * The grammatical form. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Form form = 4; - * @return int - */ - public function getForm() - { - return $this->form; - } - - /** - * The grammatical form. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Form form = 4; - * @param int $var - * @return $this - */ - public function setForm($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Form::class); - $this->form = $var; - - return $this; - } - - /** - * The grammatical gender. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Gender gender = 5; - * @return int - */ - public function getGender() - { - return $this->gender; - } - - /** - * The grammatical gender. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Gender gender = 5; - * @param int $var - * @return $this - */ - public function setGender($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Gender::class); - $this->gender = $var; - - return $this; - } - - /** - * The grammatical mood. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Mood mood = 6; - * @return int - */ - public function getMood() - { - return $this->mood; - } - - /** - * The grammatical mood. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Mood mood = 6; - * @param int $var - * @return $this - */ - public function setMood($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Mood::class); - $this->mood = $var; - - return $this; - } - - /** - * The grammatical number. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Number number = 7; - * @return int - */ - public function getNumber() - { - return $this->number; - } - - /** - * The grammatical number. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Number number = 7; - * @param int $var - * @return $this - */ - public function setNumber($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Number::class); - $this->number = $var; - - return $this; - } - - /** - * The grammatical person. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Person person = 8; - * @return int - */ - public function getPerson() - { - return $this->person; - } - - /** - * The grammatical person. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Person person = 8; - * @param int $var - * @return $this - */ - public function setPerson($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Person::class); - $this->person = $var; - - return $this; - } - - /** - * The grammatical properness. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Proper proper = 9; - * @return int - */ - public function getProper() - { - return $this->proper; - } - - /** - * The grammatical properness. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Proper proper = 9; - * @param int $var - * @return $this - */ - public function setProper($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Proper::class); - $this->proper = $var; - - return $this; - } - - /** - * The grammatical reciprocity. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Reciprocity reciprocity = 10; - * @return int - */ - public function getReciprocity() - { - return $this->reciprocity; - } - - /** - * The grammatical reciprocity. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Reciprocity reciprocity = 10; - * @param int $var - * @return $this - */ - public function setReciprocity($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Reciprocity::class); - $this->reciprocity = $var; - - return $this; - } - - /** - * The grammatical tense. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Tense tense = 11; - * @return int - */ - public function getTense() - { - return $this->tense; - } - - /** - * The grammatical tense. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Tense tense = 11; - * @param int $var - * @return $this - */ - public function setTense($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Tense::class); - $this->tense = $var; - - return $this; - } - - /** - * The grammatical voice. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Voice voice = 12; - * @return int - */ - public function getVoice() - { - return $this->voice; - } - - /** - * The grammatical voice. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech.Voice voice = 12; - * @param int $var - * @return $this - */ - public function setVoice($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Language\V1beta2\PartOfSpeech\Voice::class); - $this->voice = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/PartOfSpeech/Aspect.php b/Language/src/V1beta2/PartOfSpeech/Aspect.php deleted file mode 100644 index 48882ba09ce..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Aspect.php +++ /dev/null @@ -1,71 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Aspect - */ -class Aspect -{ - /** - * Aspect is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum ASPECT_UNKNOWN = 0; - */ - const ASPECT_UNKNOWN = 0; - /** - * Perfective - * - * Generated from protobuf enum PERFECTIVE = 1; - */ - const PERFECTIVE = 1; - /** - * Imperfective - * - * Generated from protobuf enum IMPERFECTIVE = 2; - */ - const IMPERFECTIVE = 2; - /** - * Progressive - * - * Generated from protobuf enum PROGRESSIVE = 3; - */ - const PROGRESSIVE = 3; - - private static $valueToName = [ - self::ASPECT_UNKNOWN => 'ASPECT_UNKNOWN', - self::PERFECTIVE => 'PERFECTIVE', - self::IMPERFECTIVE => 'IMPERFECTIVE', - self::PROGRESSIVE => 'PROGRESSIVE', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Aspect::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Aspect::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Form.php b/Language/src/V1beta2/PartOfSpeech/Form.php deleted file mode 100644 index b3c1847352d..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Form.php +++ /dev/null @@ -1,130 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Form - */ -class Form -{ - /** - * Form is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum FORM_UNKNOWN = 0; - */ - const FORM_UNKNOWN = 0; - /** - * Adnomial - * - * Generated from protobuf enum ADNOMIAL = 1; - */ - const ADNOMIAL = 1; - /** - * Auxiliary - * - * Generated from protobuf enum AUXILIARY = 2; - */ - const AUXILIARY = 2; - /** - * Complementizer - * - * Generated from protobuf enum COMPLEMENTIZER = 3; - */ - const COMPLEMENTIZER = 3; - /** - * Final ending - * - * Generated from protobuf enum FINAL_ENDING = 4; - */ - const FINAL_ENDING = 4; - /** - * Gerund - * - * Generated from protobuf enum GERUND = 5; - */ - const GERUND = 5; - /** - * Realis - * - * Generated from protobuf enum REALIS = 6; - */ - const REALIS = 6; - /** - * Irrealis - * - * Generated from protobuf enum IRREALIS = 7; - */ - const IRREALIS = 7; - /** - * Short form - * - * Generated from protobuf enum SHORT = 8; - */ - const SHORT = 8; - /** - * Long form - * - * Generated from protobuf enum LONG = 9; - */ - const LONG = 9; - /** - * Order form - * - * Generated from protobuf enum ORDER = 10; - */ - const ORDER = 10; - /** - * Specific form - * - * Generated from protobuf enum SPECIFIC = 11; - */ - const SPECIFIC = 11; - - private static $valueToName = [ - self::FORM_UNKNOWN => 'FORM_UNKNOWN', - self::ADNOMIAL => 'ADNOMIAL', - self::AUXILIARY => 'AUXILIARY', - self::COMPLEMENTIZER => 'COMPLEMENTIZER', - self::FINAL_ENDING => 'FINAL_ENDING', - self::GERUND => 'GERUND', - self::REALIS => 'REALIS', - self::IRREALIS => 'IRREALIS', - self::SHORT => 'SHORT', - self::LONG => 'LONG', - self::ORDER => 'ORDER', - self::SPECIFIC => 'SPECIFIC', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Form::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Form::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Gender.php b/Language/src/V1beta2/PartOfSpeech/Gender.php deleted file mode 100644 index 8481abbc6b9..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Gender.php +++ /dev/null @@ -1,71 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Gender - */ -class Gender -{ - /** - * Gender is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum GENDER_UNKNOWN = 0; - */ - const GENDER_UNKNOWN = 0; - /** - * Feminine - * - * Generated from protobuf enum FEMININE = 1; - */ - const FEMININE = 1; - /** - * Masculine - * - * Generated from protobuf enum MASCULINE = 2; - */ - const MASCULINE = 2; - /** - * Neuter - * - * Generated from protobuf enum NEUTER = 3; - */ - const NEUTER = 3; - - private static $valueToName = [ - self::GENDER_UNKNOWN => 'GENDER_UNKNOWN', - self::FEMININE => 'FEMININE', - self::MASCULINE => 'MASCULINE', - self::NEUTER => 'NEUTER', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Gender::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Gender::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Mood.php b/Language/src/V1beta2/PartOfSpeech/Mood.php deleted file mode 100644 index 8857bc7dcd4..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Mood.php +++ /dev/null @@ -1,92 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Mood - */ -class Mood -{ - /** - * Mood is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum MOOD_UNKNOWN = 0; - */ - const MOOD_UNKNOWN = 0; - /** - * Conditional - * - * Generated from protobuf enum CONDITIONAL_MOOD = 1; - */ - const CONDITIONAL_MOOD = 1; - /** - * Imperative - * - * Generated from protobuf enum IMPERATIVE = 2; - */ - const IMPERATIVE = 2; - /** - * Indicative - * - * Generated from protobuf enum INDICATIVE = 3; - */ - const INDICATIVE = 3; - /** - * Interrogative - * - * Generated from protobuf enum INTERROGATIVE = 4; - */ - const INTERROGATIVE = 4; - /** - * Jussive - * - * Generated from protobuf enum JUSSIVE = 5; - */ - const JUSSIVE = 5; - /** - * Subjunctive - * - * Generated from protobuf enum SUBJUNCTIVE = 6; - */ - const SUBJUNCTIVE = 6; - - private static $valueToName = [ - self::MOOD_UNKNOWN => 'MOOD_UNKNOWN', - self::CONDITIONAL_MOOD => 'CONDITIONAL_MOOD', - self::IMPERATIVE => 'IMPERATIVE', - self::INDICATIVE => 'INDICATIVE', - self::INTERROGATIVE => 'INTERROGATIVE', - self::JUSSIVE => 'JUSSIVE', - self::SUBJUNCTIVE => 'SUBJUNCTIVE', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Mood::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Mood::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Number.php b/Language/src/V1beta2/PartOfSpeech/Number.php deleted file mode 100644 index f3c9eddeaf9..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Number.php +++ /dev/null @@ -1,71 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Number - */ -class Number -{ - /** - * Number is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum NUMBER_UNKNOWN = 0; - */ - const NUMBER_UNKNOWN = 0; - /** - * Singular - * - * Generated from protobuf enum SINGULAR = 1; - */ - const SINGULAR = 1; - /** - * Plural - * - * Generated from protobuf enum PLURAL = 2; - */ - const PLURAL = 2; - /** - * Dual - * - * Generated from protobuf enum DUAL = 3; - */ - const DUAL = 3; - - private static $valueToName = [ - self::NUMBER_UNKNOWN => 'NUMBER_UNKNOWN', - self::SINGULAR => 'SINGULAR', - self::PLURAL => 'PLURAL', - self::DUAL => 'DUAL', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Number::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Number::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/PBCase.php b/Language/src/V1beta2/PartOfSpeech/PBCase.php deleted file mode 100644 index f110d8846a1..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/PBCase.php +++ /dev/null @@ -1,150 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Case - */ -class PBCase -{ - /** - * Case is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum CASE_UNKNOWN = 0; - */ - const CASE_UNKNOWN = 0; - /** - * Accusative - * - * Generated from protobuf enum ACCUSATIVE = 1; - */ - const ACCUSATIVE = 1; - /** - * Adverbial - * - * Generated from protobuf enum ADVERBIAL = 2; - */ - const ADVERBIAL = 2; - /** - * Complementive - * - * Generated from protobuf enum COMPLEMENTIVE = 3; - */ - const COMPLEMENTIVE = 3; - /** - * Dative - * - * Generated from protobuf enum DATIVE = 4; - */ - const DATIVE = 4; - /** - * Genitive - * - * Generated from protobuf enum GENITIVE = 5; - */ - const GENITIVE = 5; - /** - * Instrumental - * - * Generated from protobuf enum INSTRUMENTAL = 6; - */ - const INSTRUMENTAL = 6; - /** - * Locative - * - * Generated from protobuf enum LOCATIVE = 7; - */ - const LOCATIVE = 7; - /** - * Nominative - * - * Generated from protobuf enum NOMINATIVE = 8; - */ - const NOMINATIVE = 8; - /** - * Oblique - * - * Generated from protobuf enum OBLIQUE = 9; - */ - const OBLIQUE = 9; - /** - * Partitive - * - * Generated from protobuf enum PARTITIVE = 10; - */ - const PARTITIVE = 10; - /** - * Prepositional - * - * Generated from protobuf enum PREPOSITIONAL = 11; - */ - const PREPOSITIONAL = 11; - /** - * Reflexive - * - * Generated from protobuf enum REFLEXIVE_CASE = 12; - */ - const REFLEXIVE_CASE = 12; - /** - * Relative - * - * Generated from protobuf enum RELATIVE_CASE = 13; - */ - const RELATIVE_CASE = 13; - /** - * Vocative - * - * Generated from protobuf enum VOCATIVE = 14; - */ - const VOCATIVE = 14; - - private static $valueToName = [ - self::CASE_UNKNOWN => 'CASE_UNKNOWN', - self::ACCUSATIVE => 'ACCUSATIVE', - self::ADVERBIAL => 'ADVERBIAL', - self::COMPLEMENTIVE => 'COMPLEMENTIVE', - self::DATIVE => 'DATIVE', - self::GENITIVE => 'GENITIVE', - self::INSTRUMENTAL => 'INSTRUMENTAL', - self::LOCATIVE => 'LOCATIVE', - self::NOMINATIVE => 'NOMINATIVE', - self::OBLIQUE => 'OBLIQUE', - self::PARTITIVE => 'PARTITIVE', - self::PREPOSITIONAL => 'PREPOSITIONAL', - self::REFLEXIVE_CASE => 'REFLEXIVE_CASE', - self::RELATIVE_CASE => 'RELATIVE_CASE', - self::VOCATIVE => 'VOCATIVE', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(PBCase::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Case::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Person.php b/Language/src/V1beta2/PartOfSpeech/Person.php deleted file mode 100644 index 9584fd35c7c..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Person.php +++ /dev/null @@ -1,78 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Person - */ -class Person -{ - /** - * Person is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum PERSON_UNKNOWN = 0; - */ - const PERSON_UNKNOWN = 0; - /** - * First - * - * Generated from protobuf enum FIRST = 1; - */ - const FIRST = 1; - /** - * Second - * - * Generated from protobuf enum SECOND = 2; - */ - const SECOND = 2; - /** - * Third - * - * Generated from protobuf enum THIRD = 3; - */ - const THIRD = 3; - /** - * Reflexive - * - * Generated from protobuf enum REFLEXIVE_PERSON = 4; - */ - const REFLEXIVE_PERSON = 4; - - private static $valueToName = [ - self::PERSON_UNKNOWN => 'PERSON_UNKNOWN', - self::FIRST => 'FIRST', - self::SECOND => 'SECOND', - self::THIRD => 'THIRD', - self::REFLEXIVE_PERSON => 'REFLEXIVE_PERSON', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Person::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Person::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Proper.php b/Language/src/V1beta2/PartOfSpeech/Proper.php deleted file mode 100644 index d71aded410d..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Proper.php +++ /dev/null @@ -1,64 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Proper - */ -class Proper -{ - /** - * Proper is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum PROPER_UNKNOWN = 0; - */ - const PROPER_UNKNOWN = 0; - /** - * Proper - * - * Generated from protobuf enum PROPER = 1; - */ - const PROPER = 1; - /** - * Not proper - * - * Generated from protobuf enum NOT_PROPER = 2; - */ - const NOT_PROPER = 2; - - private static $valueToName = [ - self::PROPER_UNKNOWN => 'PROPER_UNKNOWN', - self::PROPER => 'PROPER', - self::NOT_PROPER => 'NOT_PROPER', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Proper::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Proper::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Reciprocity.php b/Language/src/V1beta2/PartOfSpeech/Reciprocity.php deleted file mode 100644 index aae22e4dd76..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Reciprocity.php +++ /dev/null @@ -1,65 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Reciprocity - */ -class Reciprocity -{ - /** - * Reciprocity is not applicable in the analyzed language or is not - * predicted. - * - * Generated from protobuf enum RECIPROCITY_UNKNOWN = 0; - */ - const RECIPROCITY_UNKNOWN = 0; - /** - * Reciprocal - * - * Generated from protobuf enum RECIPROCAL = 1; - */ - const RECIPROCAL = 1; - /** - * Non-reciprocal - * - * Generated from protobuf enum NON_RECIPROCAL = 2; - */ - const NON_RECIPROCAL = 2; - - private static $valueToName = [ - self::RECIPROCITY_UNKNOWN => 'RECIPROCITY_UNKNOWN', - self::RECIPROCAL => 'RECIPROCAL', - self::NON_RECIPROCAL => 'NON_RECIPROCAL', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Reciprocity::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Reciprocity::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Tag.php b/Language/src/V1beta2/PartOfSpeech/Tag.php deleted file mode 100644 index 0fb0d7e7e81..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Tag.php +++ /dev/null @@ -1,141 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Tag - */ -class Tag -{ - /** - * Unknown - * - * Generated from protobuf enum UNKNOWN = 0; - */ - const UNKNOWN = 0; - /** - * Adjective - * - * Generated from protobuf enum ADJ = 1; - */ - const ADJ = 1; - /** - * Adposition (preposition and postposition) - * - * Generated from protobuf enum ADP = 2; - */ - const ADP = 2; - /** - * Adverb - * - * Generated from protobuf enum ADV = 3; - */ - const ADV = 3; - /** - * Conjunction - * - * Generated from protobuf enum CONJ = 4; - */ - const CONJ = 4; - /** - * Determiner - * - * Generated from protobuf enum DET = 5; - */ - const DET = 5; - /** - * Noun (common and proper) - * - * Generated from protobuf enum NOUN = 6; - */ - const NOUN = 6; - /** - * Cardinal number - * - * Generated from protobuf enum NUM = 7; - */ - const NUM = 7; - /** - * Pronoun - * - * Generated from protobuf enum PRON = 8; - */ - const PRON = 8; - /** - * Particle or other function word - * - * Generated from protobuf enum PRT = 9; - */ - const PRT = 9; - /** - * Punctuation - * - * Generated from protobuf enum PUNCT = 10; - */ - const PUNCT = 10; - /** - * Verb (all tenses and modes) - * - * Generated from protobuf enum VERB = 11; - */ - const VERB = 11; - /** - * Other: foreign words, typos, abbreviations - * - * Generated from protobuf enum X = 12; - */ - const X = 12; - /** - * Affix - * - * Generated from protobuf enum AFFIX = 13; - */ - const AFFIX = 13; - - private static $valueToName = [ - self::UNKNOWN => 'UNKNOWN', - self::ADJ => 'ADJ', - self::ADP => 'ADP', - self::ADV => 'ADV', - self::CONJ => 'CONJ', - self::DET => 'DET', - self::NOUN => 'NOUN', - self::NUM => 'NUM', - self::PRON => 'PRON', - self::PRT => 'PRT', - self::PUNCT => 'PUNCT', - self::VERB => 'VERB', - self::X => 'X', - self::AFFIX => 'AFFIX', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Tag::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Tag::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Tense.php b/Language/src/V1beta2/PartOfSpeech/Tense.php deleted file mode 100644 index e9e4e2000ad..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Tense.php +++ /dev/null @@ -1,92 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Tense - */ -class Tense -{ - /** - * Tense is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum TENSE_UNKNOWN = 0; - */ - const TENSE_UNKNOWN = 0; - /** - * Conditional - * - * Generated from protobuf enum CONDITIONAL_TENSE = 1; - */ - const CONDITIONAL_TENSE = 1; - /** - * Future - * - * Generated from protobuf enum FUTURE = 2; - */ - const FUTURE = 2; - /** - * Past - * - * Generated from protobuf enum PAST = 3; - */ - const PAST = 3; - /** - * Present - * - * Generated from protobuf enum PRESENT = 4; - */ - const PRESENT = 4; - /** - * Imperfect - * - * Generated from protobuf enum IMPERFECT = 5; - */ - const IMPERFECT = 5; - /** - * Pluperfect - * - * Generated from protobuf enum PLUPERFECT = 6; - */ - const PLUPERFECT = 6; - - private static $valueToName = [ - self::TENSE_UNKNOWN => 'TENSE_UNKNOWN', - self::CONDITIONAL_TENSE => 'CONDITIONAL_TENSE', - self::FUTURE => 'FUTURE', - self::PAST => 'PAST', - self::PRESENT => 'PRESENT', - self::IMPERFECT => 'IMPERFECT', - self::PLUPERFECT => 'PLUPERFECT', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Tense::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Tense::class); - diff --git a/Language/src/V1beta2/PartOfSpeech/Voice.php b/Language/src/V1beta2/PartOfSpeech/Voice.php deleted file mode 100644 index b1cfd65aeaa..00000000000 --- a/Language/src/V1beta2/PartOfSpeech/Voice.php +++ /dev/null @@ -1,72 +0,0 @@ -google.cloud.language.v1beta2.PartOfSpeech.Voice - */ -class Voice -{ - /** - * Voice is not applicable in the analyzed language or is not predicted. - * - * Generated from protobuf enum VOICE_UNKNOWN = 0; - */ - const VOICE_UNKNOWN = 0; - /** - * Active - * - * Generated from protobuf enum ACTIVE = 1; - */ - const ACTIVE = 1; - /** - * Causative - * - * Generated from protobuf enum CAUSATIVE = 2; - */ - const CAUSATIVE = 2; - /** - * Passive - * - * Generated from protobuf enum PASSIVE = 3; - */ - const PASSIVE = 3; - - private static $valueToName = [ - self::VOICE_UNKNOWN => 'VOICE_UNKNOWN', - self::ACTIVE => 'ACTIVE', - self::CAUSATIVE => 'CAUSATIVE', - self::PASSIVE => 'PASSIVE', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Voice::class, \Google\Cloud\Language\V1beta2\PartOfSpeech_Voice::class); - diff --git a/Language/src/V1beta2/PartOfSpeech_Aspect.php b/Language/src/V1beta2/PartOfSpeech_Aspect.php deleted file mode 100644 index 15059e3520b..00000000000 --- a/Language/src/V1beta2/PartOfSpeech_Aspect.php +++ /dev/null @@ -1,16 +0,0 @@ - '/Users/dsupplee/Downloads/gcloud.json' -]); - -$document = new Document([ - 'content' => 'Greetings from Michigan!', - 'type' => Type::PLAIN_TEXT -]); -$features = new Features([ - 'extract_document_sentiment' => true, - 'extract_entities' => true, - 'extract_syntax' => true -]); - -// Annotate the document. -$response = $client->annotateText($document, $features); - -// Check the sentiment. -$sentimentScore = $response->getDocumentSentiment() - ->getScore(); - -if ($sentimentScore > 0) { - echo 'This is a positive message.' . PHP_EOL; -} - -// Detect entities. -foreach ($response->getEntities() as $entity) { - printf( - '[%s] %s', - EntityType::name($entity->getType()), - $entity->getName() - ); - echo PHP_EOL; -} - -// Parse the syntax. -foreach ($response->getTokens() as $token) { - $speechTag = Tag::name($token->getPartOfSpeech()->getTag()); - - printf( - '[%s] %s', - $speechTag, - $token->getText()->getContent() - ); - echo PHP_EOL; -} -``` diff --git a/Language/src/V1beta2/Sentence.php b/Language/src/V1beta2/Sentence.php deleted file mode 100644 index f882b8130a2..00000000000 --- a/Language/src/V1beta2/Sentence.php +++ /dev/null @@ -1,129 +0,0 @@ -google.cloud.language.v1beta2.Sentence - */ -class Sentence extends \Google\Protobuf\Internal\Message -{ - /** - * The sentence text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - */ - private $text = null; - /** - * For calls to [AnalyzeSentiment][] or if - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] - * is set to true, this field will contain the sentiment for the sentence. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 2; - */ - private $sentiment = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\TextSpan $text - * The sentence text. - * @type \Google\Cloud\Language\V1beta2\Sentiment $sentiment - * For calls to [AnalyzeSentiment][] or if - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] - * is set to true, this field will contain the sentiment for the sentence. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The sentence text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - * @return \Google\Cloud\Language\V1beta2\TextSpan|null - */ - public function getText() - { - return $this->text; - } - - public function hasText() - { - return isset($this->text); - } - - public function clearText() - { - unset($this->text); - } - - /** - * The sentence text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - * @param \Google\Cloud\Language\V1beta2\TextSpan $var - * @return $this - */ - public function setText($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\TextSpan::class); - $this->text = $var; - - return $this; - } - - /** - * For calls to [AnalyzeSentiment][] or if - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] - * is set to true, this field will contain the sentiment for the sentence. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 2; - * @return \Google\Cloud\Language\V1beta2\Sentiment|null - */ - public function getSentiment() - { - return $this->sentiment; - } - - public function hasSentiment() - { - return isset($this->sentiment); - } - - public function clearSentiment() - { - unset($this->sentiment); - } - - /** - * For calls to [AnalyzeSentiment][] or if - * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] - * is set to true, this field will contain the sentiment for the sentence. - * - * Generated from protobuf field .google.cloud.language.v1beta2.Sentiment sentiment = 2; - * @param \Google\Cloud\Language\V1beta2\Sentiment $var - * @return $this - */ - public function setSentiment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\Sentiment::class); - $this->sentiment = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/Sentiment.php b/Language/src/V1beta2/Sentiment.php deleted file mode 100644 index 01a2bc4b889..00000000000 --- a/Language/src/V1beta2/Sentiment.php +++ /dev/null @@ -1,115 +0,0 @@ -google.cloud.language.v1beta2.Sentiment - */ -class Sentiment extends \Google\Protobuf\Internal\Message -{ - /** - * A non-negative number in the [0, +inf) range, which represents - * the absolute magnitude of sentiment regardless of score (positive or - * negative). - * - * Generated from protobuf field float magnitude = 2; - */ - private $magnitude = 0.0; - /** - * Sentiment score between -1.0 (negative sentiment) and 1.0 - * (positive sentiment). - * - * Generated from protobuf field float score = 3; - */ - private $score = 0.0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type float $magnitude - * A non-negative number in the [0, +inf) range, which represents - * the absolute magnitude of sentiment regardless of score (positive or - * negative). - * @type float $score - * Sentiment score between -1.0 (negative sentiment) and 1.0 - * (positive sentiment). - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * A non-negative number in the [0, +inf) range, which represents - * the absolute magnitude of sentiment regardless of score (positive or - * negative). - * - * Generated from protobuf field float magnitude = 2; - * @return float - */ - public function getMagnitude() - { - return $this->magnitude; - } - - /** - * A non-negative number in the [0, +inf) range, which represents - * the absolute magnitude of sentiment regardless of score (positive or - * negative). - * - * Generated from protobuf field float magnitude = 2; - * @param float $var - * @return $this - */ - public function setMagnitude($var) - { - GPBUtil::checkFloat($var); - $this->magnitude = $var; - - return $this; - } - - /** - * Sentiment score between -1.0 (negative sentiment) and 1.0 - * (positive sentiment). - * - * Generated from protobuf field float score = 3; - * @return float - */ - public function getScore() - { - return $this->score; - } - - /** - * Sentiment score between -1.0 (negative sentiment) and 1.0 - * (positive sentiment). - * - * Generated from protobuf field float score = 3; - * @param float $var - * @return $this - */ - public function setScore($var) - { - GPBUtil::checkFloat($var); - $this->score = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/TextSpan.php b/Language/src/V1beta2/TextSpan.php deleted file mode 100644 index ab0836775f2..00000000000 --- a/Language/src/V1beta2/TextSpan.php +++ /dev/null @@ -1,113 +0,0 @@ -google.cloud.language.v1beta2.TextSpan - */ -class TextSpan extends \Google\Protobuf\Internal\Message -{ - /** - * The content of the output text. - * - * Generated from protobuf field string content = 1; - */ - private $content = ''; - /** - * The API calculates the beginning offset of the content in the original - * document according to the - * [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the - * API request. - * - * Generated from protobuf field int32 begin_offset = 2; - */ - private $begin_offset = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $content - * The content of the output text. - * @type int $begin_offset - * The API calculates the beginning offset of the content in the original - * document according to the - * [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the - * API request. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The content of the output text. - * - * Generated from protobuf field string content = 1; - * @return string - */ - public function getContent() - { - return $this->content; - } - - /** - * The content of the output text. - * - * Generated from protobuf field string content = 1; - * @param string $var - * @return $this - */ - public function setContent($var) - { - GPBUtil::checkString($var, True); - $this->content = $var; - - return $this; - } - - /** - * The API calculates the beginning offset of the content in the original - * document according to the - * [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the - * API request. - * - * Generated from protobuf field int32 begin_offset = 2; - * @return int - */ - public function getBeginOffset() - { - return $this->begin_offset; - } - - /** - * The API calculates the beginning offset of the content in the original - * document according to the - * [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the - * API request. - * - * Generated from protobuf field int32 begin_offset = 2; - * @param int $var - * @return $this - */ - public function setBeginOffset($var) - { - GPBUtil::checkInt32($var); - $this->begin_offset = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/Token.php b/Language/src/V1beta2/Token.php deleted file mode 100644 index 49dd99f6893..00000000000 --- a/Language/src/V1beta2/Token.php +++ /dev/null @@ -1,199 +0,0 @@ -google.cloud.language.v1beta2.Token - */ -class Token extends \Google\Protobuf\Internal\Message -{ - /** - * The token text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - */ - private $text = null; - /** - * Parts of speech tag for this token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech part_of_speech = 2; - */ - private $part_of_speech = null; - /** - * Dependency tree parse for this token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.DependencyEdge dependency_edge = 3; - */ - private $dependency_edge = null; - /** - * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - * - * Generated from protobuf field string lemma = 4; - */ - private $lemma = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Language\V1beta2\TextSpan $text - * The token text. - * @type \Google\Cloud\Language\V1beta2\PartOfSpeech $part_of_speech - * Parts of speech tag for this token. - * @type \Google\Cloud\Language\V1beta2\DependencyEdge $dependency_edge - * Dependency tree parse for this token. - * @type string $lemma - * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Language\V1Beta2\LanguageService::initOnce(); - parent::__construct($data); - } - - /** - * The token text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - * @return \Google\Cloud\Language\V1beta2\TextSpan|null - */ - public function getText() - { - return $this->text; - } - - public function hasText() - { - return isset($this->text); - } - - public function clearText() - { - unset($this->text); - } - - /** - * The token text. - * - * Generated from protobuf field .google.cloud.language.v1beta2.TextSpan text = 1; - * @param \Google\Cloud\Language\V1beta2\TextSpan $var - * @return $this - */ - public function setText($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\TextSpan::class); - $this->text = $var; - - return $this; - } - - /** - * Parts of speech tag for this token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech part_of_speech = 2; - * @return \Google\Cloud\Language\V1beta2\PartOfSpeech|null - */ - public function getPartOfSpeech() - { - return $this->part_of_speech; - } - - public function hasPartOfSpeech() - { - return isset($this->part_of_speech); - } - - public function clearPartOfSpeech() - { - unset($this->part_of_speech); - } - - /** - * Parts of speech tag for this token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.PartOfSpeech part_of_speech = 2; - * @param \Google\Cloud\Language\V1beta2\PartOfSpeech $var - * @return $this - */ - public function setPartOfSpeech($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\PartOfSpeech::class); - $this->part_of_speech = $var; - - return $this; - } - - /** - * Dependency tree parse for this token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.DependencyEdge dependency_edge = 3; - * @return \Google\Cloud\Language\V1beta2\DependencyEdge|null - */ - public function getDependencyEdge() - { - return $this->dependency_edge; - } - - public function hasDependencyEdge() - { - return isset($this->dependency_edge); - } - - public function clearDependencyEdge() - { - unset($this->dependency_edge); - } - - /** - * Dependency tree parse for this token. - * - * Generated from protobuf field .google.cloud.language.v1beta2.DependencyEdge dependency_edge = 3; - * @param \Google\Cloud\Language\V1beta2\DependencyEdge $var - * @return $this - */ - public function setDependencyEdge($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Language\V1beta2\DependencyEdge::class); - $this->dependency_edge = $var; - - return $this; - } - - /** - * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - * - * Generated from protobuf field string lemma = 4; - * @return string - */ - public function getLemma() - { - return $this->lemma; - } - - /** - * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - * - * Generated from protobuf field string lemma = 4; - * @param string $var - * @return $this - */ - public function setLemma($var) - { - GPBUtil::checkString($var, True); - $this->lemma = $var; - - return $this; - } - -} - diff --git a/Language/src/V1beta2/gapic_metadata.json b/Language/src/V1beta2/gapic_metadata.json deleted file mode 100644 index 15d19a22b05..00000000000 --- a/Language/src/V1beta2/gapic_metadata.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", - "language": "php", - "protoPackage": "google.cloud.language.v1beta2", - "libraryPackage": "Google\\Cloud\\Language\\V1beta2", - "services": { - "LanguageService": { - "clients": { - "grpc": { - "libraryClient": "LanguageServiceGapicClient", - "rpcs": { - "AnalyzeEntities": { - "methods": [ - "analyzeEntities" - ] - }, - "AnalyzeEntitySentiment": { - "methods": [ - "analyzeEntitySentiment" - ] - }, - "AnalyzeSentiment": { - "methods": [ - "analyzeSentiment" - ] - }, - "AnalyzeSyntax": { - "methods": [ - "analyzeSyntax" - ] - }, - "AnnotateText": { - "methods": [ - "annotateText" - ] - }, - "ClassifyText": { - "methods": [ - "classifyText" - ] - }, - "ModerateText": { - "methods": [ - "moderateText" - ] - } - } - } - } - } - } -} \ No newline at end of file diff --git a/Language/src/V1beta2/resources/language_service_client_config.json b/Language/src/V1beta2/resources/language_service_client_config.json deleted file mode 100644 index 33aee9f82ca..00000000000 --- a/Language/src/V1beta2/resources/language_service_client_config.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "interfaces": { - "google.cloud.language.v1beta2.LanguageService": { - "retry_codes": { - "no_retry_codes": [], - "retry_policy_1_codes": [ - "UNAVAILABLE", - "DEADLINE_EXCEEDED" - ] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - }, - "retry_policy_1_params": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 600000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 600000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "AnalyzeEntities": { - "timeout_millis": 600000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "AnalyzeEntitySentiment": { - "timeout_millis": 600000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "AnalyzeSentiment": { - "timeout_millis": 600000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "AnalyzeSyntax": { - "timeout_millis": 600000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "AnnotateText": { - "timeout_millis": 600000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "ClassifyText": { - "timeout_millis": 600000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "ModerateText": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - } - } - } - } -} diff --git a/Language/src/V1beta2/resources/language_service_descriptor_config.php b/Language/src/V1beta2/resources/language_service_descriptor_config.php deleted file mode 100644 index 748ed652ec9..00000000000 --- a/Language/src/V1beta2/resources/language_service_descriptor_config.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - 'google.cloud.language.v1beta2.LanguageService' => [], - ], -]; diff --git a/Language/src/V1beta2/resources/language_service_rest_client_config.php b/Language/src/V1beta2/resources/language_service_rest_client_config.php deleted file mode 100644 index 99ccfe4ee08..00000000000 --- a/Language/src/V1beta2/resources/language_service_rest_client_config.php +++ /dev/null @@ -1,64 +0,0 @@ - [ - 'google.cloud.language.v1beta2.LanguageService' => [ - 'AnalyzeEntities' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:analyzeEntities', - 'body' => '*', - ], - 'AnalyzeEntitySentiment' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:analyzeEntitySentiment', - 'body' => '*', - ], - 'AnalyzeSentiment' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:analyzeSentiment', - 'body' => '*', - ], - 'AnalyzeSyntax' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:analyzeSyntax', - 'body' => '*', - ], - 'AnnotateText' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:annotateText', - 'body' => '*', - ], - 'ClassifyText' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:classifyText', - 'body' => '*', - ], - 'ModerateText' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta2/documents:moderateText', - 'body' => '*', - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/Language/tests/Snippet/AnnotationTest.php b/Language/tests/Snippet/AnnotationTest.php deleted file mode 100644 index 39f5ce64a3b..00000000000 --- a/Language/tests/Snippet/AnnotationTest.php +++ /dev/null @@ -1,181 +0,0 @@ -info = [ - 'categories' => [ - [ - 'name' => 'my-category', - 'confidence' => .99 - ] - ], - 'sentences' => [ - [ - 'text' => [ - 'content' => 'hello world' - ] - ] - ], - 'tokens' => [ - [ - 'text' => [ - 'content' => 'hello world' - ], - 'partOfSpeech' => [ - 'tag' => 'NOUN' - ], - 'dependencyEdge' => [ - 'label' => 'P' - ], - 'lemma' => 'foo' - ] - ], - 'entities' => [ - [ - 'type' => 'PERSON', - 'name' => 'somebody' - ] - ], - 'language' => 'en-us', - 'documentSentiment' => [ - 'score' => 999 - ] - ]; - $this->annotation = new Annotation($this->info); - } - - public function testClass() - { - $snippet = $this->snippetFromClass(Annotation::class); - - $connection = $this->prophesize(ConnectionInterface::class); - $connection->annotateText(Argument::any()) - ->shouldBeCalled() - ->willReturn([]); - - $language = TestHelpers::stub(LanguageClient::class); - $language->___setProperty('connection', $connection->reveal()); - - $snippet->replace('$language = new LanguageClient();', ''); - $snippet->addLocal('language', $language); - - $res = $snippet->invoke('annotation'); - $this->assertInstanceOf(Annotation::class, $res->returnVal()); - } - - public function testSentences() - { - $snippet = $this->snippetFromMagicMethod(Annotation::class, 'sentences'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['sentences'][0]['text']['content'], $res->output()); - } - - public function testTokens() - { - $snippet = $this->snippetFromMagicMethod(Annotation::class, 'tokens'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['tokens'][0]['text']['content'], $res->output()); - } - - public function testEntities() - { - $snippet = $this->snippetFromMagicMethod(Annotation::class, 'entities'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['entities'][0]['type'], $res->output()); - } - - public function testCategories() - { - $snippet = $this->snippetFromMagicMethod(Annotation::class, 'categories'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['categories'][0]['name'], $res->output()); - } - - public function testLanguage() - { - $snippet = $this->snippetFromMagicMethod(Annotation::class, 'language'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['language'], $res->output()); - } - - public function testInfo() - { - $snippet = $this->snippetFromMethod(Annotation::class, 'info'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke('info'); - - $this->assertEquals($this->info, $res->returnVal()); - } - - public function testSentiment() - { - $snippet = $this->snippetFromMethod(Annotation::class, 'sentiment'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals('This is a positive message.', $res->output()); - } - - public function testTokensByTag() - { - $snippet = $this->snippetFromMethod(Annotation::class, 'tokensByTag'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['tokens'][0]['lemma'], $res->output()); - } - - public function testTokensByLabel() - { - $snippet = $this->snippetFromMethod(Annotation::class, 'tokensByLabel'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['tokens'][0]['lemma'], $res->output()); - } - - public function testEntitiesByType() - { - $snippet = $this->snippetFromMethod(Annotation::class, 'entitiesByType'); - $snippet->addLocal('annotation', $this->annotation); - $res = $snippet->invoke(); - $this->assertEquals($this->info['entities'][0]['name'], $res->output()); - } -} diff --git a/Language/tests/Snippet/LanguageClientTest.php b/Language/tests/Snippet/LanguageClientTest.php deleted file mode 100644 index bf5d56a43aa..00000000000 --- a/Language/tests/Snippet/LanguageClientTest.php +++ /dev/null @@ -1,202 +0,0 @@ -connection = $this->prophesize(ConnectionInterface::class); - $this->client = TestHelpers::stub(LanguageClient::class); - $this->client->___setProperty('connection', $this->connection->reveal()); - } - - public function testClass() - { - $snippet = $this->snippetFromClass(LanguageClient::class); - $res = $snippet->invoke('language'); - $this->assertInstanceOf(LanguageClient::class, $res->returnVal()); - } - - public function testAnalyzeEntities() - { - $this->connection->analyzeEntities(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'entities' => [ - [ - 'type' => 'PERSON' - ] - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'analyzeEntities'); - $snippet->addLocal('language', $this->client); - - $res = $snippet->invoke(); - $this->assertEquals('PERSON', $res->output()); - } - - public function testAnalyzeSentiment() - { - $this->connection->analyzeSentiment(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'documentSentiment' => [ - 'score' => 1.0 - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'analyzeSentiment'); - $snippet->addLocal('language', $this->client); - - $res = $snippet->invoke(); - $this->assertEquals("This is a positive message.", $res->output()); - } - - public function testAnalyzeEntitySentiment() - { - $this->connection->analyzeEntitySentiment(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'entities' => [ - [ - 'name' => 'Google Cloud Platform', - 'sentiment' => [ - 'score' => 1.0 - ] - ] - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'analyzeEntitySentiment'); - $snippet->addLocal('language', $this->client); - - $res = $snippet->invoke(); - $lines = explode(PHP_EOL, $res->output()); - $this->assertEquals('Entity name: Google Cloud Platform', $lines[0]); - $this->assertEquals("This is a positive message.", $lines[1]); - } - - public function testAnalyzeSyntax() - { - $this->connection->analyzeSyntax(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'sentences' => [ - [ - 'text' => [ - 'beginOffset' => '1.0' - ] - ] - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'analyzeSyntax'); - $snippet->addLocal('language', $this->client); - - $res = $snippet->invoke(); - $this->assertEquals('1.0', $res->output()); - } - - public function testClassifyText() - { - $name = 'my-category'; - $this->connection->classifyText(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'categories' => [ - [ - 'name' => $name, - 'confidence' => .99 - ] - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'classifyText'); - $snippet->addLocal('language', $this->client); - - $res = $snippet->invoke(); - $this->assertEquals($name, $res->output()); - } - - public function testAnnotateTextAllFeatures() - { - $this->connection->annotateText(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'documentSentiment' => [ - 'magnitude' => 999 - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'annotateText'); - $snippet->addLocal('language', $this->client); - - $this->assertEquals('999', $snippet->invoke()->output()); - } - - public function testAnnotateTextSomeFeatures() - { - $this->connection->annotateText(Argument::any()) - ->shouldBeCalled() - ->willReturn([ - 'tokens' => [ - [ - 'text' => [ - 'beginOffset' => '2.0' - ] - ] - ] - ]); - - $this->client->___setProperty('connection', $this->connection->reveal()); - - $snippet = $this->snippetFromMethod(LanguageClient::class, 'annotateText', 1); - $snippet->addLocal('language', $this->client); - - $this->assertEquals('2.0', $snippet->invoke()->output()); - } -} diff --git a/Language/tests/System/LanguageTestCase.php b/Language/tests/System/LanguageTestCase.php index 81b345464d9..ab7b2154a32 100644 --- a/Language/tests/System/LanguageTestCase.php +++ b/Language/tests/System/LanguageTestCase.php @@ -17,11 +17,7 @@ namespace Google\Cloud\Language\Tests\System; -use Google\Cloud\Core\ExponentialBackoff; -use Google\Cloud\BigQuery\BigQueryClient; -use Google\Cloud\Language\LanguageClient; -use Google\Cloud\PubSub\PubSubClient; -use Google\Cloud\Storage\StorageClient; +use Google\Cloud\Language\V2\LanguageClient; use PHPUnit\Framework\TestCase; class LanguageTestCase extends TestCase diff --git a/Language/tests/System/V1beta2/LanguageServiceSmokeTest.php b/Language/tests/System/V1beta2/LanguageServiceSmokeTest.php deleted file mode 100644 index ead6a20a942..00000000000 --- a/Language/tests/System/V1beta2/LanguageServiceSmokeTest.php +++ /dev/null @@ -1,51 +0,0 @@ -setContent($content); - $document->setType($type); - $encodingType = EncodingType::NONE; - $languageServiceClient->analyzeSentiment($document, ['encodingType' => $encodingType]); - } -} diff --git a/Language/tests/System/bootstrap.php b/Language/tests/System/bootstrap.php deleted file mode 100644 index ef978fd2a31..00000000000 --- a/Language/tests/System/bootstrap.php +++ /dev/null @@ -1,6 +0,0 @@ -entity = [ - 'type' => 'PERSON' - ]; - $this->token = [ - 'partOfSpeech' => [ - 'tag' => 'ADJ' - ], - 'dependencyEdge' => [ - 'label' => 'P' - ] - ]; - $this->info = [ - 'documentSentiment' => [ - 'polarity' => 1 - ], - 'entities' => [ - $this->entity, - [ - 'type' => 'EVENT' - ] - ], - 'tokens' => [ - $this->token, - [ - 'partOfSpeech' => [ - 'tag' => 'NOUN' - ], - 'dependencyEdge' => [ - 'label' => 'ABBREV' - ] - ] - ], - 'sentences' => [], - 'language' => 'en' - ]; - $this->annotation = new Annotation($this->info); - } - - public function testGetSentiment() - { - $this->assertEquals(1, $this->annotation->sentiment()['polarity']); - } - - public function testGetInfo() - { - $this->assertEquals($this->info, $this->annotation->info()); - } - - public function testFetchesTokensByTag() - { - $this->assertEquals($this->token, $this->annotation->tokensByTag('ADJ')[0]); - } - - public function testFetchesTokensByLabel() - { - $this->assertEquals($this->token, $this->annotation->tokensByLabel('P')[0]); - } - - public function testFetchesEntitiesByType() - { - $this->assertEquals($this->entity, $this->annotation->entitiesByType('PERSON')[0]); - } -} diff --git a/Language/tests/Unit/Connection/RestTest.php b/Language/tests/Unit/Connection/RestTest.php deleted file mode 100644 index bab65b1e8a4..00000000000 --- a/Language/tests/Unit/Connection/RestTest.php +++ /dev/null @@ -1,104 +0,0 @@ -requestWrapper = $this->prophesize(RequestWrapper::class); - $this->successBody = '{"canI":"kickIt"}'; - } - - public function testApiEndpoint() - { - $endpoint = 'https://foobar.com/'; - $rest = TestHelpers::stub(Rest::class, [ - [ - 'apiEndpoint' => $endpoint - ] - ], ['requestBuilder']); - - $rb = $rest->___getProperty('requestBuilder'); - $r = new \ReflectionObject($rb); - $p = $r->getProperty('baseUri'); - $p->setAccessible(true); - - $this->assertEquals($endpoint, $p->getValue($rb)); - } - - /** - * @dataProvider methodProvider - * @todo revisit this approach - */ - public function testCallBasicMethods($method) - { - $options = []; - $request = new Request('GET', '/somewhere'); - $response = new Response(200, [], $this->successBody); - - $requestBuilder = $this->prophesize(RequestBuilder::class); - $requestBuilder->build( - Argument::type('string'), - Argument::type('string'), - Argument::type('array') - )->willReturn($request); - - $this->requestWrapper->send( - Argument::type(RequestInterface::class), - Argument::type('array') - )->willReturn($response); - - $rest = new Rest(); - $rest->setRequestBuilder($requestBuilder->reveal()); - $rest->setRequestWrapper($this->requestWrapper->reveal()); - - $this->assertEquals(json_decode($this->successBody, true), $rest->$method($options)); - } - - public function methodProvider() - { - return [ - ['analyzeSentiment'], - ['analyzeEntities'], - ['analyzeEntitySentiment'], - ['analyzeSyntax'], - ['annotateText'], - ['classifyText'] - ]; - } -} diff --git a/Language/tests/Unit/LanguageClientTest.php b/Language/tests/Unit/LanguageClientTest.php deleted file mode 100644 index d69716f9d0f..00000000000 --- a/Language/tests/Unit/LanguageClientTest.php +++ /dev/null @@ -1,214 +0,0 @@ -client = TestHelpers::stub(LanguageClient::class); - $this->connection = $this->prophesize(ConnectionInterface::class); - } - - /** - * @dataProvider analyzeDataProvider - */ - public function testAnalyzeEntities($options, $expectedOptions) - { - $content = $options['content']; - unset($options['content']); - $this->connection - ->analyzeEntities($expectedOptions) - ->willReturn([]) - ->shouldBeCalledTimes(1); - $this->client->___setProperty('connection', $this->connection->reveal()); - $annotation = $this->client->analyzeEntities($content, $options); - - $this->assertInstanceOf(Annotation::class, $annotation); - } - - /** - * @dataProvider analyzeDataProvider - */ - public function testAnalyzeSentiment($options, $expectedOptions) - { - $content = $options['content']; - unset($options['content']); - $this->connection - ->analyzeSentiment($expectedOptions) - ->willReturn([]) - ->shouldBeCalledTimes(1); - $this->client->___setProperty('connection', $this->connection->reveal()); - $annotation = $this->client->analyzeSentiment($content, $options); - - $this->assertInstanceOf(Annotation::class, $annotation); - } - - /** - * @dataProvider analyzeDataProvider - */ - public function testAnalyzeEntitySentiment($options, $expectedOptions) - { - $content = $options['content']; - unset($options['content']); - $this->connection - ->analyzeEntitySentiment($expectedOptions) - ->willReturn([]) - ->shouldBeCalledTimes(1); - $this->client->___setProperty('connection', $this->connection->reveal()); - $annotation = $this->client->analyzeEntitySentiment($content, $options); - $this->assertInstanceOf(Annotation::class, $annotation); - } - - /** - * @dataProvider analyzeDataProvider - */ - public function testAnalyzeSyntax($options, $expectedOptions) - { - $content = $options['content']; - unset($options['content']); - - $this->connection - ->analyzeSyntax($expectedOptions) - ->willReturn([]) - ->shouldBeCalledTimes(1); - $this->client->___setProperty('connection', $this->connection->reveal()); - $annotation = $this->client->analyzeSyntax($content, $options); - - $this->assertInstanceOf(Annotation::class, $annotation); - } - - /** - * @dataProvider analyzeDataProvider - */ - public function testClassifyText($options, $expectedOptions) - { - $content = $options['content']; - unset($options['content']); - $categories = [ - [ - 'name' => 'category1', - 'confidence' => .99 - ] - ]; - - $this->connection - ->classifyText($expectedOptions) - ->willReturn([ - 'categories' => $categories - ]) - ->shouldBeCalledTimes(1); - $this->client->___setProperty('connection', $this->connection->reveal()); - $annotation = $this->client->classifyText($content, $options); - - $this->assertInstanceOf(Annotation::class, $annotation); - $this->assertEquals($categories, $annotation->categories()); - } - - /** - * @dataProvider analyzeDataProvider - */ - public function testAnnotateText($options, $expectedOptions) - { - $content = $options['content']; - unset($options['content']); - $options['features'] = ['syntax', 'entities', 'sentiment', 'entitySentiment']; - $expectedOptions['features'] = [ - 'extractSyntax' => true, - 'extractEntities' => true, - 'extractDocumentSentiment' => true, - 'extractEntitySentiment' => true, - ]; - $this->connection - ->annotateText($expectedOptions) - ->willReturn([]) - ->shouldBeCalledTimes(1); - $this->client->___setProperty('connection', $this->connection->reveal()); - $annotation = $this->client->annotateText($content, $options); - - $this->assertInstanceOf(Annotation::class, $annotation); - } - - public function analyzeDataProvider() - { - $objectMock = $this->prophesize(StorageObject::class); - $gcsUri = 'gs://bucket/object'; - $objectMock->gcsUri(Argument::any())->willReturn($gcsUri); - - return [ - [ - [ - 'content' => $gcsUri, - 'encodingType' => 'UTF16' - ], - [ - 'document' => [ - 'gcsContentUri' => $gcsUri, - 'type' => 'PLAIN_TEXT' - ], - 'encodingType' => 'UTF16' - ] - ], - [ - [ - 'content' => 'My content.', - 'type' => 'HTML', - 'language' => 'es', - 'encodingType' => 'UTF16' - ], - [ - 'document' => [ - 'content' => 'My content.', - 'type' => 'HTML', - 'language' => 'es', - ], - 'encodingType' => 'UTF16' - ] - ], - [ - [ - 'content' => $objectMock->reveal() - ], - [ - 'document' => [ - 'gcsContentUri' => 'gs://bucket/object', - 'type' => 'PLAIN_TEXT', - ], - 'encodingType' => 'UTF8' - ] - ] - ]; - } -} diff --git a/Language/tests/Unit/V1/LanguageServiceClientTest.php b/Language/tests/Unit/V1/LanguageServiceClientTest.php deleted file mode 100644 index cece17bc343..00000000000 --- a/Language/tests/Unit/V1/LanguageServiceClientTest.php +++ /dev/null @@ -1,489 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return LanguageServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new LanguageServiceClient($options); - } - - /** @test */ - public function analyzeEntitiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeEntitiesResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeEntities($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeEntities', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeEntitiesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeEntities($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeEntitySentimentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeEntitySentimentResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeEntitySentiment($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeEntitySentimentExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeEntitySentiment($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSentimentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeSentimentResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeSentiment($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeSentiment', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSentimentExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeSentiment($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSyntaxTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeSyntaxResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeSyntax($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeSyntax', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSyntaxExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeSyntax($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function annotateTextTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnnotateTextResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $features = new Features(); - $response = $gapicClient->annotateText($document, $features); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/AnnotateText', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $actualValue = $actualRequestObject->getFeatures(); - $this->assertProtobufEquals($features, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function annotateTextExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - $features = new Features(); - try { - $gapicClient->annotateText($document, $features); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function classifyTextTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ClassifyTextResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->classifyText($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/ClassifyText', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function classifyTextExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->classifyText($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function moderateTextTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ModerateTextResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->moderateText($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1.LanguageService/ModerateText', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function moderateTextExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->moderateText($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/Language/tests/Unit/V1beta2/LanguageServiceClientTest.php b/Language/tests/Unit/V1beta2/LanguageServiceClientTest.php deleted file mode 100644 index 51597c7b0c3..00000000000 --- a/Language/tests/Unit/V1beta2/LanguageServiceClientTest.php +++ /dev/null @@ -1,489 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return LanguageServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new LanguageServiceClient($options); - } - - /** @test */ - public function analyzeEntitiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeEntitiesResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeEntities($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/AnalyzeEntities', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeEntitiesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeEntities($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeEntitySentimentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeEntitySentimentResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeEntitySentiment($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/AnalyzeEntitySentiment', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeEntitySentimentExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeEntitySentiment($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSentimentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeSentimentResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeSentiment($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/AnalyzeSentiment', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSentimentExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeSentiment($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSyntaxTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnalyzeSyntaxResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->analyzeSyntax($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/AnalyzeSyntax', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function analyzeSyntaxExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->analyzeSyntax($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function annotateTextTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $language = 'language-1613589672'; - $expectedResponse = new AnnotateTextResponse(); - $expectedResponse->setLanguage($language); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $features = new Features(); - $response = $gapicClient->annotateText($document, $features); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/AnnotateText', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $actualValue = $actualRequestObject->getFeatures(); - $this->assertProtobufEquals($features, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function annotateTextExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - $features = new Features(); - try { - $gapicClient->annotateText($document, $features); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function classifyTextTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ClassifyTextResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->classifyText($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/ClassifyText', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function classifyTextExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->classifyText($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function moderateTextTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ModerateTextResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $document = new Document(); - $response = $gapicClient->moderateText($document); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.language.v1beta2.LanguageService/ModerateText', $actualFuncCall); - $actualValue = $actualRequestObject->getDocument(); - $this->assertProtobufEquals($document, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function moderateTextExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $document = new Document(); - try { - $gapicClient->moderateText($document); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -}