We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Language: typo ("spech") in Natural Language samples
#### Environment details

N/A

#### Steps to reproduce

N/A

#### Code example

Comments say "Parts of spech" instead of "Parts of speech"
https://github.com/googleapis/google-cloud-python/blob/master/language/samples/v1/language_syntax_gcs.py#L67
https://github.com/googleapis/google-cloud-python/blob/master/language/samples/v1/language_syntax_text.py#L66



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `language/samples/v1/language_syntax_gcs.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright 2019 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     https://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 # DO NOT EDIT! This is a generated sample ("Request",  "language_syntax_gcs")
18 
19 # To install the latest published package dependency, execute the following:
20 #   pip install google-cloud-language
21 
22 # sample-metadata
23 #   title: Analyzing Syntax (GCS)
24 #   description: Analyzing Syntax in text file stored in Cloud Storage
25 #   usage: python3 samples/v1/language_syntax_gcs.py [--gcs_content_uri "gs://cloud-samples-data/language/syntax-sentence.txt"]
26 
27 # [START language_syntax_gcs]
28 from google.cloud import language_v1
29 from google.cloud.language_v1 import enums
30 
31 
32 def sample_analyze_syntax(gcs_content_uri):
33     """
34     Analyzing Syntax in text file stored in Cloud Storage
35 
36     Args:
37       gcs_content_uri Google Cloud Storage URI where the file content is located.
38       e.g. gs://[Your Bucket]/[Path to File]
39     """
40 
41     client = language_v1.LanguageServiceClient()
42 
43     # gcs_content_uri = 'gs://cloud-samples-data/language/syntax-sentence.txt'
44 
45     # Available types: PLAIN_TEXT, HTML
46     type_ = enums.Document.Type.PLAIN_TEXT
47 
48     # Optional. If not specified, the language is automatically detected.
49     # For list of supported languages:
50     # https://cloud.google.com/natural-language/docs/languages
51     language = "en"
52     document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
53 
54     # Available values: NONE, UTF8, UTF16, UTF32
55     encoding_type = enums.EncodingType.UTF8
56 
57     response = client.analyze_syntax(document, encoding_type=encoding_type)
58     # Loop through tokens returned from the API
59     for token in response.tokens:
60         # Get the text content of this token. Usually a word or punctuation.
61         text = token.text
62         print(u"Token text: {}".format(text.content))
63         print(
64             u"Location of this token in overall document: {}".format(text.begin_offset)
65         )
66         # Get the part of speech information for this token.
67         # Parts of spech are as defined in:
68         # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
69         part_of_speech = token.part_of_speech
70         # Get the tag, e.g. NOUN, ADJ for Adjective, et al.
71         print(
72             u"Part of Speech tag: {}".format(
73                 enums.PartOfSpeech.Tag(part_of_speech.tag).name
74             )
75         )
76         # Get the voice, e.g. ACTIVE or PASSIVE
77         print(u"Voice: {}".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))
78         # Get the tense, e.g. PAST, FUTURE, PRESENT, et al.
79         print(u"Tense: {}".format(enums.PartOfSpeech.Tense(part_of_speech.tense).name))
80         # See API reference for additional Part of Speech information available
81         # Get the lemma of the token. Wikipedia lemma description
82         # https://en.wikipedia.org/wiki/Lemma_(morphology)
83         print(u"Lemma: {}".format(token.lemma))
84         # Get the dependency tree parse information for this token.
85         # For more information on dependency labels:
86         # http://www.aclweb.org/anthology/P13-2017
87         dependency_edge = token.dependency_edge
88         print(u"Head token index: {}".format(dependency_edge.head_token_index))
89         print(
90             u"Label: {}".format(enums.DependencyEdge.Label(dependency_edge.label).name)
91         )
92 
93     # Get the language of the text, which will be the same as
94     # the language specified in the request or, if not specified,
95     # the automatically-detected language.
96     print(u"Language of the text: {}".format(response.language))
97 
98 
99 # [END language_syntax_gcs]
100 
101 
102 def main():
103     import argparse
104 
105     parser = argparse.ArgumentParser()
106     parser.add_argument(
107         "--gcs_content_uri",
108         type=str,
109         default="gs://cloud-samples-data/language/syntax-sentence.txt",
110     )
111     args = parser.parse_args()
112 
113     sample_analyze_syntax(args.gcs_content_uri)
114 
115 
116 if __name__ == "__main__":
117     main()
118
```

Path: `language/samples/v1/language_syntax_text.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright 2019 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     https://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 # DO NOT EDIT! This is a generated sample ("Request",  "language_syntax_text")
18 
19 # To install the latest published package dependency, execute the following:
20 #   pip install google-cloud-language
21 
22 # sample-metadata
23 #   title: Analyzing Syntax
24 #   description: Analyzing Syntax in a String
25 #   usage: python3 samples/v1/language_syntax_text.py [--text_content "This is a short sentence."]
26 
27 # [START language_syntax_text]
28 from google.cloud import language_v1
29 from google.cloud.language_v1 import enums
30 
31 
32 def sample_analyze_syntax(text_content):
33     """
34     Analyzing Syntax in a String
35 
36     Args:
37       text_content The text content to analyze
38     """
39 
40     client = language_v1.LanguageServiceClient()
41 
42     # text_content = 'This is a short sentence.'
43 
44     # Available types: PLAIN_TEXT, HTML
45     type_ = enums.Document.Type.PLAIN_TEXT
46 
47     # Optional. If not specified, the language is automatically detected.
48     # For list of supported languages:
49     # https://cloud.google.com/natural-language/docs/languages
50     language = "en"
51     document = {"content": text_content, "type": type_, "language": language}
52 
53     # Available values: NONE, UTF8, UTF16, UTF32
54     encoding_type = enums.EncodingType.UTF8
55 
56     response = client.analyze_syntax(document, encoding_type=encoding_type)
57     # Loop through tokens returned from the API
58     for token in response.tokens:
59         # Get the text content of this token. Usually a word or punctuation.
60         text = token.text
61         print(u"Token text: {}".format(text.content))
62         print(
63             u"Location of this token in overall document: {}".format(text.begin_offset)
64         )
65         # Get the part of speech information for this token.
66         # Parts of spech are as defined in:
67         # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
68         part_of_speech = token.part_of_speech
69         # Get the tag, e.g. NOUN, ADJ for Adjective, et al.
70         print(
71             u"Part of Speech tag: {}".format(
72                 enums.PartOfSpeech.Tag(part_of_speech.tag).name
73             )
74         )
75         # Get the voice, e.g. ACTIVE or PASSIVE
76         print(u"Voice: {}".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))
77         # Get the tense, e.g. PAST, FUTURE, PRESENT, et al.
78         print(u"Tense: {}".format(enums.PartOfSpeech.Tense(part_of_speech.tense).name))
79         # See API reference for additional Part of Speech information available
80         # Get the lemma of the token. Wikipedia lemma description
81         # https://en.wikipedia.org/wiki/Lemma_(morphology)
82         print(u"Lemma: {}".format(token.lemma))
83         # Get the dependency tree parse information for this token.
84         # For more information on dependency labels:
85         # http://www.aclweb.org/anthology/P13-2017
86         dependency_edge = token.dependency_edge
87         print(u"Head token index: {}".format(dependency_edge.head_token_index))
88         print(
89             u"Label: {}".format(enums.DependencyEdge.Label(dependency_edge.label).name)
90         )
91 
92     # Get the language of the text, which will be the same as
93     # the language specified in the request or, if not specified,
94     # the automatically-detected language.
95     print(u"Language of the text: {}".format(response.language))
96 
97 
98 # [END language_syntax_text]
99 
100 
101 def main():
102     import argparse
103 
104     parser = argparse.ArgumentParser()
105     parser.add_argument("--text_content", type=str, default="This is a short sentence.")
106     args = parser.parse_args()
107 
108     sample_analyze_syntax(args.text_content)
109 
110 
111 if __name__ == "__main__":
112     main()
113
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/language/samples/v1/language_syntax_gcs.py b/language/samples/v1/language_syntax_gcs.py
--- a/language/samples/v1/language_syntax_gcs.py
+++ b/language/samples/v1/language_syntax_gcs.py
@@ -64,7 +64,7 @@
             u"Location of this token in overall document: {}".format(text.begin_offset)
         )
         # Get the part of speech information for this token.
-        # Parts of spech are as defined in:
+        # Parts of speech are as defined in:
         # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
         part_of_speech = token.part_of_speech
         # Get the tag, e.g. NOUN, ADJ for Adjective, et al.
diff --git a/language/samples/v1/language_syntax_text.py b/language/samples/v1/language_syntax_text.py
--- a/language/samples/v1/language_syntax_text.py
+++ b/language/samples/v1/language_syntax_text.py
@@ -63,7 +63,7 @@
             u"Location of this token in overall document: {}".format(text.begin_offset)
         )
         # Get the part of speech information for this token.
-        # Parts of spech are as defined in:
+        # Parts of speech are as defined in:
         # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
         part_of_speech = token.part_of_speech
         # Get the tag, e.g. NOUN, ADJ for Adjective, et al.

{"golden_diff": "diff --git a/language/samples/v1/language_syntax_gcs.py b/language/samples/v1/language_syntax_gcs.py\n--- a/language/samples/v1/language_syntax_gcs.py\n+++ b/language/samples/v1/language_syntax_gcs.py\n@@ -64,7 +64,7 @@\n             u\"Location of this token in overall document: {}\".format(text.begin_offset)\n         )\n         # Get the part of speech information for this token.\n-        # Parts of spech are as defined in:\n+        # Parts of speech are as defined in:\n         # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf\n         part_of_speech = token.part_of_speech\n         # Get the tag, e.g. NOUN, ADJ for Adjective, et al.\ndiff --git a/language/samples/v1/language_syntax_text.py b/language/samples/v1/language_syntax_text.py\n--- a/language/samples/v1/language_syntax_text.py\n+++ b/language/samples/v1/language_syntax_text.py\n@@ -63,7 +63,7 @@\n             u\"Location of this token in overall document: {}\".format(text.begin_offset)\n         )\n         # Get the part of speech information for this token.\n-        # Parts of spech are as defined in:\n+        # Parts of speech are as defined in:\n         # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf\n         part_of_speech = token.part_of_speech\n         # Get the tag, e.g. NOUN, ADJ for Adjective, et al.\n", "issue": "Language: typo (\"spech\") in Natural Language samples\n#### Environment details\r\n\r\nN/A\r\n\r\n#### Steps to reproduce\r\n\r\nN/A\r\n\r\n#### Code example\r\n\r\nComments say \"Parts of spech\" instead of \"Parts of speech\"\r\nhttps://github.com/googleapis/google-cloud-python/blob/master/language/samples/v1/language_syntax_gcs.py#L67\r\nhttps://github.com/googleapis/google-cloud-python/blob/master/language/samples/v1/language_syntax_text.py#L66\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# DO NOT EDIT! This is a generated sample (\"Request\",  \"language_syntax_gcs\")\n\n# To install the latest published package dependency, execute the following:\n#   pip install google-cloud-language\n\n# sample-metadata\n#   title: Analyzing Syntax (GCS)\n#   description: Analyzing Syntax in text file stored in Cloud Storage\n#   usage: python3 samples/v1/language_syntax_gcs.py [--gcs_content_uri \"gs://cloud-samples-data/language/syntax-sentence.txt\"]\n\n# [START language_syntax_gcs]\nfrom google.cloud import language_v1\nfrom google.cloud.language_v1 import enums\n\n\ndef sample_analyze_syntax(gcs_content_uri):\n    \"\"\"\n    Analyzing Syntax in text file stored in Cloud Storage\n\n    Args:\n      gcs_content_uri Google Cloud Storage URI where the file content is located.\n      e.g. gs://[Your Bucket]/[Path to File]\n    \"\"\"\n\n    client = language_v1.LanguageServiceClient()\n\n    # gcs_content_uri = 'gs://cloud-samples-data/language/syntax-sentence.txt'\n\n    # Available types: PLAIN_TEXT, HTML\n    type_ = enums.Document.Type.PLAIN_TEXT\n\n    # Optional. If not specified, the language is automatically detected.\n    # For list of supported languages:\n    # https://cloud.google.com/natural-language/docs/languages\n    language = \"en\"\n    document = {\"gcs_content_uri\": gcs_content_uri, \"type\": type_, \"language\": language}\n\n    # Available values: NONE, UTF8, UTF16, UTF32\n    encoding_type = enums.EncodingType.UTF8\n\n    response = client.analyze_syntax(document, encoding_type=encoding_type)\n    # Loop through tokens returned from the API\n    for token in response.tokens:\n        # Get the text content of this token. Usually a word or punctuation.\n        text = token.text\n        print(u\"Token text: {}\".format(text.content))\n        print(\n            u\"Location of this token in overall document: {}\".format(text.begin_offset)\n        )\n        # Get the part of speech information for this token.\n        # Parts of spech are as defined in:\n        # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf\n        part_of_speech = token.part_of_speech\n        # Get the tag, e.g. NOUN, ADJ for Adjective, et al.\n        print(\n            u\"Part of Speech tag: {}\".format(\n                enums.PartOfSpeech.Tag(part_of_speech.tag).name\n            )\n        )\n        # Get the voice, e.g. ACTIVE or PASSIVE\n        print(u\"Voice: {}\".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))\n        # Get the tense, e.g. PAST, FUTURE, PRESENT, et al.\n        print(u\"Tense: {}\".format(enums.PartOfSpeech.Tense(part_of_speech.tense).name))\n        # See API reference for additional Part of Speech information available\n        # Get the lemma of the token. Wikipedia lemma description\n        # https://en.wikipedia.org/wiki/Lemma_(morphology)\n        print(u\"Lemma: {}\".format(token.lemma))\n        # Get the dependency tree parse information for this token.\n        # For more information on dependency labels:\n        # http://www.aclweb.org/anthology/P13-2017\n        dependency_edge = token.dependency_edge\n        print(u\"Head token index: {}\".format(dependency_edge.head_token_index))\n        print(\n            u\"Label: {}\".format(enums.DependencyEdge.Label(dependency_edge.label).name)\n        )\n\n    # Get the language of the text, which will be the same as\n    # the language specified in the request or, if not specified,\n    # the automatically-detected language.\n    print(u\"Language of the text: {}\".format(response.language))\n\n\n# [END language_syntax_gcs]\n\n\ndef main():\n    import argparse\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"--gcs_content_uri\",\n        type=str,\n        default=\"gs://cloud-samples-data/language/syntax-sentence.txt\",\n    )\n    args = parser.parse_args()\n\n    sample_analyze_syntax(args.gcs_content_uri)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "language/samples/v1/language_syntax_gcs.py"}, {"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# DO NOT EDIT! This is a generated sample (\"Request\",  \"language_syntax_text\")\n\n# To install the latest published package dependency, execute the following:\n#   pip install google-cloud-language\n\n# sample-metadata\n#   title: Analyzing Syntax\n#   description: Analyzing Syntax in a String\n#   usage: python3 samples/v1/language_syntax_text.py [--text_content \"This is a short sentence.\"]\n\n# [START language_syntax_text]\nfrom google.cloud import language_v1\nfrom google.cloud.language_v1 import enums\n\n\ndef sample_analyze_syntax(text_content):\n    \"\"\"\n    Analyzing Syntax in a String\n\n    Args:\n      text_content The text content to analyze\n    \"\"\"\n\n    client = language_v1.LanguageServiceClient()\n\n    # text_content = 'This is a short sentence.'\n\n    # Available types: PLAIN_TEXT, HTML\n    type_ = enums.Document.Type.PLAIN_TEXT\n\n    # Optional. If not specified, the language is automatically detected.\n    # For list of supported languages:\n    # https://cloud.google.com/natural-language/docs/languages\n    language = \"en\"\n    document = {\"content\": text_content, \"type\": type_, \"language\": language}\n\n    # Available values: NONE, UTF8, UTF16, UTF32\n    encoding_type = enums.EncodingType.UTF8\n\n    response = client.analyze_syntax(document, encoding_type=encoding_type)\n    # Loop through tokens returned from the API\n    for token in response.tokens:\n        # Get the text content of this token. Usually a word or punctuation.\n        text = token.text\n        print(u\"Token text: {}\".format(text.content))\n        print(\n            u\"Location of this token in overall document: {}\".format(text.begin_offset)\n        )\n        # Get the part of speech information for this token.\n        # Parts of spech are as defined in:\n        # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf\n        part_of_speech = token.part_of_speech\n        # Get the tag, e.g. NOUN, ADJ for Adjective, et al.\n        print(\n            u\"Part of Speech tag: {}\".format(\n                enums.PartOfSpeech.Tag(part_of_speech.tag).name\n            )\n        )\n        # Get the voice, e.g. ACTIVE or PASSIVE\n        print(u\"Voice: {}\".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))\n        # Get the tense, e.g. PAST, FUTURE, PRESENT, et al.\n        print(u\"Tense: {}\".format(enums.PartOfSpeech.Tense(part_of_speech.tense).name))\n        # See API reference for additional Part of Speech information available\n        # Get the lemma of the token. Wikipedia lemma description\n        # https://en.wikipedia.org/wiki/Lemma_(morphology)\n        print(u\"Lemma: {}\".format(token.lemma))\n        # Get the dependency tree parse information for this token.\n        # For more information on dependency labels:\n        # http://www.aclweb.org/anthology/P13-2017\n        dependency_edge = token.dependency_edge\n        print(u\"Head token index: {}\".format(dependency_edge.head_token_index))\n        print(\n            u\"Label: {}\".format(enums.DependencyEdge.Label(dependency_edge.label).name)\n        )\n\n    # Get the language of the text, which will be the same as\n    # the language specified in the request or, if not specified,\n    # the automatically-detected language.\n    print(u\"Language of the text: {}\".format(response.language))\n\n\n# [END language_syntax_text]\n\n\ndef main():\n    import argparse\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--text_content\", type=str, default=\"This is a short sentence.\")\n    args = parser.parse_args()\n\n    sample_analyze_syntax(args.text_content)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "language/samples/v1/language_syntax_text.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# DO NOT EDIT! This is a generated sample (\"Request\",  \"language_syntax_gcs\")\n\n# To install the latest published package dependency, execute the following:\n#   pip install google-cloud-language\n\n# sample-metadata\n#   title: Analyzing Syntax (GCS)\n#   description: Analyzing Syntax in text file stored in Cloud Storage\n#   usage: python3 samples/v1/language_syntax_gcs.py [--gcs_content_uri \"gs://cloud-samples-data/language/syntax-sentence.txt\"]\n\n# [START language_syntax_gcs]\nfrom google.cloud import language_v1\nfrom google.cloud.language_v1 import enums\n\n\ndef sample_analyze_syntax(gcs_content_uri):\n    \"\"\"\n    Analyzing Syntax in text file stored in Cloud Storage\n\n    Args:\n      gcs_content_uri Google Cloud Storage URI where the file content is located.\n      e.g. gs://[Your Bucket]/[Path to File]\n    \"\"\"\n\n    client = language_v1.LanguageServiceClient()\n\n    # gcs_content_uri = 'gs://cloud-samples-data/language/syntax-sentence.txt'\n\n    # Available types: PLAIN_TEXT, HTML\n    type_ = enums.Document.Type.PLAIN_TEXT\n\n    # Optional. If not specified, the language is automatically detected.\n    # For list of supported languages:\n    # https://cloud.google.com/natural-language/docs/languages\n    language = \"en\"\n    document = {\"gcs_content_uri\": gcs_content_uri, \"type\": type_, \"language\": language}\n\n    # Available values: NONE, UTF8, UTF16, UTF32\n    encoding_type = enums.EncodingType.UTF8\n\n    response = client.analyze_syntax(document, encoding_type=encoding_type)\n    # Loop through tokens returned from the API\n    for token in response.tokens:\n        # Get the text content of this token. Usually a word or punctuation.\n        text = token.text\n        print(u\"Token text: {}\".format(text.content))\n        print(\n            u\"Location of this token in overall document: {}\".format(text.begin_offset)\n        )\n        # Get the part of speech information for this token.\n        # Parts of speech are as defined in:\n        # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf\n        part_of_speech = token.part_of_speech\n        # Get the tag, e.g. NOUN, ADJ for Adjective, et al.\n        print(\n            u\"Part of Speech tag: {}\".format(\n                enums.PartOfSpeech.Tag(part_of_speech.tag).name\n            )\n        )\n        # Get the voice, e.g. ACTIVE or PASSIVE\n        print(u\"Voice: {}\".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))\n        # Get the tense, e.g. PAST, FUTURE, PRESENT, et al.\n        print(u\"Tense: {}\".format(enums.PartOfSpeech.Tense(part_of_speech.tense).name))\n        # See API reference for additional Part of Speech information available\n        # Get the lemma of the token. Wikipedia lemma description\n        # https://en.wikipedia.org/wiki/Lemma_(morphology)\n        print(u\"Lemma: {}\".format(token.lemma))\n        # Get the dependency tree parse information for this token.\n        # For more information on dependency labels:\n        # http://www.aclweb.org/anthology/P13-2017\n        dependency_edge = token.dependency_edge\n        print(u\"Head token index: {}\".format(dependency_edge.head_token_index))\n        print(\n            u\"Label: {}\".format(enums.DependencyEdge.Label(dependency_edge.label).name)\n        )\n\n    # Get the language of the text, which will be the same as\n    # the language specified in the request or, if not specified,\n    # the automatically-detected language.\n    print(u\"Language of the text: {}\".format(response.language))\n\n\n# [END language_syntax_gcs]\n\n\ndef main():\n    import argparse\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"--gcs_content_uri\",\n        type=str,\n        default=\"gs://cloud-samples-data/language/syntax-sentence.txt\",\n    )\n    args = parser.parse_args()\n\n    sample_analyze_syntax(args.gcs_content_uri)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "language/samples/v1/language_syntax_gcs.py"}, {"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# DO NOT EDIT! This is a generated sample (\"Request\",  \"language_syntax_text\")\n\n# To install the latest published package dependency, execute the following:\n#   pip install google-cloud-language\n\n# sample-metadata\n#   title: Analyzing Syntax\n#   description: Analyzing Syntax in a String\n#   usage: python3 samples/v1/language_syntax_text.py [--text_content \"This is a short sentence.\"]\n\n# [START language_syntax_text]\nfrom google.cloud import language_v1\nfrom google.cloud.language_v1 import enums\n\n\ndef sample_analyze_syntax(text_content):\n    \"\"\"\n    Analyzing Syntax in a String\n\n    Args:\n      text_content The text content to analyze\n    \"\"\"\n\n    client = language_v1.LanguageServiceClient()\n\n    # text_content = 'This is a short sentence.'\n\n    # Available types: PLAIN_TEXT, HTML\n    type_ = enums.Document.Type.PLAIN_TEXT\n\n    # Optional. If not specified, the language is automatically detected.\n    # For list of supported languages:\n    # https://cloud.google.com/natural-language/docs/languages\n    language = \"en\"\n    document = {\"content\": text_content, \"type\": type_, \"language\": language}\n\n    # Available values: NONE, UTF8, UTF16, UTF32\n    encoding_type = enums.EncodingType.UTF8\n\n    response = client.analyze_syntax(document, encoding_type=encoding_type)\n    # Loop through tokens returned from the API\n    for token in response.tokens:\n        # Get the text content of this token. Usually a word or punctuation.\n        text = token.text\n        print(u\"Token text: {}\".format(text.content))\n        print(\n            u\"Location of this token in overall document: {}\".format(text.begin_offset)\n        )\n        # Get the part of speech information for this token.\n        # Parts of speech are as defined in:\n        # http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf\n        part_of_speech = token.part_of_speech\n        # Get the tag, e.g. NOUN, ADJ for Adjective, et al.\n        print(\n            u\"Part of Speech tag: {}\".format(\n                enums.PartOfSpeech.Tag(part_of_speech.tag).name\n            )\n        )\n        # Get the voice, e.g. ACTIVE or PASSIVE\n        print(u\"Voice: {}\".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))\n        # Get the tense, e.g. PAST, FUTURE, PRESENT, et al.\n        print(u\"Tense: {}\".format(enums.PartOfSpeech.Tense(part_of_speech.tense).name))\n        # See API reference for additional Part of Speech information available\n        # Get the lemma of the token. Wikipedia lemma description\n        # https://en.wikipedia.org/wiki/Lemma_(morphology)\n        print(u\"Lemma: {}\".format(token.lemma))\n        # Get the dependency tree parse information for this token.\n        # For more information on dependency labels:\n        # http://www.aclweb.org/anthology/P13-2017\n        dependency_edge = token.dependency_edge\n        print(u\"Head token index: {}\".format(dependency_edge.head_token_index))\n        print(\n            u\"Label: {}\".format(enums.DependencyEdge.Label(dependency_edge.label).name)\n        )\n\n    # Get the language of the text, which will be the same as\n    # the language specified in the request or, if not specified,\n    # the automatically-detected language.\n    print(u\"Language of the text: {}\".format(response.language))\n\n\n# [END language_syntax_text]\n\n\ndef main():\n    import argparse\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--text_content\", type=str, default=\"This is a short sentence.\")\n    args = parser.parse_args()\n\n    sample_analyze_syntax(args.text_content)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "language/samples/v1/language_syntax_text.py"}]}