• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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// Meridiem field.
18namespace libtextclassifier3.grammar.datetime;
19enum Meridiem : int {
20  UNKNOWN = 0,
21
22  // Ante meridiem: Before noon
23  AM = 1,
24
25  // Post meridiem: After noon
26  PM = 2,
27}
28
29// Enum represents a unit of date and time in the expression.
30// Next field: 10
31namespace libtextclassifier3.grammar.datetime;
32enum ComponentType : int {
33  UNSPECIFIED = 0,
34
35  // Year of the date seen in the text match.
36  YEAR = 1,
37
38  // Month of the year starting with January = 1.
39  MONTH = 2,
40
41  // Week (7 days).
42  WEEK = 3,
43
44  // Day of week, start of the week is Sunday &  its value is 1.
45  DAY_OF_WEEK = 4,
46
47  // Day of the month starting with 1.
48  DAY_OF_MONTH = 5,
49
50  // Hour of the day.
51  HOUR = 6,
52
53  // Minute of the hour with a range of 0-59.
54  MINUTE = 7,
55
56  // Seconds of the minute with a range of 0-59.
57  SECOND = 8,
58
59  // Meridiem field i.e. AM/PM.
60  MERIDIEM = 9,
61}
62
63namespace libtextclassifier3.grammar.datetime;
64table TimeZone {
65  // Offset from UTC/GTM in minutes.
66  utc_offset_mins:int;
67}
68
69namespace libtextclassifier3.grammar.datetime.RelativeDatetimeComponent_;
70enum Modifier : int {
71  UNSPECIFIED = 0,
72  NEXT = 1,
73  THIS = 2,
74  LAST = 3,
75  NOW = 4,
76  TOMORROW = 5,
77  YESTERDAY = 6,
78  PAST = 7,
79  FUTURE = 8,
80}
81
82// Message for representing the relative date-time component in date-time
83// expressions.
84// Next field: 4
85namespace libtextclassifier3.grammar.datetime;
86table RelativeDatetimeComponent {
87  component_type:ComponentType = UNSPECIFIED;
88  modifier:RelativeDatetimeComponent_.Modifier = UNSPECIFIED;
89  value:int;
90}
91
92// AbsoluteDateTime represents date-time expressions that is not ambiguous.
93// Next field: 11
94namespace libtextclassifier3.grammar.datetime;
95table AbsoluteDateTime {
96  // Year value of the date seen in the text match.
97  year:int = -1;
98
99  // Month value of the year starting with January = 1.
100  month:int = -1;
101
102  // Day value of the month starting with 1.
103  day:int = -1;
104
105  // Day of week, start of the week is Sunday and its value is 1.
106  week_day:int = -1;
107
108  // Hour value of the day.
109  hour:int = -1;
110
111  // Minute value of the hour with a range of 0-59.
112  minute:int = -1;
113
114  // Seconds value of the minute with a range of 0-59.
115  second:int = -1;
116
117  partial_second:double = -1;
118
119  // Meridiem field i.e. AM/PM.
120  meridiem:Meridiem;
121
122  time_zone:TimeZone;
123}
124
125// Message to represent relative datetime expressions.
126// It encode expressions
127// - Where modifier such as before/after shift the date e.g.[three days ago],
128// [2 days after March 1st].
129// - When prefix make the expression relative e.g. [next weekend],
130// [last Monday].
131// Next field: 3
132namespace libtextclassifier3.grammar.datetime;
133table RelativeDateTime {
134  relative_datetime_component:[RelativeDatetimeComponent];
135
136  // The base could be an absolute datetime point for example: "March 1", a
137  // relative datetime point, for example: "2 days before March 1"
138  base:AbsoluteDateTime;
139}
140
141// Datetime result.
142namespace libtextclassifier3.grammar.datetime;
143table UngroundedDatetime {
144  absolute_datetime:AbsoluteDateTime;
145  relative_datetime:RelativeDateTime;
146
147  // The annotation usecases.
148  // There are two modes.
149  // 1- SMART - Datetime results which are optimized for Smart select
150  // 2- RAW - Results are optimized for where annotates as much as possible.
151  annotation_usecases:uint = 4294967295;
152}
153
154