Skip to content

Commit b30c127

Browse files
authored
Add small, generated version of language_sentiment_text [(#1660)](GoogleCloudPlatform/python-docs-samples#1660)
* Generated sample: language_sentiment_text FYI generated from the following YAML GAPIC config: sample_value_sets: - id: analyze_sentiment title: "Analyzing Sentiment" description: "Proof of concept for analyzing sentiment" parameters: defaults: - document.type=PLAIN_TEXT - document.content="Your text to analyze, e.g. Hello, world!" attributes: - parameter: document.content sample_argument: true on_success: - define: sentiment=$resp.document_sentiment - print: - "Score: %s" - sentiment.score - print: - "Magnitude: %s" - sentiment.magnitude samples: standalone: - calling_forms: ".*" value_sets: analyze_sentiment region_tag: language_sentiment_text * Add requirements.txt (not currently generated) * Add test for language_sentiment_text (not currently generated) * Move language_python_migration_document_text Move language_python_migration_document_text so it uses a different snippet in preparation for deprecation of existing language_sentiment_text sample * Rename generated snippets so filename == region tag * Fix test for generated code sample (file rename to match region tag) * Update Copyright year to 2018 in new hand-written file * Fix lint errors of #language_sentiment_text test * Regenerate #language_sentiment_text to fix lint errors (updated Python sample template) * Binary string support in samples! From PR googleapis/gapic-generator#2272
1 parent bd0bd1f commit b30c127

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

samples/snippets/snippets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ def sentiment_text(text):
3939
text = text.decode('utf-8')
4040

4141
# Instantiates a plain text document.
42-
# [START language_python_migration_document_text]
4342
# [START language_python_migration_sentiment_text]
4443
document = types.Document(
4544
content=text,
4645
type=enums.Document.Type.PLAIN_TEXT)
47-
# [END language_python_migration_document_text]
4846

4947
# Detects sentiment in the document. You can also analyze HTML with:
5048
# document.type == enums.Document.Type.HTML
@@ -87,9 +85,11 @@ def entities_text(text):
8785

8886
# Instantiates a plain text document.
8987
# [START language_python_migration_entities_text]
88+
# [START language_python_migration_document_text]
9089
document = types.Document(
9190
content=text,
9291
type=enums.Document.Type.PLAIN_TEXT)
92+
# [END language_python_migration_document_text]
9393

9494
# Detects entities in the document. You can also analyze HTML with:
9595
# document.type == enums.Document.Type.HTML

0 commit comments

Comments
 (0)