blob: 4c02f6db90ecee3b36d73ebc9dbb6be1e3196d76 [file] [log] [blame]
Tony Makd9446602019-02-20 18:25:39 +00001//
2// Copyright (C) 2018 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Tony Mak83d2de62019-04-10 16:12:15 +010017namespace libtextclassifier3.EntityData_.Datetime_;
18enum Granularity : int {
19 GRANULARITY_UNKNOWN = -1,
20 GRANULARITY_YEAR = 0,
21 GRANULARITY_MONTH = 1,
22 GRANULARITY_WEEK = 2,
23 GRANULARITY_DAY = 3,
24 GRANULARITY_HOUR = 4,
25 GRANULARITY_MINUTE = 5,
26 GRANULARITY_SECOND = 6,
27}
28
Tony Maka2a1ff42019-09-12 15:40:32 +010029namespace libtextclassifier3.EntityData_.Datetime_.DatetimeComponent_;
30enum ComponentType : int {
31 UNSPECIFIED = 0,
32 YEAR = 1,
33 MONTH = 2,
34 WEEK = 3,
35 DAY_OF_WEEK = 4,
36 DAY_OF_MONTH = 5,
37 HOUR = 6,
38 MINUTE = 7,
39 SECOND = 8,
40 MERIDIEM = 9,
41 ZONE_OFFSET = 10,
42 DST_OFFSET = 11,
43}
44
45// Enum to identify if the datetime component are relative or absolute.
46namespace libtextclassifier3.EntityData_.Datetime_.DatetimeComponent_;
47enum RelationType : int {
48 RELATION_UNSPECIFIED = 0,
49
50 // Absolute represents the datetime component that need no further
51 // calculation e.g. in a datetime span "21-03-2019" components
52 // year=2019, month=3 and day=21 is explicitly mentioned in the span
53 ABSOLUTE = 1,
54
55 // Identify datetime component where datetime expressions are relative.
56 // e.g. "three days ago", "2 days after March 1st", "next monday",
57 // "last Mondays".
58 RELATIVE = 2,
59}
60
61namespace libtextclassifier3.EntityData_.Datetime_;
62table DatetimeComponent {
63 component_type:DatetimeComponent_.ComponentType = UNSPECIFIED;
64 absolute_value:int;
65 relative_count:int;
66 relation_type:DatetimeComponent_.RelationType = RELATION_UNSPECIFIED;
67}
68
Tony Mak83d2de62019-04-10 16:12:15 +010069namespace libtextclassifier3.EntityData_;
70table Datetime {
71 time_ms_utc:long;
72 granularity:Datetime_.Granularity = GRANULARITY_UNKNOWN;
Tony Maka2a1ff42019-09-12 15:40:32 +010073 datetime_component:[Datetime_.DatetimeComponent];
Tony Mak83d2de62019-04-10 16:12:15 +010074}
75
76namespace libtextclassifier3.EntityData_;
77table Contact {
Tony Maka2a1ff42019-09-12 15:40:32 +010078 name:string (shared);
79 given_name:string (shared);
80 nickname:string (shared);
81 email_address:string (shared);
82 phone_number:string (shared);
83 contact_id:string (shared);
Tony Mak83d2de62019-04-10 16:12:15 +010084}
85
86namespace libtextclassifier3.EntityData_;
87table App {
Tony Maka2a1ff42019-09-12 15:40:32 +010088 name:string (shared);
89 package_name:string (shared);
90}
91
92// The issuer/network of the payment card.
93namespace libtextclassifier3.EntityData_.PaymentCard_;
94enum CardNetwork : int {
95 UNKNOWN_CARD_NETWORK = 0,
96 AMEX = 1,
97 DINERS_CLUB = 2,
98 DISCOVER = 3,
99 INTER_PAYMENT = 4,
100 JCB = 5,
101 MAESTRO = 6,
102 MASTERCARD = 7,
103 MIR = 8,
104 TROY = 9,
105 UNIONPAY = 10,
106 VISA = 11,
107}
108
109// Details about a payment card.
110namespace libtextclassifier3.EntityData_;
111table PaymentCard {
112 card_network:PaymentCard_.CardNetwork;
113
114 // The card number.
115 card_number:string (shared);
116}
117
118// Details about a flight number.
119namespace libtextclassifier3.EntityData_;
120table Flight {
121 // The IATA or ICAO airline code of the flight number.
122 airline_code:string (shared);
123
124 // The flight number.
125 flight_number:string (shared);
Tony Mak83d2de62019-04-10 16:12:15 +0100126}
127
Tony Mak8cd7ba62019-10-15 15:29:22 +0100128// Details about an ISBN number.
129namespace libtextclassifier3.EntityData_;
130table Isbn {
131 // The (normalized) number.
132 number:string (shared);
133}
134
135// Details about an IBAN number.
136namespace libtextclassifier3.EntityData_;
137table Iban {
138 // The (normalized) number.
139 number:string (shared);
140
141 // The country code.
142 country_code:string (shared);
143}
144
Tony Mak968412a2019-11-13 15:39:57 +0000145// The issuer/network of the package tracking number.
Tony Mak8cd7ba62019-10-15 15:29:22 +0100146namespace libtextclassifier3.EntityData_.ParcelTracking_;
147enum Carrier : int {
148 UNKNOWN_CARRIER = 0,
149 FEDEX = 1,
150 UPS = 2,
151 DHL = 3,
152 USPS = 4,
153 ONTRAC = 5,
154 LASERSHIP = 6,
155 ISRAEL_POST = 7,
156 SWISS_POST = 8,
157 MSC = 9,
158 AMAZON = 10,
159 I_PARCEL = 11,
160}
161
162// Details about a tracking number.
163namespace libtextclassifier3.EntityData_;
164table ParcelTracking {
165 carrier:ParcelTracking_.Carrier;
166 tracking_number:string (shared);
167}
168
Tony Mak76d80962020-01-08 17:30:51 +0000169// Parsed money amount.
170namespace libtextclassifier3.EntityData_;
171table Money {
172 // String representation of currency, unnormalized.
173 unnormalized_currency:string (shared);
174
175 // Whole part of the amount (e.g. 123 from "CHF 123.45").
176 amount_whole_part:int;
177
178 // Decimal part of the amount (e.g. 45 from "CHF 123.45").
179 amount_decimal_part:int;
Tony Mak63959242020-02-07 18:31:16 +0000180
181 // Money amount (e.g. 123.45 from "CHF 123.45").
182 unnormalized_amount:string (shared);
Tony Mak76d80962020-01-08 17:30:51 +0000183}
184
Tony Mak21460022020-03-12 18:29:35 +0000185namespace libtextclassifier3.EntityData_.Translate_;
186table LanguagePredictionResult {
187 // BCP 47 tag for the language prediction result.
188 language_tag:string (shared);
189
190 // Confidence score for the language prediction result.
191 confidence_score:float;
192}
193
194// Details about detected foreign text.
195namespace libtextclassifier3.EntityData_;
196table Translate {
197 language_prediction_results:[Translate_.LanguagePredictionResult];
198}
199
Tony Mak83d2de62019-04-10 16:12:15 +0100200// Represents an entity annotated in text.
Tony Makd9446602019-02-20 18:25:39 +0000201namespace libtextclassifier3;
202table EntityData {
Tony Mak83d2de62019-04-10 16:12:15 +0100203 // Codepoint indices of the annotation, start is inclusive, end is
204 // exclusive.
205 start:int;
206
207 end:int;
208
209 // The entity type, as in the TextClassifier APIs.
Tony Maka2a1ff42019-09-12 15:40:32 +0100210 type:string (shared);
Tony Mak83d2de62019-04-10 16:12:15 +0100211
212 datetime:EntityData_.Datetime;
213 reserved_5:int (deprecated);
214 contact:EntityData_.Contact;
215 app:EntityData_.App;
Tony Maka2a1ff42019-09-12 15:40:32 +0100216 payment_card:EntityData_.PaymentCard;
217 flight:EntityData_.Flight;
Tony Mak8cd7ba62019-10-15 15:29:22 +0100218 isbn:EntityData_.Isbn;
219 iban:EntityData_.Iban;
220 parcel:EntityData_.ParcelTracking;
Tony Mak76d80962020-01-08 17:30:51 +0000221 money:EntityData_.Money;
Tony Mak21460022020-03-12 18:29:35 +0000222 translate:EntityData_.Translate;
Tony Makd9446602019-02-20 18:25:39 +0000223}
224
225root_type libtextclassifier3.EntityData;