Skip to content

Commit

Permalink
Fix client_info bug, update docstrings. (#6415)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpebot authored and tseaver committed Nov 6, 2018
1 parent 62a28d0 commit 464c674
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
class EncodingType(enum.IntEnum):
"""
Represents the text encoding that the caller uses to process the output.
Providing an ``EncodingType`` is recommended because the API provides the
beginning offsets for various outputs, such as tokens and mentions, and
languages that natively use different text encodings may access offsets
differently.
Providing an ``EncodingType`` is recommended because the API provides
the beginning offsets for various outputs, such as tokens and mentions,
and languages that natively use different text encodings may access
offsets differently.
Attributes:
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information (such as
``begin_offset``) will be set at ``-1``.
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
on the UTF-8 encoding of the input. C++ and Go are examples of languages
that use this encoding natively.
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
on the UTF-16 encoding of the input. Java and Javascript are examples of
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information
(such as ``begin_offset``) will be set at ``-1``.
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
based on the UTF-8 encoding of the input. C++ and Go are examples of
languages that use this encoding natively.
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
on the UTF-32 encoding of the input. Python is an example of a language
that uses this encoding natively.
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
based on the UTF-16 encoding of the input. Java and Javascript are
examples of languages that use this encoding natively.
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
based on the UTF-32 encoding of the input. Python is an example of a
language that uses this encoding natively.
"""
NONE = 0
UTF8 = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ def __init__(self,
)

if client_info is None:
client_info = (
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION, )
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
self._client_info = client_info

# Parse out the default settings for retry and timeout for each RPC
Expand Down Expand Up @@ -171,13 +172,14 @@ def analyze_sentiment(self,
>>>
>>> client = language_v1.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_sentiment(document)
Args:
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Document`
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate sentence offsets.
Expand Down Expand Up @@ -235,13 +237,14 @@ def analyze_entities(self,
>>>
>>> client = language_v1.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_entities(document)
Args:
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Document`
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down Expand Up @@ -299,13 +302,14 @@ def analyze_entity_sentiment(
>>>
>>> client = language_v1.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_entity_sentiment(document)
Args:
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Document`
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down Expand Up @@ -363,13 +367,14 @@ def analyze_syntax(self,
>>>
>>> client = language_v1.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_syntax(document)
Args:
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Document`
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down Expand Up @@ -423,13 +428,14 @@ def classify_text(self,
>>>
>>> client = language_v1.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.classify_text(document)
Args:
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Document`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -482,19 +488,21 @@ def annotate_text(self,
>>>
>>> client = language_v1.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> # TODO: Initialize ``features``:
>>> # TODO: Initialize `features`:
>>> features = {}
>>>
>>> response = client.annotate_text(document, features)
Args:
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Document`
features (Union[dict, ~google.cloud.language_v1.types.Features]): The enabled features.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1.types.Features`
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
class EncodingType(enum.IntEnum):
"""
Represents the text encoding that the caller uses to process the output.
Providing an ``EncodingType`` is recommended because the API provides the
beginning offsets for various outputs, such as tokens and mentions, and
languages that natively use different text encodings may access offsets
differently.
Providing an ``EncodingType`` is recommended because the API provides
the beginning offsets for various outputs, such as tokens and mentions,
and languages that natively use different text encodings may access
offsets differently.
Attributes:
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information (such as
``begin_offset``) will be set at ``-1``.
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
on the UTF-8 encoding of the input. C++ and Go are examples of languages
that use this encoding natively.
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
on the UTF-16 encoding of the input. Java and Javascript are examples of
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information
(such as ``begin_offset``) will be set at ``-1``.
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
based on the UTF-8 encoding of the input. C++ and Go are examples of
languages that use this encoding natively.
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
on the UTF-32 encoding of the input. Python is an example of a language
that uses this encoding natively.
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
based on the UTF-16 encoding of the input. Java and Javascript are
examples of languages that use this encoding natively.
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
based on the UTF-32 encoding of the input. Python is an example of a
language that uses this encoding natively.
"""
NONE = 0
UTF8 = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ def __init__(self,
)

if client_info is None:
client_info = (
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION, )
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
self._client_info = client_info

# Parse out the default settings for retry and timeout for each RPC
Expand Down Expand Up @@ -171,13 +172,14 @@ def analyze_sentiment(self,
>>>
>>> client = language_v1beta2.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_sentiment(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Document`
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate sentence offsets for the
Expand Down Expand Up @@ -236,13 +238,14 @@ def analyze_entities(self,
>>>
>>> client = language_v1beta2.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_entities(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Document`
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down Expand Up @@ -300,13 +303,14 @@ def analyze_entity_sentiment(
>>>
>>> client = language_v1beta2.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_entity_sentiment(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Document`
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down Expand Up @@ -364,13 +368,14 @@ def analyze_syntax(self,
>>>
>>> client = language_v1beta2.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.analyze_syntax(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Document`
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down Expand Up @@ -424,13 +429,14 @@ def classify_text(self,
>>>
>>> client = language_v1beta2.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> response = client.classify_text(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Document`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -483,19 +489,21 @@ def annotate_text(self,
>>>
>>> client = language_v1beta2.LanguageServiceClient()
>>>
>>> # TODO: Initialize ``document``:
>>> # TODO: Initialize `document`:
>>> document = {}
>>>
>>> # TODO: Initialize ``features``:
>>> # TODO: Initialize `features`:
>>> features = {}
>>>
>>> response = client.annotate_text(document, features)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Document`
features (Union[dict, ~google.cloud.language_v1beta2.types.Features]): The enabled features.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.language_v1beta2.types.Features`
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
Expand Down

0 comments on commit 464c674

Please sign in to comment.