language_classify_text.yaml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
  2. schema_version: 1.2.0
  3. samples:
  4. - region_tag: language_classify_text
  5. title: Classify Content
  6. description: Classifying Content in a String
  7. service: google.cloud.language.v1.LanguageService
  8. rpc: ClassifyText
  9. request:
  10. - field: document.content
  11. value: "That actor on TV makes movies in Hollywood and also stars in a variety of popular new TV shows."
  12. comment: The text content to analyze. Must include at least 20 words.
  13. input_parameter: text_content
  14. - field: document.type
  15. value: PLAIN_TEXT
  16. comment: "Available types: PLAIN_TEXT, HTML"
  17. - field: document.language
  18. value: en
  19. comment: |
  20. Optional. If not specified, the language is automatically detected.
  21. For list of supported languages:
  22. https://cloud.google.com/natural-language/docs/languages
  23. response:
  24. - comment: ["Loop through classified categories returned from the API"]
  25. - loop:
  26. collection: $resp.categories
  27. variable: category
  28. body:
  29. - comment:
  30. - |
  31. Get the name of the category representing the document.
  32. See the predefined taxonomy of categories:
  33. https://cloud.google.com/natural-language/docs/categories
  34. - print: ["Category name: %s", category.name]
  35. - comment:
  36. - |
  37. Get the confidence. Number representing how certain the classifier
  38. is that this category represents the provided text.
  39. - print: ["Confidence: %s", category.confidence]