Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions google/cloud/language_v1/services/language_service/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,28 @@ async def analyze_sentiment(
) -> language_service.AnalyzeSentimentResponse:
r"""Analyzes the sentiment of the provided text.

.. code-block::

from google.cloud import language_v1

def sample_analyze_sentiment():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeSentimentRequest(
document=document,
)

# Make the request
response = client.analyze_sentiment(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeSentimentRequest, dict]):
The request object. The sentiment analysis request
Expand Down Expand Up @@ -299,6 +321,29 @@ async def analyze_entities(
salience, mentions for each entity, and other
properties.


.. code-block::

from google.cloud import language_v1

def sample_analyze_entities():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeEntitiesRequest(
document=document,
)

# Make the request
response = client.analyze_entities(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeEntitiesRequest, dict]):
The request object. The entity analysis request message.
Expand Down Expand Up @@ -382,6 +427,29 @@ async def analyze_entity_sentiment(
in the text and analyzes sentiment associated with each entity
and its mentions.


.. code-block::

from google.cloud import language_v1

def sample_analyze_entity_sentiment():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeEntitySentimentRequest(
document=document,
)

# Make the request
response = client.analyze_entity_sentiment(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeEntitySentimentRequest, dict]):
The request object. The entity-level sentiment analysis
Expand Down Expand Up @@ -467,6 +535,29 @@ async def analyze_syntax(
boundaries and tokenization along with part of speech
tags, dependency trees, and other properties.


.. code-block::

from google.cloud import language_v1

def sample_analyze_syntax():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeSyntaxRequest(
document=document,
)

# Make the request
response = client.analyze_syntax(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeSyntaxRequest, dict]):
The request object. The syntax analysis request message.
Expand Down Expand Up @@ -546,6 +637,28 @@ async def classify_text(
) -> language_service.ClassifyTextResponse:
r"""Classifies a document into categories.

.. code-block::

from google.cloud import language_v1

def sample_classify_text():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.ClassifyTextRequest(
document=document,
)

# Make the request
response = client.classify_text(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.ClassifyTextRequest, dict]):
The request object. The document classification request
Expand Down Expand Up @@ -623,6 +736,29 @@ async def annotate_text(
that analyzeSentiment, analyzeEntities, and
analyzeSyntax provide in one call.


.. code-block::

from google.cloud import language_v1

def sample_annotate_text():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnnotateTextRequest(
document=document,
)

# Make the request
response = client.annotate_text(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnnotateTextRequest, dict]):
The request object. The request message for the text
Expand Down
142 changes: 142 additions & 0 deletions google/cloud/language_v1/services/language_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,29 @@ def analyze_sentiment(
) -> language_service.AnalyzeSentimentResponse:
r"""Analyzes the sentiment of the provided text.


.. code-block::

from google.cloud import language_v1

def sample_analyze_sentiment():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeSentimentRequest(
document=document,
)

# Make the request
response = client.analyze_sentiment(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeSentimentRequest, dict]):
The request object. The sentiment analysis request
Expand Down Expand Up @@ -472,6 +495,30 @@ def analyze_entities(
salience, mentions for each entity, and other
properties.



.. code-block::

from google.cloud import language_v1

def sample_analyze_entities():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeEntitiesRequest(
document=document,
)

# Make the request
response = client.analyze_entities(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeEntitiesRequest, dict]):
The request object. The entity analysis request message.
Expand Down Expand Up @@ -545,6 +592,30 @@ def analyze_entity_sentiment(
in the text and analyzes sentiment associated with each entity
and its mentions.



.. code-block::

from google.cloud import language_v1

def sample_analyze_entity_sentiment():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeEntitySentimentRequest(
document=document,
)

# Make the request
response = client.analyze_entity_sentiment(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeEntitySentimentRequest, dict]):
The request object. The entity-level sentiment analysis
Expand Down Expand Up @@ -620,6 +691,30 @@ def analyze_syntax(
boundaries and tokenization along with part of speech
tags, dependency trees, and other properties.



.. code-block::

from google.cloud import language_v1

def sample_analyze_syntax():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnalyzeSyntaxRequest(
document=document,
)

# Make the request
response = client.analyze_syntax(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnalyzeSyntaxRequest, dict]):
The request object. The syntax analysis request message.
Expand Down Expand Up @@ -689,6 +784,29 @@ def classify_text(
) -> language_service.ClassifyTextResponse:
r"""Classifies a document into categories.


.. code-block::

from google.cloud import language_v1

def sample_classify_text():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.ClassifyTextRequest(
document=document,
)

# Make the request
response = client.classify_text(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.ClassifyTextRequest, dict]):
The request object. The document classification request
Expand Down Expand Up @@ -756,6 +874,30 @@ def annotate_text(
that analyzeSentiment, analyzeEntities, and
analyzeSyntax provide in one call.



.. code-block::

from google.cloud import language_v1

def sample_annotate_text():
# Create a client
client = language_v1.LanguageServiceClient()

# Initialize request argument(s)
document = language_v1.Document()
document.content = "content_value"

request = language_v1.AnnotateTextRequest(
document=document,
)

# Make the request
response = client.annotate_text(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.language_v1.types.AnnotateTextRequest, dict]):
The request object. The request message for the text
Expand Down
Loading