12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
- schema_version: 1.2.0
- samples:
- - region_tag: language_syntax_text
- title: Analyzing Syntax
- description: Analyzing Syntax in a String
- service: google.cloud.language.v1.LanguageService
- rpc: AnalyzeSyntax
- request:
- - field: document.content
- value: "This is a short sentence."
- 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: ["Loop through tokens returned from the API"]
- - loop:
- collection: $resp.tokens
- variable: token
- body:
- - comment: ["Get the text content of this token. Usually a word or punctuation."]
- - define: text = token.text
- - print: ["Token text: %s", text.content]
- - print: ["Location of this token in overall document: %s", text.begin_offset]
- - comment:
- - |
- Get the part of speech information for this token.
- Parts of spech are as defined in:
- http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
- - define: part_of_speech = token.part_of_speech
- - comment: ["Get the tag, e.g. NOUN, ADJ for Adjective, et al."]
- - print: ["Part of Speech tag: %s", part_of_speech.tag]
- - comment: ["Get the voice, e.g. ACTIVE or PASSIVE"]
- - print: ["Voice: %s", part_of_speech.voice]
- - comment: ["Get the tense, e.g. PAST, FUTURE, PRESENT, et al."]
- - print: ["Tense: %s", part_of_speech.tense]
- - comment: ["See API reference for additional Part of Speech information available"]
- - comment:
- - |
- Get the lemma of the token. Wikipedia lemma description
- https://en.wikipedia.org/wiki/Lemma_(morphology)
- - print: ["Lemma: %s", token.lemma]
- - comment:
- - |
- Get the dependency tree parse information for this token.
- For more information on dependency labels:
- http://www.aclweb.org/anthology/P13-2017
- - define: dependency_edge = token.dependency_edge
- - print: ["Head token index: %s", dependency_edge.head_token_index]
- - print: ["Label: %s", dependency_edge.label]
- - 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]
|