language_entities_gcs.yaml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
  2. schema_version: 1.2.0
  3. samples:
  4. - region_tag: language_entities_gcs
  5. title: Analyzing Entities (GCS)
  6. description: Analyzing Entities in text file stored in Cloud Storage
  7. service: google.cloud.language.v1.LanguageService
  8. rpc: AnalyzeEntities
  9. request:
  10. - field: document.gcs_content_uri
  11. value: gs://cloud-samples-data/language/entity.txt
  12. comment: |
  13. Google Cloud Storage URI where the file content is located.
  14. e.g. gs://[Your Bucket]/[Path to File]
  15. input_parameter: gcs_content_uri
  16. - field: document.type
  17. value: PLAIN_TEXT
  18. comment: "Available types: PLAIN_TEXT, HTML"
  19. - field: document.language
  20. value: en
  21. comment: |
  22. Optional. If not specified, the language is automatically detected.
  23. For list of supported languages:
  24. https://cloud.google.com/natural-language/docs/languages
  25. - field: encoding_type
  26. value: UTF8
  27. comment: "Available values: NONE, UTF8, UTF16, UTF32"
  28. response:
  29. - comment: ["Loop through entitites returned from the API"]
  30. - loop:
  31. collection: $resp.entities
  32. variable: entity
  33. body:
  34. - print: ["Representative name for the entity: %s", entity.name]
  35. - comment: ["Get entity type, e.g. PERSON, LOCATION, ADDRESS, NUMBER, et al"]
  36. - print: ["Entity type: %s", entity.type]
  37. - comment: ["Get the salience score associated with the entity in the [0, 1.0] range"]
  38. - print: ["Salience score: %s", entity.salience]
  39. - comment:
  40. - |
  41. Loop over the metadata associated with entity. For many known entities,
  42. the metadata is a Wikipedia URL (wikipedia_url) and Knowledge Graph MID (mid).
  43. Some entity types may have additional metadata, e.g. ADDRESS entities
  44. may have metadata for the address street_name, postal_code, et al.
  45. - loop:
  46. map: entity.metadata
  47. key: metadata_name
  48. value: metadata_value
  49. body:
  50. - print: ["%s: %s", metadata_name, metadata_value]
  51. - comment:
  52. - |
  53. Loop over the mentions of this entity in the input document.
  54. The API currently supports proper noun mentions.
  55. - loop:
  56. collection: entity.mentions
  57. variable: mention
  58. body:
  59. - print: ["Mention text: %s", mention.text.content]
  60. - comment: ["Get the mention type, e.g. PROPER for proper noun"]
  61. - print: ["Mention type: %s", mention.type]
  62. - comment:
  63. - |
  64. Get the language of the text, which will be the same as
  65. the language specified in the request or, if not specified,
  66. the automatically-detected language.
  67. - print: ["Language of the text: %s", $resp.language]