type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
schema_version: 1.2.0
samples:
- region_tag: language_classify_text
title: Classify Content
description: Classifying Content in a String
service: google.cloud.language.v1.LanguageService
rpc: ClassifyText
request:
- field: document.content
value: "That actor on TV makes movies in Hollywood and also stars in a variety of popular new TV shows."
comment: The text content to analyze. Must include at least 20 words.
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
response:
- comment: ["Loop through classified categories returned from the API"]
- loop:
collection: $resp.categories
variable: category
body:
- comment:
- |
Get the name of the category representing the document.
See the predefined taxonomy of categories:
https://cloud.google.com/natural-language/docs/categories
- print: ["Category name: %s", category.name]
- comment:
- |
Get the confidence. Number representing how certain the classifier
is that this category represents the provided text.
- print: ["Confidence: %s", category.confidence]