xref: /aosp_15_r20/external/libtextclassifier/native/annotator/entity-data.fbs (revision 993b0882672172b81d12fad7a7ac0c3e5c824a12)
1//
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
17namespace 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
29namespace 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
69namespace libtextclassifier3.EntityData_;
70table Datetime {
71  time_ms_utc:long;
72  granularity:Datetime_.Granularity = GRANULARITY_UNKNOWN;
73  datetime_component:[Datetime_.DatetimeComponent];
74}
75
76namespace libtextclassifier3.EntityData_.Contact_.AlternativeNameInfo_;
77enum AlternativeNameSource : int {
78  NONE = 0,
79  NAME_CORRECTION_LOG = 1,
80}
81
82namespace libtextclassifier3.EntityData_.Contact_;
83table AlternativeNameInfo {
84  name:string (shared);
85  source:AlternativeNameInfo_.AlternativeNameSource;
86}
87
88namespace libtextclassifier3.EntityData_;
89table Contact {
90  name:string (shared);
91  given_name:string (shared);
92  nickname:string (shared);
93  email_address:string (shared);
94  phone_number:string (shared);
95  contact_id:string (shared);
96  alternative_name_info:[Contact_.AlternativeNameInfo];
97}
98
99namespace libtextclassifier3.EntityData_;
100table App {
101  name:string (shared);
102  package_name:string (shared);
103}
104
105// The issuer/network of the payment card.
106namespace libtextclassifier3.EntityData_.PaymentCard_;
107enum CardNetwork : int {
108  UNKNOWN_CARD_NETWORK = 0,
109  AMEX = 1,
110  DINERS_CLUB = 2,
111  DISCOVER = 3,
112  INTER_PAYMENT = 4,
113  JCB = 5,
114  MAESTRO = 6,
115  MASTERCARD = 7,
116  MIR = 8,
117  TROY = 9,
118  UNIONPAY = 10,
119  VISA = 11,
120}
121
122// Details about a payment card.
123namespace libtextclassifier3.EntityData_;
124table PaymentCard {
125  card_network:PaymentCard_.CardNetwork;
126
127  // The card number.
128  card_number:string (shared);
129}
130
131// Details about a flight number.
132namespace libtextclassifier3.EntityData_;
133table Flight {
134  // The IATA or ICAO airline code of the flight number.
135  airline_code:string (shared);
136
137  // The flight number.
138  flight_number:string (shared);
139}
140
141// Details about an ISBN number.
142namespace libtextclassifier3.EntityData_;
143table Isbn {
144  // The (normalized) number.
145  number:string (shared);
146}
147
148// Details about an IBAN number.
149namespace libtextclassifier3.EntityData_;
150table Iban {
151  // The (normalized) number.
152  number:string (shared);
153
154  // The country code.
155  country_code:string (shared);
156}
157
158// The issuer/network of the package tracking number.
159namespace libtextclassifier3.EntityData_.ParcelTracking_;
160enum Carrier : int {
161  UNKNOWN_CARRIER = 0,
162  FEDEX = 1,
163  UPS = 2,
164  DHL = 3,
165  USPS = 4,
166  ONTRAC = 5,
167  LASERSHIP = 6,
168  ISRAEL_POST = 7,
169  SWISS_POST = 8,
170  MSC = 9,
171  AMAZON = 10,
172  I_PARCEL = 11,
173}
174
175// Details about a tracking number.
176namespace libtextclassifier3.EntityData_;
177table ParcelTracking {
178  carrier:ParcelTracking_.Carrier;
179  tracking_number:string (shared);
180}
181
182// Parsed money amount.
183namespace libtextclassifier3.EntityData_;
184table Money {
185  // String representation of currency, unnormalized.
186  unnormalized_currency:string (shared);
187
188  // Whole part of the amount (e.g. 123 from "CHF 123.45").
189  amount_whole_part:int;
190
191  // Decimal part of the amount (e.g. 45 from "CHF 123.45"). Will be
192  // deprecated, use nanos instead.
193  amount_decimal_part:int;
194
195  // Money amount (e.g. 123.45 from "CHF 123.45").
196  unnormalized_amount:string (shared);
197
198  // Number of nano (10^-9) units of the amount fractional part.
199  // The value must be between -999,999,999 and +999,999,999 inclusive.
200  // If `units` is positive, `nanos` must be positive or zero.
201  // If `units` is zero, `nanos` can be positive, zero, or negative.
202  // If `units` is negative, `nanos` must be negative or zero.
203  // For example $-1.75 is represented as `amount_whole_part`=-1 and
204  // `nanos`=-750,000,000.
205  nanos:int;
206
207  // Money quantity (e.g. k from "CHF 123.45k").
208  quantity:string (shared);
209}
210
211namespace libtextclassifier3.EntityData_.Translate_;
212table LanguagePredictionResult {
213  // BCP 47 tag for the language prediction result.
214  language_tag:string (shared);
215
216  // Confidence score for the language prediction result.
217  confidence_score:float;
218}
219
220// Details about detected foreign text.
221namespace libtextclassifier3.EntityData_;
222table Translate {
223  language_prediction_results:[Translate_.LanguagePredictionResult];
224}
225
226// Represents an entity annotated in text.
227namespace libtextclassifier3;
228table EntityData {
229  // Codepoint indices of the annotation, start is inclusive, end is
230  // exclusive.
231  start:int;
232
233  end:int;
234
235  // The entity type, as in the TextClassifier APIs.
236  type:string (shared);
237
238  datetime:EntityData_.Datetime;
239  reserved_5:int (deprecated);
240  contact:EntityData_.Contact;
241  app:EntityData_.App;
242  payment_card:EntityData_.PaymentCard;
243  flight:EntityData_.Flight;
244  isbn:EntityData_.Isbn;
245  iban:EntityData_.Iban;
246  parcel:EntityData_.ParcelTracking;
247  money:EntityData_.Money;
248  translate:EntityData_.Translate;
249}
250
251root_type libtextclassifier3.EntityData;
252