Skip to content

Commit

Permalink
Language: Add new entity types (via synth)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and busunkim96 committed Mar 14, 2019
1 parent fc6363b commit 3323e0f
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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 @@ -252,6 +252,11 @@ class Type(enum.IntEnum):
WORK_OF_ART (int): Work of art
CONSUMER_GOOD (int): Consumer goods
OTHER (int): Other types
PHONE_NUMBER (int): Phone number
ADDRESS (int): Address
DATE (int): Date
NUMBER (int): Number
PRICE (int): Price
"""

UNKNOWN = 0
Expand All @@ -262,6 +267,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
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 60000,
"initial_rpc_timeout_millis": 20000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 60000,
"max_rpc_timeout_millis": 20000,
"total_timeout_millis": 600000,
}
},
"methods": {
"AnalyzeSentiment": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"AnalyzeEntities": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"AnalyzeEntitySentiment": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"AnalyzeSyntax": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ClassifyText": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"AnnotateText": {
"timeout_millis": 30000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class LanguageServiceGrpcTransport(object):

# The scopes needed to make gRPC calls to all of the methods defined
# in this service.
_OAUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
_OAUTH_SCOPES = (
"https://www.googleapis.com/auth/cloud-language",
"https://www.googleapis.com/auth/cloud-platform",
)

def __init__(
self, channel=None, credentials=None, address="language.googleapis.com:443"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google Inc.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

Expand Down Expand Up @@ -170,6 +171,21 @@ message Entity {

// Other types
OTHER = 7;

// Phone number
PHONE_NUMBER = 9;

// Address
ADDRESS = 10;

// Date
DATE = 11;

// Number
NUMBER = 12;

// Price
PRICE = 13;
}

// The representative name for the entity.
Expand Down Expand Up @@ -203,6 +219,32 @@ message Entity {
Sentiment sentiment = 6;
}

// 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.
enum EncodingType {
// If `EncodingType` is not specified, encoding-dependent information (such as
// `begin_offset`) will be set at `-1`.
NONE = 0;

// 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.
UTF8 = 1;

// 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.
UTF16 = 2;

// 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.
UTF32 = 3;
}

// Represents the smallest syntactic building block of the text.
message Token {
// The token text.
Expand Down Expand Up @@ -870,7 +912,8 @@ message TextSpan {

// Represents a category returned from the text classifier.
message ClassificationCategory {
// The name of the category representing the document.
// The name of the category representing the document, from the [predefined
// taxonomy](/natural-language/docs/categories).
string name = 1;

// The classifier's confidence of the category. Number represents how certain
Expand Down Expand Up @@ -1041,29 +1084,3 @@ message AnnotateTextResponse {
// Categories identified in the input document.
repeated ClassificationCategory categories = 6;
}

// 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.
enum EncodingType {
// If `EncodingType` is not specified, encoding-dependent information (such as
// `begin_offset`) will be set at `-1`.
NONE = 0;

// 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.
UTF8 = 1;

// 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.
UTF16 = 2;

// 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.
UTF32 = 3;
}
Loading

0 comments on commit 3323e0f

Please sign in to comment.