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 17 #ifndef LIBTEXTCLASSIFIER_ANNOTATOR_GRAMMAR_DATES_ANNOTATIONS_ANNOTATION_OPTIONS_H_ 18 #define LIBTEXTCLASSIFIER_ANNOTATOR_GRAMMAR_DATES_ANNOTATIONS_ANNOTATION_OPTIONS_H_ 19 20 #include <string> 21 #include <vector> 22 23 #include "utils/base/integral_types.h" 24 25 namespace libtextclassifier3 { 26 27 // Options for date/datetime/date range annotations. 28 struct DateAnnotationOptions { 29 // If enabled, extract special day offset like today, yesterday, etc. 30 bool enable_special_day_offset; 31 32 // If true, merge the adjacent day of week, time and date. e.g. 33 // "20/2/2016 at 8pm" is extracted as a single instance instead of two 34 // instance: "20/2/2016" and "8pm". 35 bool merge_adjacent_components; 36 37 // List the extra id of requested dates. 38 std::vector<std::string> extra_requested_dates; 39 40 // If true, try to include preposition to the extracted annotation. e.g. 41 // "at 6pm". if it's false, only 6pm is included. offline-actions has special 42 // requirements to include preposition. 43 bool include_preposition; 44 45 // The base timestamp (milliseconds) which used to convert relative time to 46 // absolute time. 47 // e.g.: 48 // base timestamp is 2016/4/25, then tomorrow will be converted to 49 // 2016/4/26. 50 // base timestamp is 2016/4/25 10:30:20am, then 1 days, 2 hours, 10 minutes 51 // and 5 seconds ago will be converted to 2016/4/24 08:20:15am 52 int64 base_timestamp_millis; 53 54 // If enabled, extract range in date annotator. 55 // input: Monday, 5-6pm 56 // If the flag is true, The extracted annotation only contains 1 range 57 // instance which is from Monday 5pm to 6pm. 58 // If the flag is false, The extracted annotation contains two date 59 // instance: "Monday" and "6pm". 60 bool enable_date_range; 61 62 // Timezone in which the input text was written 63 std::string reference_timezone; 64 // Localization params. 65 // The format of the locale lists should be "<lang_code-<county_code>" 66 // comma-separated list of two-character language/country pairs. 67 std::string locales; 68 69 // If enabled, the annotation/rule_match priority score is used to set the and 70 // priority score of the annotation. 71 // In case of false the annotation priority score are set from 72 // GrammarDatetimeModel's priority_score 73 bool use_rule_priority_score; 74 75 // If enabled, annotator will try to resolve the ambiguity by generating 76 // possible alternative interpretations of the input text 77 // e.g. '9:45' will be resolved to '9:45 AM' and '9:45 PM'. 78 bool generate_alternative_interpretations_when_ambiguous; 79 80 // List the ignored span in the date string e.g. 12 March @12PM, here '@' 81 // can be ignored tokens. 82 std::vector<std::string> ignored_spans; 83 84 // Default Constructor DateAnnotationOptionsDateAnnotationOptions85 DateAnnotationOptions() 86 : enable_special_day_offset(true), 87 merge_adjacent_components(true), 88 include_preposition(false), 89 base_timestamp_millis(0), 90 enable_date_range(false), 91 use_rule_priority_score(false), 92 generate_alternative_interpretations_when_ambiguous(false) {} 93 }; 94 95 } // namespace libtextclassifier3 96 #endif // LIBTEXTCLASSIFIER_ANNOTATOR_GRAMMAR_DATES_ANNOTATIONS_ANNOTATION_OPTIONS_H_ 97