Skip to content

Commit

Permalink
chore(python): run blacken session for all directories with a noxfile (
Browse files Browse the repository at this point in the history
…#220)

Source-Link: googleapis/synthtool@bc0de6e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:39ad8c0570e4f5d2d3124a509de4fe975e799e2b97e0f58aed88f8880d5a8b60

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Nov 11, 2021
1 parent abf8e46 commit a952f23
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion language/snippets/classify_text/classify_text_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def classify(text, verbose=True):
document = language_v1.Document(
content=text, type_=language_v1.Document.Type.PLAIN_TEXT
)
response = language_client.classify_text(request={'document': document})
response = language_client.classify_text(request={"document": document})
categories = response.categories

result = {}
Expand Down
8 changes: 6 additions & 2 deletions language/snippets/cloud-client/v1/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ def run_quickstart():

# The text to analyze
text = u"Hello, world!"
document = language_v1.Document(content=text, type_=language_v1.Document.Type.PLAIN_TEXT)
document = language_v1.Document(
content=text, type_=language_v1.Document.Type.PLAIN_TEXT
)

# Detects the sentiment of the text
sentiment = client.analyze_sentiment(request={'document': document}).document_sentiment
sentiment = client.analyze_sentiment(
request={"document": document}
).document_sentiment

print("Text: {}".format(text))
print("Sentiment: {}, {}".format(sentiment.score, sentiment.magnitude))
Expand Down
4 changes: 3 additions & 1 deletion language/snippets/cloud-client/v1/set_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def set_endpoint():
)

# Detects the sentiment of the text
sentiment = client.analyze_sentiment(request={'document': document}).document_sentiment
sentiment = client.analyze_sentiment(
request={"document": document}
).document_sentiment

print("Sentiment: {}, {}".format(sentiment.score, sentiment.magnitude))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def sample_analyze_sentiment(content):
type_ = language_v1.Document.Type.PLAIN_TEXT
document = {"type_": type_, "content": content}

response = client.analyze_sentiment(request={'document': document})
response = client.analyze_sentiment(request={"document": document})
sentiment = response.document_sentiment
print("Score: {}".format(sentiment.score))
print("Magnitude: {}".format(sentiment.magnitude))
Expand Down
6 changes: 4 additions & 2 deletions language/snippets/sentiment/sentiment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def analyze(movie_review_filename):
# Instantiates a plain text document.
content = review_file.read()

document = language_v1.Document(content=content, type_=language_v1.Document.Type.PLAIN_TEXT)
annotations = client.analyze_sentiment(request={'document': document})
document = language_v1.Document(
content=content, type_=language_v1.Document.Type.PLAIN_TEXT
)
annotations = client.analyze_sentiment(request={"document": document})

# Print the results
print_result(annotations)
Expand Down

0 comments on commit a952f23

Please sign in to comment.