type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
schema_version: 1.2.0
samples:
- region_tag: language_sentiment_text
  title: Analyzing Sentiment
  description: Analyzing Sentiment in a String
  service: google.cloud.language.v1.LanguageService
  rpc: AnalyzeSentiment
  request:
  - field: document.content
    value: "I am so happy and joyful."
    comment: The text content to analyze
    input_parameter: text_content
  - field: document.type
    value: PLAIN_TEXT
    comment: "Available types: PLAIN_TEXT, HTML"
  - field: document.language
    value: en
    comment: |
      Optional. If not specified, the language is automatically detected.
      For list of supported languages:
        https://cloud.google.com/natural-language/docs/languages
  - field: encoding_type
    value: UTF8
    comment: "Available values: NONE, UTF8, UTF16, UTF32"
  response:
  - comment: ["Get overall sentiment of the input document"]
  - print: ["Document sentiment score: %s", $resp.document_sentiment.score]
  - print: ["Document sentiment magnitude: %s", $resp.document_sentiment.magnitude]
  - comment: ["Get sentiment for all sentences in the document"]
  - loop:
      collection: $resp.sentences
      variable: sentence
      body:
      - print: ["Sentence text: %s", sentence.text.content]
      - print: ["Sentence sentiment score: %s", sentence.sentiment.score]
      - print: ["Sentence sentiment magnitude: %s", sentence.sentiment.magnitude]
  - comment:
    - |
        Get 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.
  - print: ["Language of the text: %s", $resp.language]
