language_classify_gcs.yaml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
  2. schema_version: 1.2.0
  3. samples:
  4. - region_tag: language_classify_gcs
  5. title: Classify Content (GCS)
  6. description: Classifying Content in text file stored in Cloud Storage
  7. service: google.cloud.language.v1.LanguageService
  8. rpc: ClassifyText
  9. request:
  10. - field: document.gcs_content_uri
  11. value: gs://cloud-samples-data/language/classify-entertainment.txt
  12. comment: |
  13. Google Cloud Storage URI where the file content is located.
  14. e.g. gs://[Your Bucket]/[Path to File]
  15. The text file must include at least 20 words.
  16. input_parameter: gcs_content_uri
  17. - field: document.type
  18. value: PLAIN_TEXT
  19. comment: "Available types: PLAIN_TEXT, HTML"
  20. - field: document.language
  21. value: en
  22. comment: |
  23. Optional. If not specified, the language is automatically detected.
  24. For list of supported languages:
  25. https://cloud.google.com/natural-language/docs/languages
  26. response:
  27. - comment: ["Loop through classified categories returned from the API"]
  28. - loop:
  29. collection: $resp.categories
  30. variable: category
  31. body:
  32. - comment:
  33. - |
  34. Get the name of the category representing the document.
  35. See the predefined taxonomy of categories:
  36. https://cloud.google.com/natural-language/docs/categories
  37. - print: ["Category name: %s", category.name]
  38. - comment:
  39. - |
  40. Get the confidence. Number representing how certain the classifier
  41. is that this category represents the provided text.
  42. - print: ["Confidence: %s", category.confidence]