Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
enhancement(language): add entity types (via synth) (#9373)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and tseaver committed Oct 1, 2019
1 parent 979f44f commit 0df6206
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 221 deletions.
58 changes: 53 additions & 5 deletions google/cloud/language_v1beta2/gapic/enums.py
Expand Up @@ -34,7 +34,7 @@ class EncodingType(enum.IntEnum):
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
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
Expand Down Expand Up @@ -242,17 +242,60 @@ class Type(enum.IntEnum):
class Entity(object):
class Type(enum.IntEnum):
"""
The type of the entity.
The type of the entity. For most entity types, the associated metadata
is a Wikipedia URL (``wikipedia_url``) and Knowledge Graph MID
(``mid``). The table below lists the associated fields for entities that
have different metadata.
Attributes:
UNKNOWN (int): Unknown
PERSON (int): Person
LOCATION (int): Location
ORGANIZATION (int): Organization
EVENT (int): Event
WORK_OF_ART (int): Work of art
CONSUMER_GOOD (int): Consumer goods
OTHER (int): Other types
WORK_OF_ART (int): Artwork
CONSUMER_GOOD (int): Consumer product
OTHER (int): Other types of entities
PHONE_NUMBER (int): Phone number
The metadata lists the phone number, formatted according to local
convention, plus whichever additional elements appear in the text:
- ``number`` - the actual number, broken down into sections as per
local convention
- ``national_prefix`` - country code, if detected
- ``area_code`` - region or area code, if detected
- ``extension`` - phone extension (to be dialed after connection), if
detected
ADDRESS (int): Address
The metadata identifies the street number and locality plus whichever
additional elements appear in the text:
- ``street_number`` - street number
- ``locality`` - city or town
- ``street_name`` - street/route name, if detected
- ``postal_code`` - postal code, if detected
- ``country`` - country, if detected<
- ``broad_region`` - administrative area, such as the state, if
detected
- ``narrow_region`` - smaller administrative area, such as county, if
detected
- ``sublocality`` - used in Asian addresses to demark a district within
a city, if detected
DATE (int): Date
The metadata identifies the components of the date:
- ``year`` - four digit year, if detected
- ``month`` - two digit month number, if detected
- ``day`` - two digit day number, if detected
NUMBER (int): Number
The metadata is the number itself.
PRICE (int): Price
The metadata identifies the ``value`` and ``currency``.
"""

UNKNOWN = 0
Expand All @@ -263,6 +306,11 @@ class Type(enum.IntEnum):
WORK_OF_ART = 5
CONSUMER_GOOD = 6
OTHER = 7
PHONE_NUMBER = 9
ADDRESS = 10
DATE = 11
NUMBER = 12
PRICE = 13


class EntityMention(object):
Expand Down
14 changes: 7 additions & 7 deletions google/cloud/language_v1beta2/gapic/language_service_client.py
Expand Up @@ -207,7 +207,7 @@ def analyze_sentiment(
>>> response = client.analyze_sentiment(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Required. 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`
Expand Down Expand Up @@ -274,7 +274,7 @@ def analyze_entities(
>>> response = client.analyze_entities(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Required. 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`
Expand Down Expand Up @@ -339,7 +339,7 @@ def analyze_entity_sentiment(
>>> response = client.analyze_entity_sentiment(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Required. 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`
Expand Down Expand Up @@ -405,7 +405,7 @@ def analyze_syntax(
>>> response = client.analyze_syntax(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Required. 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`
Expand Down Expand Up @@ -468,7 +468,7 @@ def classify_text(
>>> response = client.classify_text(document)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Required. 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`
Expand Down Expand Up @@ -534,11 +534,11 @@ def annotate_text(
>>> response = client.annotate_text(document, features)
Args:
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Required. 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.
features (Union[dict, ~google.cloud.language_v1beta2.types.Features]): Required. 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`
Expand Down

0 comments on commit 0df6206

Please sign in to comment.