Skip to content

Commit 498813c

Browse files
hkdevandlabusunkim96
authored andcommitted
chore: update templates
1 parent 55b3069 commit 498813c

19 files changed

+1395
-265
lines changed

language/AUTHORING_GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md

language/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md

language/snippets/api/analyze.py

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,77 +26,67 @@
2626
def get_native_encoding_type():
2727
"""Returns the encoding type that matches Python's native strings."""
2828
if sys.maxunicode == 65535:
29-
return 'UTF16'
29+
return "UTF16"
3030
else:
31-
return 'UTF32'
31+
return "UTF32"
3232

3333

34-
def analyze_entities(text, encoding='UTF32'):
34+
def analyze_entities(text, encoding="UTF32"):
3535
body = {
36-
'document': {
37-
'type': 'PLAIN_TEXT',
38-
'content': text,
39-
},
40-
'encoding_type': encoding,
36+
"document": {"type": "PLAIN_TEXT", "content": text},
37+
"encoding_type": encoding,
4138
}
4239

43-
service = googleapiclient.discovery.build('language', 'v1')
40+
service = googleapiclient.discovery.build("language", "v1")
4441

4542
request = service.documents().analyzeEntities(body=body)
4643
response = request.execute()
4744

4845
return response
4946

5047

51-
def analyze_sentiment(text, encoding='UTF32'):
48+
def analyze_sentiment(text, encoding="UTF32"):
5249
body = {
53-
'document': {
54-
'type': 'PLAIN_TEXT',
55-
'content': text,
56-
},
57-
'encoding_type': encoding
50+
"document": {"type": "PLAIN_TEXT", "content": text},
51+
"encoding_type": encoding,
5852
}
5953

60-
service = googleapiclient.discovery.build('language', 'v1')
54+
service = googleapiclient.discovery.build("language", "v1")
6155

6256
request = service.documents().analyzeSentiment(body=body)
6357
response = request.execute()
6458

6559
return response
6660

6761

68-
def analyze_syntax(text, encoding='UTF32'):
62+
def analyze_syntax(text, encoding="UTF32"):
6963
body = {
70-
'document': {
71-
'type': 'PLAIN_TEXT',
72-
'content': text,
73-
},
74-
'encoding_type': encoding
64+
"document": {"type": "PLAIN_TEXT", "content": text},
65+
"encoding_type": encoding,
7566
}
7667

77-
service = googleapiclient.discovery.build('language', 'v1')
68+
service = googleapiclient.discovery.build("language", "v1")
7869

7970
request = service.documents().analyzeSyntax(body=body)
8071
response = request.execute()
8172

8273
return response
8374

8475

85-
if __name__ == '__main__':
76+
if __name__ == "__main__":
8677
parser = argparse.ArgumentParser(
87-
description=__doc__,
88-
formatter_class=argparse.RawDescriptionHelpFormatter)
89-
parser.add_argument('command', choices=[
90-
'entities', 'sentiment', 'syntax'])
91-
parser.add_argument('text')
78+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
79+
)
80+
parser.add_argument("command", choices=["entities", "sentiment", "syntax"])
81+
parser.add_argument("text")
9282

9383
args = parser.parse_args()
9484

95-
if args.command == 'entities':
85+
if args.command == "entities":
9686
result = analyze_entities(args.text, get_native_encoding_type())
97-
elif args.command == 'sentiment':
87+
elif args.command == "sentiment":
9888
result = analyze_sentiment(args.text, get_native_encoding_type())
99-
elif args.command == 'syntax':
89+
elif args.command == "syntax":
10090
result = analyze_syntax(args.text, get_native_encoding_type())
10191

10292
print(json.dumps(result, indent=2))

0 commit comments

Comments
 (0)