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_; 77table Contact { 78 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); 84} 85 86namespace libtextclassifier3.EntityData_; 87table App { 88 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); 126} 127 128// 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 145// The issuer/network of the package tracking number. 146namespace 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 169// 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"). Will be 179 // deprecated, use nanos instead. 180 amount_decimal_part:int; 181 182 // Money amount (e.g. 123.45 from "CHF 123.45"). 183 unnormalized_amount:string (shared); 184 185 // Number of nano (10^-9) units of the amount fractional part. 186 // The value must be between -999,999,999 and +999,999,999 inclusive. 187 // If `units` is positive, `nanos` must be positive or zero. 188 // If `units` is zero, `nanos` can be positive, zero, or negative. 189 // If `units` is negative, `nanos` must be negative or zero. 190 // For example $-1.75 is represented as `amount_whole_part`=-1 and 191 // `nanos`=-750,000,000. 192 nanos:int; 193 194 // Money quantity (e.g. k from "CHF 123.45k"). 195 quantity:string (shared); 196} 197 198namespace libtextclassifier3.EntityData_.Translate_; 199table LanguagePredictionResult { 200 // BCP 47 tag for the language prediction result. 201 language_tag:string (shared); 202 203 // Confidence score for the language prediction result. 204 confidence_score:float; 205} 206 207// Details about detected foreign text. 208namespace libtextclassifier3.EntityData_; 209table Translate { 210 language_prediction_results:[Translate_.LanguagePredictionResult]; 211} 212 213// Represents an entity annotated in text. 214namespace libtextclassifier3; 215table EntityData { 216 // Codepoint indices of the annotation, start is inclusive, end is 217 // exclusive. 218 start:int; 219 220 end:int; 221 222 // The entity type, as in the TextClassifier APIs. 223 type:string (shared); 224 225 datetime:EntityData_.Datetime; 226 reserved_5:int (deprecated); 227 contact:EntityData_.Contact; 228 app:EntityData_.App; 229 payment_card:EntityData_.PaymentCard; 230 flight:EntityData_.Flight; 231 isbn:EntityData_.Isbn; 232 iban:EntityData_.Iban; 233 parcel:EntityData_.ParcelTracking; 234 money:EntityData_.Money; 235 translate:EntityData_.Translate; 236} 237 238root_type libtextclassifier3.EntityData; 239