Tony Mak | d944660 | 2019-02-20 18:25:39 +0000 | [diff] [blame] | 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 | |
Tony Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 17 | namespace libtextclassifier3.EntityData_.Datetime_; |
| 18 | enum 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 Mak | a2a1ff4 | 2019-09-12 15:40:32 +0100 | [diff] [blame] | 29 | namespace libtextclassifier3.EntityData_.Datetime_.DatetimeComponent_; |
| 30 | enum 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. |
| 46 | namespace libtextclassifier3.EntityData_.Datetime_.DatetimeComponent_; |
| 47 | enum 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 | |
| 61 | namespace libtextclassifier3.EntityData_.Datetime_; |
| 62 | table 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 Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 69 | namespace libtextclassifier3.EntityData_; |
| 70 | table Datetime { |
| 71 | time_ms_utc:long; |
| 72 | granularity:Datetime_.Granularity = GRANULARITY_UNKNOWN; |
Tony Mak | a2a1ff4 | 2019-09-12 15:40:32 +0100 | [diff] [blame] | 73 | datetime_component:[Datetime_.DatetimeComponent]; |
Tony Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | namespace libtextclassifier3.EntityData_; |
| 77 | table Contact { |
Tony Mak | a2a1ff4 | 2019-09-12 15:40:32 +0100 | [diff] [blame] | 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); |
Tony Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | namespace libtextclassifier3.EntityData_; |
| 87 | table App { |
Tony Mak | a2a1ff4 | 2019-09-12 15:40:32 +0100 | [diff] [blame] | 88 | name:string (shared); |
| 89 | package_name:string (shared); |
| 90 | } |
| 91 | |
| 92 | // The issuer/network of the payment card. |
| 93 | namespace libtextclassifier3.EntityData_.PaymentCard_; |
| 94 | enum 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. |
| 110 | namespace libtextclassifier3.EntityData_; |
| 111 | table PaymentCard { |
| 112 | card_network:PaymentCard_.CardNetwork; |
| 113 | |
| 114 | // The card number. |
| 115 | card_number:string (shared); |
| 116 | } |
| 117 | |
| 118 | // Details about a flight number. |
| 119 | namespace libtextclassifier3.EntityData_; |
| 120 | table 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 Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 126 | } |
| 127 | |
Tony Mak | 8cd7ba6 | 2019-10-15 15:29:22 +0100 | [diff] [blame] | 128 | // Details about an ISBN number. |
| 129 | namespace libtextclassifier3.EntityData_; |
| 130 | table Isbn { |
| 131 | // The (normalized) number. |
| 132 | number:string (shared); |
| 133 | } |
| 134 | |
| 135 | // Details about an IBAN number. |
| 136 | namespace libtextclassifier3.EntityData_; |
| 137 | table Iban { |
| 138 | // The (normalized) number. |
| 139 | number:string (shared); |
| 140 | |
| 141 | // The country code. |
| 142 | country_code:string (shared); |
| 143 | } |
| 144 | |
Tony Mak | 968412a | 2019-11-13 15:39:57 +0000 | [diff] [blame] | 145 | // The issuer/network of the package tracking number. |
Tony Mak | 8cd7ba6 | 2019-10-15 15:29:22 +0100 | [diff] [blame] | 146 | namespace libtextclassifier3.EntityData_.ParcelTracking_; |
| 147 | enum 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. |
| 163 | namespace libtextclassifier3.EntityData_; |
| 164 | table ParcelTracking { |
| 165 | carrier:ParcelTracking_.Carrier; |
| 166 | tracking_number:string (shared); |
| 167 | } |
| 168 | |
Tony Mak | 76d8096 | 2020-01-08 17:30:51 +0000 | [diff] [blame] | 169 | // Parsed money amount. |
| 170 | namespace libtextclassifier3.EntityData_; |
| 171 | table 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 Mak | 6395924 | 2020-02-07 18:31:16 +0000 | [diff] [blame] | 180 | |
| 181 | // Money amount (e.g. 123.45 from "CHF 123.45"). |
| 182 | unnormalized_amount:string (shared); |
Tony Mak | 76d8096 | 2020-01-08 17:30:51 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Tony Mak | 2146002 | 2020-03-12 18:29:35 +0000 | [diff] [blame] | 185 | namespace libtextclassifier3.EntityData_.Translate_; |
| 186 | table 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. |
| 195 | namespace libtextclassifier3.EntityData_; |
| 196 | table Translate { |
| 197 | language_prediction_results:[Translate_.LanguagePredictionResult]; |
| 198 | } |
| 199 | |
Tony Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 200 | // Represents an entity annotated in text. |
Tony Mak | d944660 | 2019-02-20 18:25:39 +0000 | [diff] [blame] | 201 | namespace libtextclassifier3; |
| 202 | table EntityData { |
Tony Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 203 | // 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 Mak | a2a1ff4 | 2019-09-12 15:40:32 +0100 | [diff] [blame] | 210 | type:string (shared); |
Tony Mak | 83d2de6 | 2019-04-10 16:12:15 +0100 | [diff] [blame] | 211 | |
| 212 | datetime:EntityData_.Datetime; |
| 213 | reserved_5:int (deprecated); |
| 214 | contact:EntityData_.Contact; |
| 215 | app:EntityData_.App; |
Tony Mak | a2a1ff4 | 2019-09-12 15:40:32 +0100 | [diff] [blame] | 216 | payment_card:EntityData_.PaymentCard; |
| 217 | flight:EntityData_.Flight; |
Tony Mak | 8cd7ba6 | 2019-10-15 15:29:22 +0100 | [diff] [blame] | 218 | isbn:EntityData_.Isbn; |
| 219 | iban:EntityData_.Iban; |
| 220 | parcel:EntityData_.ParcelTracking; |
Tony Mak | 76d8096 | 2020-01-08 17:30:51 +0000 | [diff] [blame] | 221 | money:EntityData_.Money; |
Tony Mak | 2146002 | 2020-03-12 18:29:35 +0000 | [diff] [blame] | 222 | translate:EntityData_.Translate; |
Tony Mak | d944660 | 2019-02-20 18:25:39 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | root_type libtextclassifier3.EntityData; |