Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python GAPIC: Language v1 #3697

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 11 additions & 17 deletions language/google/cloud/gapic/language/v1/language_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self,

# Finally, track the GAPIC package version.
metrics_headers['gapic'] = pkg_resources.get_distribution(
'google-cloud-language', ).version
'gapic-google-cloud-language-v1', ).version

# Load the configuration defaults.
default_client_config = json.loads(
Expand Down Expand Up @@ -184,25 +184,22 @@ def analyze_sentiment(self, document, encoding_type=None, options=None):
:exc:`google.gax.errors.GaxError` if the RPC is aborted.
:exc:`ValueError` if the parameters are invalid.
"""
# Create the request object.
request = language_service_pb2.AnalyzeSentimentRequest(
document=document, encoding_type=encoding_type)
return self._analyze_sentiment(request, options)

def analyze_entities(self, document, encoding_type, options=None):
def analyze_entities(self, document, encoding_type=None, options=None):
"""
Finds named entities (currently proper names and common nouns) in the text
along with entity types, salience, mentions for each entity, and
other properties.

Example:
>>> from google.cloud.gapic.language.v1 import language_service_client
>>> from google.cloud.gapic.language.v1 import enums
>>> from google.cloud.proto.language.v1 import language_service_pb2
>>> client = language_service_client.LanguageServiceClient()
>>> document = language_service_pb2.Document()
>>> encoding_type = enums.EncodingType.NONE
>>> response = client.analyze_entities(document, encoding_type)
>>> response = client.analyze_entities(document)

Args:
document (:class:`google.cloud.proto.language.v1.language_service_pb2.Document`): Input document.
Expand All @@ -217,25 +214,22 @@ def analyze_entities(self, document, encoding_type, options=None):
:exc:`google.gax.errors.GaxError` if the RPC is aborted.
:exc:`ValueError` if the parameters are invalid.
"""
# Create the request object.
request = language_service_pb2.AnalyzeEntitiesRequest(
document=document, encoding_type=encoding_type)
return self._analyze_entities(request, options)

def analyze_syntax(self, document, encoding_type, options=None):
def analyze_syntax(self, document, encoding_type=None, options=None):
"""
Analyzes the syntax of the text and provides sentence boundaries and
tokenization along with part of speech tags, dependency trees, and other
properties.

Example:
>>> from google.cloud.gapic.language.v1 import language_service_client
>>> from google.cloud.gapic.language.v1 import enums
>>> from google.cloud.proto.language.v1 import language_service_pb2
>>> client = language_service_client.LanguageServiceClient()
>>> document = language_service_pb2.Document()
>>> encoding_type = enums.EncodingType.NONE
>>> response = client.analyze_syntax(document, encoding_type)
>>> response = client.analyze_syntax(document)

Args:
document (:class:`google.cloud.proto.language.v1.language_service_pb2.Document`): Input document.
Expand All @@ -250,25 +244,26 @@ def analyze_syntax(self, document, encoding_type, options=None):
:exc:`google.gax.errors.GaxError` if the RPC is aborted.
:exc:`ValueError` if the parameters are invalid.
"""
# Create the request object.
request = language_service_pb2.AnalyzeSyntaxRequest(
document=document, encoding_type=encoding_type)
return self._analyze_syntax(request, options)

def annotate_text(self, document, features, encoding_type, options=None):
def annotate_text(self,
document,
features,
encoding_type=None,
options=None):
"""
A convenience method that provides all the features that analyzeSentiment,
analyzeEntities, and analyzeSyntax provide in one call.

Example:
>>> from google.cloud.gapic.language.v1 import language_service_client
>>> from google.cloud.gapic.language.v1 import enums
>>> from google.cloud.proto.language.v1 import language_service_pb2
>>> client = language_service_client.LanguageServiceClient()
>>> document = language_service_pb2.Document()
>>> features = language_service_pb2.AnnotateTextRequest.Features()
>>> encoding_type = enums.EncodingType.NONE
>>> response = client.annotate_text(document, features, encoding_type)
>>> response = client.annotate_text(document, features)

Args:
document (:class:`google.cloud.proto.language.v1.language_service_pb2.Document`): Input document.
Expand All @@ -284,7 +279,6 @@ def annotate_text(self, document, features, encoding_type, options=None):
:exc:`google.gax.errors.GaxError` if the RPC is aborted.
:exc:`ValueError` if the parameters are invalid.
"""
# Create the request object.
request = language_service_pb2.AnnotateTextRequest(
document=document, features=features, encoding_type=encoding_type)
return self._annotate_text(request, options)
Empty file.
Loading