Synchronize new proto/yaml changes.
PiperOrigin-RevId: 245313728
diff --git a/google/cloud/language/v1/language.tests.yaml b/google/cloud/language/v1/language.tests.yaml
new file mode 100644
index 0000000..d133b04
--- /dev/null
+++ b/google/cloud/language/v1/language.tests.yaml
@@ -0,0 +1,123 @@
+test:
+ suites:
+ - name: Natural Language V1
+ cases:
+
+ - name: Analyze Syntax
+ spec:
+ - call: {sample: language_syntax_text}
+ - assert_contains:
+ - literal: "Text: This"
+ - literal: "Text: is"
+ - literal: "Text: short"
+ - literal: "Text: sentence"
+ - literal: "Text: ."
+
+ - name: Analyze Syntax – GCS
+ spec:
+ - call:
+ sample: language_syntax_gcs
+ - assert_contains:
+ - literal: "Text: This"
+ - literal: "Text: is"
+ - literal: "Text: short"
+ - literal: "Text: sentence"
+ - literal: "Text: ."
+
+ - name: Analyze Sentiment
+ spec:
+ - call: {sample: language_sentiment_text}
+ - assert_contains:
+ # Default message should return positive: 'I am so happy and joyful'
+ - literal: "Sentiment score: 0."
+ - literal: "Magnitude: 0."
+
+ - name: Analyze Sentiment – Negative
+ spec:
+ - call:
+ sample: language_sentiment_text
+ params:
+ text_content:
+ literal: "I am so sad and upset."
+ - assert_contains:
+ - literal: "Sentiment score: -0."
+ - literal: "Magnitude: 0."
+
+ - name: Analyze Sentiment – GCS
+ spec:
+ - call: {sample: language_sentiment_gcs}
+ - assert_contains:
+ # Default message should return positive: 'I am so happy and joyful'
+ - literal: "Sentiment score: 0."
+ - literal: "Magnitude: 0."
+
+ - name: Analyze Sentiment – GCS – Negative
+ spec:
+ - call:
+ sample: language_sentiment_gcs
+ params:
+ gcs_uri:
+ literal: "gs://cloud-samples-data/language/sentiment-negative.txt"
+ - assert_contains:
+ - literal: "Sentiment score: -0."
+ - literal: "Magnitude: 0."
+
+ - name: Analyze Entities
+ spec:
+ - call: {sample: language_entities_text}
+ - assert_contains:
+ - literal: "Entity name: California"
+ - literal: "Entity salience score: 1"
+ - literal: "Mention: California"
+ - literal: "Mention: state"
+
+ - name: Analyze Entities – GCS
+ spec:
+ - call: {sample: language_entities_gcs}
+ - assert_contains:
+ - literal: "Entity name: California"
+ - literal: "Entity salience score: 1"
+ - literal: "Mention: California"
+ - literal: "Mention: state"
+
+ - name: Analyze Entity Sentiment
+ spec:
+ - call: {sample: language_entity_sentiment_text}
+ - assert_contains:
+ - literal: "Entity name: Grapes"
+ - literal: "Entity sentiment score: 0."
+ - literal: "Mention: Grapes"
+ - literal: "Mention sentiment score: 0."
+ - literal: "Mention sentiment magnitude: 0."
+ - literal: "Entity name: Bananas"
+ - literal: "Entity sentiment score: -0."
+ - literal: "Mention: Bananas"
+ - literal: "Mention sentiment score: -0."
+
+ - name: Analyze Entity Sentiment – GCS
+ spec:
+ - call: {sample: language_entity_sentiment_gcs}
+ - assert_contains:
+ - literal: "Entity name: Grapes"
+ - literal: "Entity sentiment score: 0."
+ - literal: "Mention: Grapes"
+ - literal: "Mention sentiment score: 0."
+ - literal: "Mention sentiment magnitude: 0."
+ - literal: "Entity name: Bananas"
+ - literal: "Entity sentiment score: -0."
+ - literal: "Mention: Bananas"
+ - literal: "Mention sentiment score: -0."
+
+ - name: Classify Text
+ spec:
+ - call: {sample: language_classify_text}
+ - assert_contains:
+ - literal: "Category name: /Arts & Entertainment"
+ - literal: "Confidence: 0."
+
+ - name: Classify Text – GCS
+ spec:
+ - call: {sample: language_classify_gcs}
+ - assert_contains:
+ - literal: "Category name: /Arts & Entertainment"
+ - literal: "Confidence: 0."
diff --git a/google/cloud/language/v1/language_gapic.yaml b/google/cloud/language/v1/language_gapic.yaml
index 2b05e8b..a3796fc 100644
--- a/google/cloud/language/v1/language_gapic.yaml
+++ b/google/cloud/language/v1/language_gapic.yaml
@@ -118,6 +118,47 @@
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
+ samples:
+ standalone:
+ - value_sets: [language_sentiment_text]
+ region_tag: language_sentiment_text
+ - value_sets: [language_sentiment_gcs]
+ region_tag: language_sentiment_gcs
+ - region_tag: analyze_text_sentiment
+ value_sets: [analyze_text_sentiment]
+ sample_value_sets:
+ - id: analyze_text_sentiment
+ description: This sample demonstrates analyzing the sentiment of text
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.content="I am so happy"
+ - id: language_sentiment_text
+ description: "Analyze sentiment of text"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.content="I am so happy and joyful."
+ attributes:
+ - parameter: document.content
+ sample_argument_name: text_content
+ on_success:
+ - define: sentiment=$resp.document_sentiment
+ - print: ["Sentiment score: %s", sentiment.score]
+ - print: ["Magnitude: %s", sentiment.magnitude]
+ - id: language_sentiment_gcs
+ description: "Analyze sentiment of text stored in GCS"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.gcs_content_uri="gs://cloud-samples-data/language/sentiment-positive.txt"
+ attributes:
+ - parameter: document.gcs_content_uri
+ sample_argument_name: gcs_uri
+ on_success:
+ - define: sentiment=$resp.document_sentiment
+ - print: ["Sentiment score: %s", sentiment.score]
+ - print: ["Magnitude: %s", sentiment.magnitude]
- name: AnalyzeEntities
flattening:
groups:
@@ -131,6 +172,59 @@
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
+ samples:
+ standalone:
+ - value_sets: [language_entities_text]
+ region_tag: language_entities_text
+ - value_sets: [language_entities_gcs]
+ region_tag: language_entities_gcs
+ sample_value_sets:
+ - id: language_entities_text
+ description: "Analyze entities in text"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.content="California is a state."
+ attributes:
+ - parameter: document.content
+ sample_argument_name: text_content
+ on_success:
+ - loop:
+ collection: $resp.entities
+ variable: entity
+ body:
+ - print: ["Entity name: %s", entity.name]
+ - print: ["Entity type: %s", entity.type]
+ - print: ["Entity salience score: %s", entity.salience]
+ - loop:
+ collection: entity.mentions
+ variable: mention
+ body:
+ - print: ["Mention: %s", mention.text.content]
+ - print: ["Mention type: %s", mention.type]
+ - id: language_entities_gcs
+ description: "Analyze entities in text stored in GCS"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.gcs_content_uri="gs://cloud-samples-data/language/entity.txt"
+ attributes:
+ - parameter: document.gcs_content_uri
+ sample_argument_name: gcs_ur
+ on_success:
+ - loop:
+ collection: $resp.entities
+ variable: entity
+ body:
+ - print: ["Entity name: %s", entity.name]
+ - print: ["Entity type: %s", entity.type]
+ - print: ["Entity salience score: %s", entity.salience]
+ - loop:
+ collection: entity.mentions
+ variable: mention
+ body:
+ - print: ["Mention: %s", mention.text.content]
+ - print: ["Mention type: %s", mention.type]
- name: AnalyzeEntitySentiment
flattening:
groups:
@@ -144,6 +238,65 @@
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
+ samples:
+ standalone:
+ - value_sets: [language_entity_sentiment_text]
+ region_tag: language_entity_sentiment_text
+ - value_sets: [language_entity_sentiment_gcs]
+ region_tag: language_entity_sentiment_gcs
+ sample_value_sets:
+ - id: language_entity_sentiment_text
+ description: "Analyze Sentiment of Entities in Text"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.content="Grapes are good. Bananas are bad."
+ attributes:
+ - parameter: document.content
+ sample_argument_name: text_content
+ on_success:
+ - loop:
+ collection: $resp.entities
+ variable: entity
+ body:
+ - print: ["Entity name: %s", entity.name]
+ - print: ["Entity sentiment score: %s", entity.sentiment.score]
+ - loop:
+ collection: entity.mentions
+ variable: mention
+ body:
+ - print: ["Mention: %s", mention.text.content]
+ - print: ["Mention type: %s", mention.type]
+ - print: ["Mention sentiment score: %s", mention.sentiment.score]
+ - print:
+ - "Mention sentiment magnitude: %s"
+ - mention.sentiment.magnitude
+ - id: language_entity_sentiment_gcs
+ description: "Analyze Sentiment of Entities in Text stored in GCS"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.gcs_content_uri="gs://cloud-samples-data/language/entity-sentiment.txt"
+ attributes:
+ - parameter: document.gcs_content_uri
+ sample_argument_name: gcs_ur
+ on_success:
+ - loop:
+ collection: $resp.entities
+ variable: entity
+ body:
+ - print: ["Entity name: %s", entity.name]
+ - print: ["Entity sentiment score: %s", entity.sentiment.score]
+ - loop:
+ collection: entity.mentions
+ variable: mention
+ body:
+ - print: ["Mention: %s", mention.text.content]
+ - print: ["Mention type: %s", mention.type]
+ - print: ["Mention sentiment score: %s", mention.sentiment.score]
+ - print:
+ - "Mention sentiment magnitude: %s"
+ - mention.sentiment.magnitude
- name: AnalyzeSyntax
flattening:
groups:
@@ -157,6 +310,47 @@
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
+ samples:
+ standalone:
+ - value_sets: [language_syntax_text]
+ region_tag: language_syntax_text
+ - value_sets: [language_syntax_gcs]
+ region_tag: language_syntax_gcs
+ sample_value_sets:
+ - id: language_syntax_text
+ description: "Analyze syntax of text"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.content="This is a short sentence."
+ attributes:
+ - parameter: document.content
+ sample_argument_name: text_content
+ on_success:
+ - define: tokens=$resp.tokens
+ - loop:
+ variable: token
+ collection: tokens
+ body:
+ - print: ["Part of speech: %s", token.part_of_speech.tag]
+ - print: ["Text: %s", token.text.content]
+ - id: language_syntax_gcs
+ description: "Analyze syntax of text in GCS"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.gcs_content_uri="gs://cloud-samples-data/language/syntax-sentence.txt"
+ attributes:
+ - parameter: document.gcs_content_uri
+ sample_argument_name: gcs_urs
+ on_success:
+ - define: tokens=$resp.tokens
+ - loop:
+ variable: token
+ collection: tokens
+ body:
+ - print: ["Part of speech: %s", token.part_of_speech.tag]
+ - print: ["Text: %s", token.text.content]
- name: ClassifyText
flattening:
groups:
@@ -167,6 +361,45 @@
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
+ samples:
+ standalone:
+ - value_sets: [language_classify_text]
+ region_tag: language_classify_text
+ - value_sets: [language_classify_gcs]
+ region_tag: language_classify_gcs
+ sample_value_sets:
+ - id: language_classify_text
+ description: "Classify text"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.content="This is about film and movies and television and acting and movie theatres and theatre and drama and entertainment and the arts."
+ attributes:
+ - parameter: document.content
+ sample_argument_name: text_content
+ on_success:
+ - loop:
+ collection: $resp.categories
+ variable: category
+ body:
+ - print: ["Category name: %s", category.name]
+ - print: ["Confidence: %s", category.confidence]
+ - id: language_classify_gcs
+ description: "Classify text in GCS"
+ parameters:
+ defaults:
+ - document.type=PLAIN_TEXT
+ - document.gcs_content_uri="gs://cloud-samples-data/language/classify-entertainment.txt"
+ attributes:
+ - parameter: document.gcs_content_uri
+ sample_argument_name: gcs_urs
+ on_success:
+ - loop:
+ collection: $resp.categories
+ variable: category
+ body:
+ - print: ["Category name: %s", category.name]
+ - print: ["Confidence: %s", category.confidence]
- name: AnnotateText
flattening:
groups: