mirror of
https://github.com/facebook/duckling.git
synced 2024-11-29 09:54:49 +03:00
tt helper for returning Time Tokens
Summary: This is a very common pattern (>1k occurrences). Replacing it with something shorter makes the rules a bit less boilerplate-y. Feel free to bikeshed the name, I can easily redo the codemod. Reviewed By: patapizza Differential Revision: D4848864 fbshipit-source-id: 7baeee3
This commit is contained in:
parent
f46539ced2
commit
1cf8496967
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ ruleIntersect = Rule
|
||||
, Predicate isNotLatent
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) -> Just . Token Time $ intersect (td1, td2)
|
||||
(Token Time td1:Token Time td2:_) -> tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ ruleIntersectOf = Rule
|
||||
, Predicate isNotLatent
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) -> Just . Token Time $ intersect (td1, td2)
|
||||
(Token Time td1:_:Token Time td2:_) -> tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ ruleInstants = map go instants
|
||||
go (name, regexPattern, grain, n) = Rule
|
||||
{ name = name
|
||||
, pattern = [regex regexPattern]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth grain n
|
||||
, prod = \_ -> tt $ cycleNth grain n
|
||||
}
|
||||
|
||||
ruleNextDOW :: Rule
|
||||
@ -133,7 +133,7 @@ ruleNextDOW = Rule
|
||||
, Predicate isADayOfWeek
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ predNth 0 True td
|
||||
(_:Token Time td:_) -> tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ ruleThisTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ predNth 0 False td
|
||||
(_:Token Time td:_) -> tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ ruleNextTime = Rule
|
||||
, Predicate isNotLatent
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ predNth 0 True td
|
||||
(_:Token Time td:_) -> tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ ruleLastTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ predNth (- 1) False td
|
||||
(_:Token Time td:_) -> tt $ predNth (- 1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ ruleTimeBeforeLastAfterNext = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token RegexMatch (GroupMatch (match:_)):_) ->
|
||||
Just . Token Time $ predNth 1 (match == "after next") td
|
||||
tt $ predNth 1 (match == "after next") td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ ruleLastDOWOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ predLastOf td1 td2
|
||||
tt $ predLastOf td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ ruleLastCycleOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleLastOf grain td
|
||||
tt $ cycleLastOf grain td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Just . Token Time .
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -242,7 +242,7 @@ ruleTheNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Just . Token Time .
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -258,7 +258,7 @@ ruleNthTimeAfterTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ predNthAfter (TOrdinal.value od - 1) td1 td2
|
||||
tt $ predNthAfter (TOrdinal.value od - 1) td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ ruleTheNthTimeAfterTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ predNthAfter (TOrdinal.value od - 1) td1 td2
|
||||
tt $ predNthAfter (TOrdinal.value od - 1) td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ ruleYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ year n
|
||||
tt $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ ruleYearPastLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ ruleYearFutureLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ ruleDOMLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth n
|
||||
tt . mkLatent $ dayOfMonth n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ ruleTheDOMNumeral = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth n
|
||||
tt . mkLatent $ dayOfMonth n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ ruleTheDOMOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:
|
||||
Token Ordinal (OrdinalData {TOrdinal.value = v}):
|
||||
_) -> Just . Token Time $ dayOfMonth v
|
||||
_) -> tt $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ ruleDOMOrdinalMonthYear = Rule
|
||||
(token:Token Time td:Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||
intVal <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
Just . Token Time $ intersect (dom, year intVal)
|
||||
tt $ intersect (dom, year intVal)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ ruleIdesOfMonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
Just . Token Time $
|
||||
tt $
|
||||
intersect (td, dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -439,7 +439,7 @@ ruleTODLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ hour True n
|
||||
tt . mkLatent $ hour True n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ ruleAtTOD = Rule
|
||||
, Predicate isATimeOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -463,7 +463,7 @@ ruleTODOClock = Rule
|
||||
, regex "o.?clock"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -475,7 +475,7 @@ ruleHHMM = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time $ hourMinute True h m
|
||||
tt $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ ruleHHMMLatent = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time . mkLatent $ hourMinute True h m
|
||||
tt . mkLatent $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -502,7 +502,7 @@ ruleHHMMSS = Rule
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
s <- parseInt ss
|
||||
Just . Token Time $ hourMinuteSecond True h m s
|
||||
tt $ hourMinuteSecond True h m s
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ ruleMilitaryAMPM = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):Token RegexMatch (GroupMatch (ap:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time . timeOfDayAMPM (hourMinute True h m) $
|
||||
tt . timeOfDayAMPM (hourMinute True h m) $
|
||||
Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -531,7 +531,7 @@ ruleTODAMPM = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token RegexMatch (GroupMatch (_:ap:_)):_) ->
|
||||
Just . Token Time . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
tt . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@ ruleHONumeral = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ ruleHODHalf = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 30
|
||||
tt $ hourMinute is12H hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -573,7 +573,7 @@ ruleHODQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 15
|
||||
tt $ hourMinute is12H hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -679,7 +679,7 @@ ruleMMDDYYYY = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -692,7 +692,7 @@ ruleYYYYMMDD = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -704,7 +704,7 @@ ruleMMDD = Rule
|
||||
(Token RegexMatch (GroupMatch (mm:dd:_)):_) -> do
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ ruleNoonMidnightEOD = Rule
|
||||
{ name = "noon|midnight|EOD|end of day"
|
||||
, pattern = [regex "(noon|midni(ght|te)|(the )?(EOD|end of (the )?day))"]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) -> Just . Token Time . hour False $
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) -> tt . hour False $
|
||||
if match == "noon" then 12 else 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -731,7 +731,7 @@ rulePartOfDays = Rule
|
||||
"lunch" -> (hour False 12, hour False 14)
|
||||
"at lunch" -> (hour False 12, hour False 14)
|
||||
_ -> (hour False 12, hour False 19)
|
||||
in Just . Token Time . partOfDay $ mkLatent td
|
||||
in tt . partOfDay $ mkLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ ruleEarlyMorning = Rule
|
||||
, pattern =
|
||||
[ regex "early ((in|hours of) the )?morning"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . partOfDay . mkLatent $
|
||||
, prod = \_ -> tt . partOfDay . mkLatent $
|
||||
interval TTime.Open (hour False 4, hour False 9)
|
||||
}
|
||||
|
||||
@ -753,7 +753,7 @@ rulePODIn = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ rulePODThis = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time . partOfDay . notLatent $
|
||||
(_:Token Time td:_) -> tt . partOfDay . notLatent $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -777,7 +777,7 @@ ruleTonight = Rule
|
||||
, prod = \_ ->
|
||||
let today = cycleNth TG.Day 0
|
||||
evening = interval TTime.Open (hour False 18, hour False 0) in
|
||||
Just . Token Time . partOfDay . notLatent $ intersect (today, evening)
|
||||
tt . partOfDay . notLatent $ intersect (today, evening)
|
||||
}
|
||||
|
||||
ruleAfterPartofday :: Rule
|
||||
@ -793,7 +793,7 @@ ruleAfterPartofday = Rule
|
||||
"work" -> Just (hour False 17, hour False 21)
|
||||
"school" -> Just (hour False 15, hour False 21)
|
||||
_ -> Nothing
|
||||
Just . Token Time . partOfDay . notLatent $
|
||||
tt . partOfDay . notLatent $
|
||||
intersect (cycleNth TG.Day 0, interval TTime.Open pair)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -807,7 +807,7 @@ ruleTimePOD = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token Time pod:_) -> Just . Token Time $ intersect (pod, td)
|
||||
(Token Time td:Token Time pod:_) -> tt $ intersect (pod, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -820,7 +820,7 @@ rulePODofTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time pod:_:Token Time td:_) -> Just . Token Time $ intersect (pod, td)
|
||||
(Token Time pod:_:Token Time td:_) -> tt $ intersect (pod, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -831,7 +831,7 @@ ruleWeekend = Rule
|
||||
, prod = \_ ->
|
||||
let fri = intersect (dayOfWeek 5, hour False 18)
|
||||
mon = intersect (dayOfWeek 1, hour False 0)
|
||||
in Just . Token Time $ interval TTime.Open (fri, mon)
|
||||
in tt $ interval TTime.Open (fri, mon)
|
||||
}
|
||||
|
||||
ruleSeasons :: Rule
|
||||
@ -854,7 +854,7 @@ ruleSeasons = Rule
|
||||
"winter" -> Just $ monthDay 3 20
|
||||
"spring" -> Just $ monthDay 6 21
|
||||
_ -> Nothing
|
||||
Just . Token Time $ interval TTime.Open (start, end)
|
||||
tt $ interval TTime.Open (start, end)
|
||||
_ -> Nothing
|
||||
|
||||
}
|
||||
@ -867,7 +867,7 @@ ruleTODPrecision = Rule
|
||||
, regex "(sharp|exactly|-?ish|approximately)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -879,7 +879,7 @@ rulePrecisionTOD = Rule
|
||||
, Predicate $ isGrainFinerThan TG.Year
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -902,7 +902,7 @@ ruleIntervalMonthDDDD = Rule
|
||||
dd2 <- parseInt d2
|
||||
let dom1 = intersect (dayOfMonth dd1, td)
|
||||
dom2 = intersect (dayOfMonth dd2, td)
|
||||
in Just . Token Time $ interval TTime.Closed (dom1, dom2)
|
||||
in tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -917,7 +917,7 @@ ruleIntervalDash = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -932,7 +932,7 @@ ruleIntervalFrom = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -947,7 +947,7 @@ ruleIntervalBetween = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -962,7 +962,7 @@ ruleIntervalTODDash = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -977,7 +977,7 @@ ruleIntervalTODFrom = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1003,7 +1003,7 @@ ruleIntervalTODAMPM = Rule
|
||||
td1 = case parseInt mm of
|
||||
Just m -> hourMinute True h m
|
||||
Nothing -> hour True h
|
||||
Just . Token Time $
|
||||
tt $
|
||||
interval TTime.Closed (timeOfDayAMPM td1 ampm, timeOfDayAMPM td2 ampm)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1019,7 +1019,7 @@ ruleIntervalTODBetween = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1032,7 +1032,7 @@ ruleIntervalBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ interval TTime.Open (cycleNth TG.Second 0, td)
|
||||
tt $ interval TTime.Open (cycleNth TG.Second 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1045,7 +1045,7 @@ ruleIntervalByTheEndOf = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (cycleNth TG.Second 0, td)
|
||||
tt $ interval TTime.Closed (cycleNth TG.Second 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1057,7 +1057,7 @@ ruleIntervalUntilTOD = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ withDirection TTime.Before td
|
||||
(_:Token Time td:_) -> tt $ withDirection TTime.Before td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1069,7 +1069,7 @@ ruleIntervalAfterTOD = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ withDirection TTime.After td
|
||||
(_:Token Time td:_) -> tt $ withDirection TTime.After td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1081,7 +1081,7 @@ ruleIntervalSinceTOD = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ withDirection TTime.After td
|
||||
(_:Token Time td:_) -> tt $ withDirection TTime.After td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1102,7 +1102,7 @@ ruleDaysOfWeek = zipWith go daysOfWeek [1..7]
|
||||
go (name, regexPattern) i = Rule
|
||||
{ name = name
|
||||
, pattern = [regex regexPattern]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek i
|
||||
, prod = \_ -> tt $ dayOfWeek i
|
||||
}
|
||||
|
||||
months :: [(Text, String)]
|
||||
@ -1127,7 +1127,7 @@ ruleMonths = zipWith go months [1..12]
|
||||
go (name, regexPattern) i = Rule
|
||||
{ name = name
|
||||
, pattern = [regex regexPattern]
|
||||
, prod = \_ -> Just . Token Time $ month i
|
||||
, prod = \_ -> tt $ month i
|
||||
}
|
||||
|
||||
usHolidays :: [(Text, String, Int, Int)]
|
||||
@ -1147,7 +1147,7 @@ ruleUSHolidays = map go usHolidays
|
||||
go (name, regexPattern, m, d) = Rule
|
||||
{ name = name
|
||||
, pattern = [regex regexPattern]
|
||||
, prod = \_ -> Just . Token Time $ monthDay m d
|
||||
, prod = \_ -> tt $ monthDay m d
|
||||
}
|
||||
|
||||
moreUSHolidays :: [(Text, String, Int, Int, Int)]
|
||||
@ -1184,7 +1184,7 @@ ruleMoreUSHolidays = map go moreUSHolidays
|
||||
go (name, regexPattern, n, dow, m) = Rule
|
||||
{ name = name
|
||||
, pattern = [regex regexPattern]
|
||||
, prod = \_ -> Just . Token Time $ nthDOWOfMonth n dow m
|
||||
, prod = \_ -> tt $ nthDOWOfMonth n dow m
|
||||
}
|
||||
|
||||
-- Last Monday of May
|
||||
@ -1192,7 +1192,7 @@ ruleMemorialDay :: Rule
|
||||
ruleMemorialDay = Rule
|
||||
{ name = "Memorial Day"
|
||||
, pattern = [regex "memorial day"]
|
||||
, prod = \_ -> Just . Token Time $ predLastOf (dayOfWeek 1) (month 5)
|
||||
, prod = \_ -> tt $ predLastOf (dayOfWeek 1) (month 5)
|
||||
}
|
||||
|
||||
-- Long weekend before the last Monday of May
|
||||
@ -1201,7 +1201,7 @@ ruleMemorialDayWeekend = Rule
|
||||
{ name = "Memorial Day Weekend"
|
||||
, pattern = [regex "memorial day week(\\s|-)?end"]
|
||||
, prod = \_ ->
|
||||
Just . Token Time . longWEBefore $ predLastOf (dayOfWeek 1) (month 5)
|
||||
tt . longWEBefore $ predLastOf (dayOfWeek 1) (month 5)
|
||||
}
|
||||
|
||||
-- Long weekend before the first Monday of September
|
||||
@ -1209,7 +1209,7 @@ ruleLaborDayWeekend :: Rule
|
||||
ruleLaborDayWeekend = Rule
|
||||
{ name = "Labor Day weekend"
|
||||
, pattern = [regex "labor day week(\\s|-)?end"]
|
||||
, prod = \_ -> Just . Token Time . longWEBefore $ nthDOWOfMonth 1 1 9
|
||||
, prod = \_ -> tt . longWEBefore $ nthDOWOfMonth 1 1 9
|
||||
}
|
||||
|
||||
ruleCycleThisLastNext :: Rule
|
||||
@ -1222,14 +1222,14 @@ ruleCycleThisLastNext = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):Token TimeGrain grain:_) ->
|
||||
case Text.toLower match of
|
||||
"this" -> Just . Token Time $ cycleNth grain 0
|
||||
"coming" -> Just . Token Time $ cycleNth grain 0
|
||||
"current" -> Just . Token Time $ cycleNth grain 0
|
||||
"last" -> Just . Token Time . cycleNth grain $ - 1
|
||||
"past" -> Just . Token Time . cycleNth grain $ - 1
|
||||
"previous" -> Just . Token Time . cycleNth grain $ - 1
|
||||
"next" -> Just . Token Time $ cycleNth grain 1
|
||||
"the following" -> Just . Token Time $ cycleNth grain 1
|
||||
"this" -> tt $ cycleNth grain 0
|
||||
"coming" -> tt $ cycleNth grain 0
|
||||
"current" -> tt $ cycleNth grain 0
|
||||
"last" -> tt . cycleNth grain $ - 1
|
||||
"past" -> tt . cycleNth grain $ - 1
|
||||
"previous" -> tt . cycleNth grain $ - 1
|
||||
"next" -> tt $ cycleNth grain 1
|
||||
"the following" -> tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1250,7 +1250,7 @@ ruleCycleTheAfterBeforeTime = Rule
|
||||
: Token Time td
|
||||
: _) ->
|
||||
let n = if match == "after" then 1 else - 1 in
|
||||
Just . Token Time $ cycleNthAfter False grain n td
|
||||
tt $ cycleNthAfter False grain n td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1265,7 +1265,7 @@ ruleCycleAfterBeforeTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:Token RegexMatch (GroupMatch (match:_)):Token Time td:_) ->
|
||||
let n = if match == "after" then 1 else - 1 in
|
||||
Just . Token Time $ cycleNthAfter False grain n td
|
||||
tt $ cycleNthAfter False grain n td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1280,7 +1280,7 @@ ruleCycleLastNextN = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):token:Token TimeGrain grain:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . cycleN True grain $ if match == "next" then n else - n
|
||||
tt . cycleN True grain $ if match == "next" then n else - n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1296,7 +1296,7 @@ ruleCycleOrdinalOfTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token TimeGrain grain:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter True grain (n - 1) td
|
||||
tt $ cycleNthAfter True grain (n - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1313,7 +1313,7 @@ ruleCycleTheOrdinalOfTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter True grain (n - 1) td
|
||||
tt $ cycleNthAfter True grain (n - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1328,7 +1328,7 @@ ruleCycleTheOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain 0 td
|
||||
tt $ cycleNthAfter True grain 0 td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1344,7 +1344,7 @@ ruleCycleOrdinalAfterTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token TimeGrain grain:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter True grain (n - 1) td
|
||||
tt $ cycleNthAfter True grain (n - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1361,7 +1361,7 @@ ruleCycleTheOrdinalAfterTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter True grain (n - 1) td
|
||||
tt $ cycleNthAfter True grain (n - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1375,7 +1375,7 @@ ruleCycleOrdinalQuarter = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
tt . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
cycleNth TG.Year 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1391,7 +1391,7 @@ ruleCycleTheOrdinalQuarter = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
tt . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
cycleNth TG.Year 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1407,7 +1407,7 @@ ruleCycleOrdinalQuarterYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter False TG.Quarter (n - 1) td
|
||||
tt $ cycleNthAfter False TG.Quarter (n - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1422,10 +1422,10 @@ ruleDurationInWithinAfter = Rule
|
||||
(Token RegexMatch (GroupMatch (match:_)):
|
||||
Token Duration dd:
|
||||
_) -> case Text.toLower match of
|
||||
"within" -> Just . Token Time $
|
||||
"within" -> tt $
|
||||
interval TTime.Open (cycleNth TG.Second 0, inDuration dd)
|
||||
"after" -> Just . Token Time . withDirection TTime.After $ inDuration dd
|
||||
"in" -> Just . Token Time $ inDuration dd
|
||||
"after" -> tt . withDirection TTime.After $ inDuration dd
|
||||
"in" -> tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1441,8 +1441,8 @@ ruleDurationHenceAgo = Rule
|
||||
(Token Duration dd:
|
||||
Token RegexMatch (GroupMatch (match:_)):
|
||||
_) -> case Text.toLower match of
|
||||
"ago" -> Just . Token Time $ durationAgo dd
|
||||
_ -> Just . Token Time $ inDuration dd
|
||||
"ago" -> tt $ durationAgo dd
|
||||
_ -> tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1455,7 +1455,7 @@ ruleInNumeral = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Numeral (NumeralData {TNumeral.value = v}):_) ->
|
||||
Just . Token Time . inDuration . duration TG.Minute $ floor v
|
||||
tt . inDuration . duration TG.Minute $ floor v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1472,8 +1472,8 @@ ruleDurationAfterBeforeTime = Rule
|
||||
Token RegexMatch (GroupMatch (match:_)):
|
||||
Token Time td:
|
||||
_) -> case Text.toLower match of
|
||||
"before" -> Just . Token Time $ durationBefore dd td
|
||||
_ -> Just . Token Time $ durationAfter dd td
|
||||
"before" -> tt $ durationBefore dd td
|
||||
_ -> tt $ durationAfter dd td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ ruleNamedday = Rule
|
||||
, pattern =
|
||||
[ regex "lunes|lun?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 1
|
||||
, prod = \_ -> tt $ dayOfWeek 1
|
||||
}
|
||||
|
||||
ruleTheDayAfterTomorrow :: Rule
|
||||
@ -43,7 +43,7 @@ ruleTheDayAfterTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "pasado\\s?ma(n|\x00f1)ana"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 2
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 2
|
||||
}
|
||||
|
||||
ruleHaceDuration :: Rule
|
||||
@ -55,7 +55,7 @@ ruleHaceDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time $ durationAgo dd
|
||||
tt $ durationAgo dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ ruleNamedmonth12 = Rule
|
||||
, pattern =
|
||||
[ regex "diciembre|dic\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 12
|
||||
, prod = \_ -> tt $ month 12
|
||||
}
|
||||
|
||||
ruleCeTime :: Rule
|
||||
@ -77,7 +77,7 @@ ruleCeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ ruleNamedday2 = Rule
|
||||
, pattern =
|
||||
[ regex "martes|mar?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 2
|
||||
, prod = \_ -> tt $ dayOfWeek 2
|
||||
}
|
||||
|
||||
ruleThisDayofweek :: Rule
|
||||
@ -99,7 +99,7 @@ ruleThisDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 True td
|
||||
tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ ruleNamedday6 = Rule
|
||||
, pattern =
|
||||
[ regex "s(\x00e1|a)bado|s(\x00e1|a)b\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 6
|
||||
, prod = \_ -> tt $ dayOfWeek 6
|
||||
}
|
||||
|
||||
ruleDatetimeDatetimeInterval :: Rule
|
||||
@ -122,7 +122,7 @@ ruleDatetimeDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Open (td1, td2)
|
||||
tt $ interval TTime.Open (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ ruleNamedmonth7 = Rule
|
||||
, pattern =
|
||||
[ regex "julio|jul\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 7
|
||||
, prod = \_ -> tt $ month 7
|
||||
}
|
||||
|
||||
ruleEvening :: Rule
|
||||
@ -144,7 +144,7 @@ ruleEvening = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 18
|
||||
to = hour False 0
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ ruleDayOfMonthSt = Rule
|
||||
, pattern =
|
||||
[ regex "primero|uno|prem\\.?|1o"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfMonth 1
|
||||
, prod = \_ -> tt $ dayOfMonth 1
|
||||
}
|
||||
|
||||
ruleEnDuration :: Rule
|
||||
@ -166,7 +166,7 @@ ruleEnDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time $ inDuration dd
|
||||
tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ ruleNow = Rule
|
||||
, pattern =
|
||||
[ regex "(hoy)|(en este momento)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 0
|
||||
}
|
||||
|
||||
ruleUltimoDayofweekDeTime :: Rule
|
||||
@ -190,7 +190,7 @@ ruleUltimoDayofweekDeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ predLastOf td1 td2
|
||||
tt $ predLastOf td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ ruleEntreDatetimeEtDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Open (td1, td2)
|
||||
tt $ interval TTime.Open (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ ruleHhhmmTimeofday = Rule
|
||||
(Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
|
||||
h <- parseInt m1
|
||||
m <- parseInt m2
|
||||
Just . Token Time $ hourMinute True h m
|
||||
tt $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ ruleNamedday4 = Rule
|
||||
, pattern =
|
||||
[ regex "jueves|jue|jue\\."
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 4
|
||||
, prod = \_ -> tt $ dayOfWeek 4
|
||||
}
|
||||
|
||||
ruleElDayofmonthDeNamedmonth :: Rule
|
||||
@ -257,7 +257,7 @@ ruleNPasadosCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ ruleElProximoCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 1
|
||||
tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ rulePasadosNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ ruleElDayofmonthNonOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ dayOfMonth v
|
||||
tt $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ ruleSeason4 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 3 20
|
||||
to = monthDay 6 21
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleYearLatent2 :: Rule
|
||||
@ -325,7 +325,7 @@ ruleYearLatent2 = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year v
|
||||
tt . mkLatent $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ ruleNoon = Rule
|
||||
, pattern =
|
||||
[ regex "mediod(\x00ed|i)a"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 12
|
||||
, prod = \_ -> tt $ hour False 12
|
||||
}
|
||||
|
||||
ruleProximasNCycle :: Rule
|
||||
@ -349,7 +349,7 @@ ruleProximasNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ ruleNochevieja = Rule
|
||||
, pattern =
|
||||
[ regex "nochevieja"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 31
|
||||
, prod = \_ -> tt $ monthDay 12 31
|
||||
}
|
||||
|
||||
ruleTheDayBeforeYesterday :: Rule
|
||||
@ -368,7 +368,7 @@ ruleTheDayBeforeYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "anteayer|antes de (ayer|anoche)|antier"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 2
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 2
|
||||
}
|
||||
|
||||
ruleHourofdayMinusIntegerAsRelativeMinutes :: Rule
|
||||
@ -458,7 +458,7 @@ ruleHourofdayIntegerAsRelativeMinutes = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -475,7 +475,7 @@ ruleHourofdayIntegerAsRelativeMinutes2 = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ ruleHourofdayQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 15
|
||||
tt $ hourMinute is12H hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -501,7 +501,7 @@ ruleHourofdayHalf = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 30
|
||||
tt $ hourMinute is12H hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ ruleHourofdayThreeQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 45
|
||||
tt $ hourMinute is12H hours 45
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ ruleHourofdayAndRelativeMinutes = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -551,7 +551,7 @@ ruleHourofdayAndRelativeMinutes2 = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -564,7 +564,7 @@ ruleHourofdayAndQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 15
|
||||
tt $ hourMinute is12H hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -577,7 +577,7 @@ ruleHourofdayAndHalf = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 30
|
||||
tt $ hourMinute is12H hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ ruleHourofdayAndThreeQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:_) ->
|
||||
Just . Token Time $ hourMinute is12H hours 45
|
||||
tt $ hourMinute is12H hours 45
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -600,7 +600,7 @@ ruleNamedmonth = Rule
|
||||
, pattern =
|
||||
[ regex "enero|ene\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 1
|
||||
, prod = \_ -> tt $ month 1
|
||||
}
|
||||
|
||||
ruleInThePartofday :: Rule
|
||||
@ -612,7 +612,7 @@ ruleInThePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -626,7 +626,7 @@ ruleDelYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ ruleNamedmonth3 = Rule
|
||||
, pattern =
|
||||
[ regex "marzo|mar\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 3
|
||||
, prod = \_ -> tt $ month 3
|
||||
}
|
||||
|
||||
ruleDdmm :: Rule
|
||||
@ -649,7 +649,7 @@ ruleDdmm = Rule
|
||||
(Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
|
||||
d <- parseInt m1
|
||||
m <- parseInt m2
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -662,7 +662,7 @@ ruleAfternoon = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 12
|
||||
to = hour False 19
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -672,7 +672,7 @@ ruleNamedmonth4 = Rule
|
||||
, pattern =
|
||||
[ regex "abril|abr\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 4
|
||||
, prod = \_ -> tt $ month 4
|
||||
}
|
||||
|
||||
ruleMidnight :: Rule
|
||||
@ -681,7 +681,7 @@ ruleMidnight = Rule
|
||||
, pattern =
|
||||
[ regex "medianoche"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 0
|
||||
, prod = \_ -> tt $ hour False 0
|
||||
}
|
||||
|
||||
ruleAnoNuevo :: Rule
|
||||
@ -690,7 +690,7 @@ ruleAnoNuevo = Rule
|
||||
, pattern =
|
||||
[ regex "a(n|\x00f1)o nuevo"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 1 1
|
||||
, prod = \_ -> tt $ monthDay 1 1
|
||||
}
|
||||
|
||||
ruleNamedday5 :: Rule
|
||||
@ -699,7 +699,7 @@ ruleNamedday5 = Rule
|
||||
, pattern =
|
||||
[ regex "viernes|vie|vie\\."
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 5
|
||||
, prod = \_ -> tt $ dayOfWeek 5
|
||||
}
|
||||
|
||||
ruleDdddMonthinterval :: Rule
|
||||
@ -723,7 +723,7 @@ ruleDdddMonthinterval = Rule
|
||||
d2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth d1, td)
|
||||
to = intersect (dayOfMonth d2, td)
|
||||
Just . Token Time $ interval TTime.Closed (from, to)
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -736,7 +736,7 @@ ruleTimeofdayLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ hour True v
|
||||
tt . mkLatent $ hour True v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -746,7 +746,7 @@ ruleNamedmonth2 = Rule
|
||||
, pattern =
|
||||
[ regex "febrero|feb\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 2
|
||||
, prod = \_ -> tt $ month 2
|
||||
}
|
||||
|
||||
ruleNamedmonthnameddayPast :: Rule
|
||||
@ -758,7 +758,7 @@ ruleNamedmonthnameddayPast = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -771,7 +771,7 @@ ruleSeason3 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 12 21
|
||||
to = monthDay 3 20
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleSeason :: Rule
|
||||
@ -783,7 +783,7 @@ ruleSeason = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 6 21
|
||||
to = monthDay 9 23
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleRightNow :: Rule
|
||||
@ -792,7 +792,7 @@ ruleRightNow = Rule
|
||||
, pattern =
|
||||
[ regex "ahor(it)?a|ya|en\\s?seguida|cuanto antes"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Second 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Second 0
|
||||
}
|
||||
|
||||
ruleDimTimeDeLaTarde :: Rule
|
||||
@ -805,7 +805,7 @@ ruleDimTimeDeLaTarde = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
let tarde = interval TTime.Open (hour False 12, hour False 21)
|
||||
in Just . Token Time $ intersect (td, mkLatent $ partOfDay tarde)
|
||||
in tt $ intersect (td, mkLatent $ partOfDay tarde)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -819,7 +819,7 @@ ruleIntegerInThePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ ruleNCycleProximoqueViene = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -847,7 +847,7 @@ ruleNamedmonthnameddayNext = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 1 False td
|
||||
tt $ predNth 1 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ ruleIntersect = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -873,7 +873,7 @@ ruleTimeofdayPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -887,7 +887,7 @@ ruleDimTimeDeLaManana = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
let manana = interval TTime.Open (hour False 0, hour False 12)
|
||||
in Just . Token Time $ intersect (td, mkLatent $ partOfDay manana)
|
||||
in tt $ intersect (td, mkLatent $ partOfDay manana)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -902,7 +902,7 @@ ruleDeDatetimeDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Open (td1, td2)
|
||||
tt $ interval TTime.Open (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -922,7 +922,7 @@ ruleNthTimeDeTime2 = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> Just . Token Time . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -932,7 +932,7 @@ ruleNamedmonth6 = Rule
|
||||
, pattern =
|
||||
[ regex "junio|jun\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 6
|
||||
, prod = \_ -> tt $ month 6
|
||||
}
|
||||
|
||||
ruleDentroDeDuration :: Rule
|
||||
@ -944,7 +944,7 @@ ruleDentroDeDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time $
|
||||
tt $
|
||||
interval TTime.Open (cycleNth TG.Second 0, inDuration dd)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -955,7 +955,7 @@ ruleNamedmonth8 = Rule
|
||||
, pattern =
|
||||
[ regex "agosto|ago\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 8
|
||||
, prod = \_ -> tt $ month 8
|
||||
}
|
||||
|
||||
ruleWeekend :: Rule
|
||||
@ -967,7 +967,7 @@ ruleWeekend = Rule
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleOrdinalQuarterYear :: Rule
|
||||
@ -981,7 +981,7 @@ ruleOrdinalQuarterYear = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal (OrdinalData {TOrdinal.value = v}):_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False TG.Quarter (v - 1) td
|
||||
tt $ cycleNthAfter False TG.Quarter (v - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -996,7 +996,7 @@ ruleYyyymmdd = Rule
|
||||
y <- parseInt m1
|
||||
m <- parseInt m2
|
||||
d <- parseInt m3
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1009,7 +1009,7 @@ ruleTimeofdayHoras = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1019,7 +1019,7 @@ ruleNavidad = Rule
|
||||
, pattern =
|
||||
[ regex "(la )?navidad"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 25
|
||||
, prod = \_ -> tt $ monthDay 12 25
|
||||
}
|
||||
|
||||
ruleElCycleAntesTime :: Rule
|
||||
@ -1033,7 +1033,7 @@ ruleElCycleAntesTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain (-1) td
|
||||
tt $ cycleNthAfter False grain (-1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1047,7 +1047,7 @@ ruleTwoTimeTokensSeparatedBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1060,7 +1060,7 @@ ruleMorning = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 4
|
||||
to = hour False 12
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -1085,7 +1085,7 @@ ruleThisPartofday = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time . partOfDay $
|
||||
(_:Token Time td:_) -> tt . partOfDay $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1100,7 +1100,7 @@ ruleLaCyclePasado = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ - 1
|
||||
tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1113,7 +1113,7 @@ ruleYearLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1123,7 +1123,7 @@ ruleYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "ayer"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 1
|
||||
}
|
||||
|
||||
ruleSeason2 :: Rule
|
||||
@ -1135,7 +1135,7 @@ ruleSeason2 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 9 23
|
||||
to = monthDay 12 21
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleDayofweekDayofmonth :: Rule
|
||||
@ -1159,7 +1159,7 @@ ruleTimeofdayAmpm = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token RegexMatch (GroupMatch (ap:_)):_) ->
|
||||
Just . Token Time . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
tt . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1199,7 +1199,7 @@ ruleEntreDdEtDdMonthinterval = Rule
|
||||
v2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth v1, td)
|
||||
to = intersect (dayOfMonth v2, td)
|
||||
Just . Token Time $ interval TTime.Closed (from, to)
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1221,7 +1221,7 @@ ruleNamedmonth5 = Rule
|
||||
, pattern =
|
||||
[ regex "mayo?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 5
|
||||
, prod = \_ -> tt $ month 5
|
||||
}
|
||||
|
||||
ruleNamedday7 :: Rule
|
||||
@ -1230,7 +1230,7 @@ ruleNamedday7 = Rule
|
||||
, pattern =
|
||||
[ regex "domingo|dom\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 7
|
||||
, prod = \_ -> tt $ dayOfWeek 7
|
||||
}
|
||||
|
||||
ruleElTime :: Rule
|
||||
@ -1254,7 +1254,7 @@ ruleYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1264,7 +1264,7 @@ ruleNamedmonth10 = Rule
|
||||
, pattern =
|
||||
[ regex "octubre|oct\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 10
|
||||
, prod = \_ -> tt $ month 10
|
||||
}
|
||||
|
||||
ruleEsteenUnCycle :: Rule
|
||||
@ -1276,7 +1276,7 @@ ruleEsteenUnCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 0
|
||||
tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1291,7 +1291,7 @@ ruleNProximasCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1305,7 +1305,7 @@ ruleLaPasadoCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ - 1
|
||||
tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1318,7 +1318,7 @@ ruleALasTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1333,7 +1333,7 @@ ruleDdmmyyyy = Rule
|
||||
d <- parseInt m1
|
||||
m <- parseInt m2
|
||||
y <- parseInt m3
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1343,7 +1343,7 @@ ruleNamedmonth11 = Rule
|
||||
, pattern =
|
||||
[ regex "noviembre|nov\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 11
|
||||
, prod = \_ -> tt $ month 11
|
||||
}
|
||||
|
||||
ruleOrdinalQuarter :: Rule
|
||||
@ -1355,7 +1355,7 @@ ruleOrdinalQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal (OrdinalData {TOrdinal.value = v}):_) ->
|
||||
Just . Token Time . cycleNthAfter False TG.Quarter (v - 1)
|
||||
tt . cycleNthAfter False TG.Quarter (v - 1)
|
||||
$ cycleNth TG.Year 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1370,7 +1370,7 @@ ruleElCycleProximoqueViene = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 1
|
||||
tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1385,7 +1385,7 @@ ruleElCycleProximoqueVieneTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain 1 td
|
||||
tt $ cycleNthAfter False grain 1 td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1398,7 +1398,7 @@ ruleDelMedioda = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 12
|
||||
to = hour False 17
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -1408,7 +1408,7 @@ ruleNamedday3 = Rule
|
||||
, pattern =
|
||||
[ regex "mi(e|\x00e9)\\.?(rcoles)?|mx|mier?\\."
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 3
|
||||
, prod = \_ -> tt $ dayOfWeek 3
|
||||
}
|
||||
|
||||
ruleIntersectByDe :: Rule
|
||||
@ -1421,7 +1421,7 @@ ruleIntersectByDe = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1431,7 +1431,7 @@ ruleTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "ma(n|\x00f1)ana"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleNthTimeDeTime :: Rule
|
||||
@ -1448,7 +1448,7 @@ ruleNthTimeDeTime = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> Just . Token Time . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1458,7 +1458,7 @@ ruleNamedmonth9 = Rule
|
||||
, pattern =
|
||||
[ regex "septiembre|sept?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 9
|
||||
, prod = \_ -> tt $ month 9
|
||||
}
|
||||
|
||||
ruleTimezone :: Rule
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ ruleArInn = Rule
|
||||
, pattern =
|
||||
[ regex "ar(\x00fa|u) inn(\x00e9|e)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 2
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 2
|
||||
}
|
||||
|
||||
ruleNamedday :: Rule
|
||||
@ -38,7 +38,7 @@ ruleNamedday = Rule
|
||||
, pattern =
|
||||
[ regex "luai?n|lu\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 1
|
||||
, prod = \_ -> tt $ dayOfWeek 1
|
||||
}
|
||||
|
||||
ruleNollaigNaMban :: Rule
|
||||
@ -47,7 +47,7 @@ ruleNollaigNaMban = Rule
|
||||
, pattern =
|
||||
[ regex "(l(\x00e1|a) |an )?nollaig (bheag|na mban)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 1 6
|
||||
, prod = \_ -> tt $ monthDay 1 6
|
||||
}
|
||||
|
||||
ruleNamedmonth12 :: Rule
|
||||
@ -56,7 +56,7 @@ ruleNamedmonth12 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(na )?nollai?g|nol\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 12
|
||||
, prod = \_ -> tt $ month 12
|
||||
}
|
||||
|
||||
ruleNamedday2 :: Rule
|
||||
@ -65,7 +65,7 @@ ruleNamedday2 = Rule
|
||||
, pattern =
|
||||
[ regex "mh?(\x00e1|a)irt|m(\x00e1|a)?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 2
|
||||
, prod = \_ -> tt $ dayOfWeek 2
|
||||
}
|
||||
|
||||
ruleNamedday6 :: Rule
|
||||
@ -74,7 +74,7 @@ ruleNamedday6 = Rule
|
||||
, pattern =
|
||||
[ regex "sathai?rn|sa\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 6
|
||||
, prod = \_ -> tt $ dayOfWeek 6
|
||||
}
|
||||
|
||||
ruleNamedmonth7 :: Rule
|
||||
@ -83,7 +83,7 @@ ruleNamedmonth7 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?i(\x00fa|u)il|i(\x00fa|u)i\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 7
|
||||
, prod = \_ -> tt $ month 7
|
||||
}
|
||||
|
||||
ruleInniu :: Rule
|
||||
@ -92,7 +92,7 @@ ruleInniu = Rule
|
||||
, pattern =
|
||||
[ regex "inniu"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 0
|
||||
}
|
||||
|
||||
ruleAnOrdinalCycleINdiaidhTime :: Rule
|
||||
@ -107,7 +107,7 @@ ruleAnOrdinalCycleINdiaidhTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ ruleInn = Rule
|
||||
, pattern =
|
||||
[ regex "inn(\x00e9|e)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 1
|
||||
}
|
||||
|
||||
ruleLFhileBrde :: Rule
|
||||
@ -126,7 +126,7 @@ ruleLFhileBrde = Rule
|
||||
, pattern =
|
||||
[ regex "(l(\x00e1|a) )?(fh(e|\x00e9)ile|'?le) bh?r(\x00ed|i)de"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 2 1
|
||||
, prod = \_ -> tt $ monthDay 2 1
|
||||
}
|
||||
|
||||
ruleLFhileVailintn :: Rule
|
||||
@ -135,7 +135,7 @@ ruleLFhileVailintn = Rule
|
||||
, pattern =
|
||||
[ regex "(l(\x00e1|a) )?(fh(e|\x00e9)ile|'?le) vailint(\x00ed|i)n"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 2 14
|
||||
, prod = \_ -> tt $ monthDay 2 14
|
||||
}
|
||||
|
||||
ruleTimeSeo :: Rule
|
||||
@ -147,7 +147,7 @@ ruleTimeSeo = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ ruleTimeSeoChaite = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ ruleTimeSeoChugainn = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 True td
|
||||
tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ ruleNamedday4 = Rule
|
||||
, pattern =
|
||||
[ regex "d(\x00e9|e)ardaoin|d(\x00e9|e)?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 4
|
||||
, prod = \_ -> tt $ dayOfWeek 4
|
||||
}
|
||||
|
||||
ruleAmrach :: Rule
|
||||
@ -192,7 +192,7 @@ ruleAmrach = Rule
|
||||
, pattern =
|
||||
[ regex "am(\x00e1|a)rach"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleYearLatent2 :: Rule
|
||||
@ -204,7 +204,7 @@ ruleYearLatent2 = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ ruleNamedmonth = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(an )?t?ean(\x00e1|a)ir|ean\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 1
|
||||
, prod = \_ -> tt $ month 1
|
||||
}
|
||||
|
||||
ruleNamedmonth3 :: Rule
|
||||
@ -223,7 +223,7 @@ ruleNamedmonth3 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(an )?mh?(\x00e1|a)rta|m(\x00e1|a)r\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 3
|
||||
, prod = \_ -> tt $ month 3
|
||||
}
|
||||
|
||||
ruleOrdinalRithe :: Rule
|
||||
@ -236,7 +236,7 @@ ruleOrdinalRithe = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
tt . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
cycleNth TG.Year 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -252,7 +252,7 @@ ruleAnnaCycleRoimhTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain (-1) td
|
||||
tt $ cycleNthAfter False grain (-1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ ruleCycleShin = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ 1
|
||||
tt . cycleNth grain $ 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ ruleDdmm = Rule
|
||||
(Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
|
||||
m <- parseInt m2
|
||||
d <- parseInt m1
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ ruleNamedmonth4 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(an )?t?aibre(\x00e1|a)i?n|abr\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 4
|
||||
, prod = \_ -> tt $ month 4
|
||||
}
|
||||
|
||||
ruleIGceannCycle :: Rule
|
||||
@ -302,7 +302,7 @@ ruleIGceannCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleN True grain (TOrdinal.value od)
|
||||
tt $ cycleN True grain (TOrdinal.value od)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ ruleAnCycleDeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain 0 td
|
||||
tt $ cycleNthAfter True grain 0 td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ ruleNamedday5 = Rule
|
||||
, pattern =
|
||||
[ regex "h?aoine|ao\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 5
|
||||
, prod = \_ -> tt $ dayOfWeek 5
|
||||
}
|
||||
|
||||
ruleDayofmonthordinalNamedmonth :: Rule
|
||||
@ -352,7 +352,7 @@ ruleIntersectBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ ruleOrdinalRitheYear = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False TG.Quarter (TOrdinal.value od - 1) td
|
||||
tt $ cycleNthAfter False TG.Quarter (TOrdinal.value od - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ ruleCycleInniu = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ ruleNamedmonth2 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(na )?feabhra|fea\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 2
|
||||
, prod = \_ -> tt $ month 2
|
||||
}
|
||||
|
||||
ruleOrdinalCycleINdiaidhTime :: Rule
|
||||
@ -405,7 +405,7 @@ ruleOrdinalCycleINdiaidhTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ ruleAnDayofmonthOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ dayOfMonth n
|
||||
tt $ dayOfMonth n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ ruleIntersect = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -442,7 +442,7 @@ ruleNamedmonth6 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(an )?mh?eith(ea|i)mh|mei\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 6
|
||||
, prod = \_ -> tt $ month 6
|
||||
}
|
||||
|
||||
ruleNamedmonth8 :: Rule
|
||||
@ -451,7 +451,7 @@ ruleNamedmonth8 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(na )?l(\x00fa|u)nasa|l(\x00fa|u)n\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 8
|
||||
, prod = \_ -> tt $ month 8
|
||||
}
|
||||
|
||||
ruleAnOrdinalCycleDeTime :: Rule
|
||||
@ -466,7 +466,7 @@ ruleAnOrdinalCycleDeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -476,7 +476,7 @@ ruleLNaNaithreacha = Rule
|
||||
, pattern =
|
||||
[ regex "l(\x00e1|a) na naithreacha"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ nthDOWOfMonth 2 7 6
|
||||
, prod = \_ -> tt $ nthDOWOfMonth 2 7 6
|
||||
}
|
||||
|
||||
ruleArAmrach :: Rule
|
||||
@ -485,7 +485,7 @@ ruleArAmrach = Rule
|
||||
, pattern =
|
||||
[ regex "ar(\x00fa|u) am(\x00e1|a)rach"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 2
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 2
|
||||
}
|
||||
|
||||
ruleOrdinalCycleDeTime :: Rule
|
||||
@ -499,7 +499,7 @@ ruleOrdinalCycleDeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ ruleYyyymmdd = Rule
|
||||
y <- parseInt m1
|
||||
m <- parseInt m2
|
||||
d <- parseInt m3
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@ ruleAnNollaig = Rule
|
||||
, pattern =
|
||||
[ regex "(l(\x00e1|a) |an )?(nollai?g)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 25
|
||||
, prod = \_ -> tt $ monthDay 12 25
|
||||
}
|
||||
|
||||
ruleOnANamedday :: Rule
|
||||
@ -560,7 +560,7 @@ ruleYearLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ ruleAnois = Rule
|
||||
, pattern =
|
||||
[ regex "anois|(ag an (t-?)?am seo)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Second 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Second 0
|
||||
}
|
||||
|
||||
ruleLFhilePdraig :: Rule
|
||||
@ -579,7 +579,7 @@ ruleLFhilePdraig = Rule
|
||||
, pattern =
|
||||
[ regex "(l(\x00e1|a) )?(fh(e|\x00e9)ile|'?le) ph?(\x00e1|a)draig"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 3 17
|
||||
, prod = \_ -> tt $ monthDay 3 17
|
||||
}
|
||||
|
||||
ruleAnCycleINdiaidhTime :: Rule
|
||||
@ -593,7 +593,7 @@ ruleAnCycleINdiaidhTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain 1 td
|
||||
tt $ cycleNthAfter False grain 1 td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ ruleDayofmonthOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth n
|
||||
tt . mkLatent $ dayOfMonth n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -620,7 +620,7 @@ ruleAnCycleSeo = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 0
|
||||
tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -630,7 +630,7 @@ ruleNamedmonth5 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(na )?bh?ealtaine|bea\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 5
|
||||
, prod = \_ -> tt $ month 5
|
||||
}
|
||||
|
||||
ruleNamedday7 :: Rule
|
||||
@ -639,7 +639,7 @@ ruleNamedday7 = Rule
|
||||
, pattern =
|
||||
[ regex "domhnai?[cg]h|do\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 7
|
||||
, prod = \_ -> tt $ dayOfWeek 7
|
||||
}
|
||||
|
||||
ruleAnDayofmonthNonOrdinal :: Rule
|
||||
@ -652,7 +652,7 @@ ruleAnDayofmonthNonOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth v
|
||||
tt . mkLatent $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -677,7 +677,7 @@ ruleYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -687,7 +687,7 @@ ruleNamedmonth10 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?dh?eireadh f(\x00f3|o)mhair|def?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 10
|
||||
, prod = \_ -> tt $ month 10
|
||||
}
|
||||
|
||||
ruleCycleRoimhTime :: Rule
|
||||
@ -700,7 +700,7 @@ ruleCycleRoimhTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain (-1) td
|
||||
tt $ cycleNthAfter False grain (-1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -727,7 +727,7 @@ ruleDdmmyyyy = Rule
|
||||
y <- parseInt m3
|
||||
m <- parseInt m2
|
||||
d <- parseInt m1
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -737,7 +737,7 @@ ruleNamedmonth11 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?(na )?samh(ain|na)|sam\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 11
|
||||
, prod = \_ -> tt $ month 11
|
||||
}
|
||||
|
||||
ruleAnNamedday :: Rule
|
||||
@ -758,7 +758,7 @@ ruleNamedday3 = Rule
|
||||
, pattern =
|
||||
[ regex "ch?(\x00e9|e)adaoin|c(\x00e9|e)\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 3
|
||||
, prod = \_ -> tt $ dayOfWeek 3
|
||||
}
|
||||
|
||||
ruleCycleINdiaidhTime :: Rule
|
||||
@ -771,7 +771,7 @@ ruleCycleINdiaidhTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain 1 td
|
||||
tt $ cycleNthAfter False grain 1 td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -781,7 +781,7 @@ ruleNamedmonth9 = Rule
|
||||
, pattern =
|
||||
[ regex "(mh?(\x00ed|i) )?mh?e(\x00e1|a)n f(\x00f3|o)mhair|mef?\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 9
|
||||
, prod = \_ -> tt $ month 9
|
||||
}
|
||||
|
||||
ruleDayofmonthordinalNamedmonthYear :: Rule
|
||||
@ -796,7 +796,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
(token:Token Time td:Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||
intVal <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
Just . Token Time $ intersect (dom, year intVal)
|
||||
tt $ intersect (dom, year intVal)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ module Duckling.Time.Helpers
|
||||
, inTimezone, longWEBefore, minute, minutesAfter, minutesBefore, mkLatent
|
||||
, month, monthDay, notLatent, nthDOWOfMonth, partOfDay, predLastOf, predNth
|
||||
, predNthAfter, second, timeOfDayAMPM, withDirection, year, yearMonthDay
|
||||
, tt
|
||||
-- Other
|
||||
, getIntValue
|
||||
) where
|
||||
@ -551,3 +552,7 @@ minutesAfter :: Int -> TimeData -> Maybe TimeData
|
||||
minutesAfter n TimeData {TTime.form = Just (TTime.TimeOfDay (Just h) is12H)} =
|
||||
Just $ hourMinute is12H h n
|
||||
minutesAfter _ _ = Nothing
|
||||
|
||||
-- | Convenience helper to return a time token from a rule
|
||||
tt :: TimeData -> Maybe Token
|
||||
tt = Just . Token Time
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@ ruleLiberationDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xad11\xbcf5\xc808"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 8 15
|
||||
, prod = \_ -> tt $ monthDay 8 15
|
||||
}
|
||||
|
||||
ruleTheDayAfterTomorrow :: Rule
|
||||
@ -56,7 +56,7 @@ ruleTheDayAfterTomorrow = Rule
|
||||
[ regex "(\xb0b4\xc77c)?\xbaa8\xb798"
|
||||
]
|
||||
, prod = \_ ->
|
||||
Just . Token Time . cycleNthAfter False TG.Day 1 $ cycleNth TG.Day 1
|
||||
tt . cycleNthAfter False TG.Day 1 $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleConstitutionDay :: Rule
|
||||
@ -65,7 +65,7 @@ ruleConstitutionDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xc81c\xd5cc\xc808"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 6 17
|
||||
, prod = \_ -> tt $ monthDay 6 17
|
||||
}
|
||||
|
||||
ruleTimeofday4 :: Rule
|
||||
@ -77,7 +77,7 @@ ruleTimeofday4 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ withDirection TTime.Before td
|
||||
tt $ withDirection TTime.Before td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ ruleDay = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ dayOfMonth v
|
||||
tt $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ ruleSinceTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time . withDirection TTime.After $ predNth (- 1) False td
|
||||
tt . withDirection TTime.After $ predNth (- 1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ ruleThisDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ ruleNewYearsDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xc2e0\xc815|\xc124\xb0a0"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 1 1
|
||||
, prod = \_ -> tt $ monthDay 1 1
|
||||
}
|
||||
|
||||
ruleLastTime :: Rule
|
||||
@ -139,7 +139,7 @@ ruleLastTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ ruleDatetimeDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ ruleInDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) ->
|
||||
Just . Token Time $ inDuration dd
|
||||
tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ ruleNow = Rule
|
||||
, pattern =
|
||||
[ regex "\xbc29\xae08|\xc9c0\xae08|\xbc29\xae08|\xb9c9"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Second 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Second 0
|
||||
}
|
||||
|
||||
ruleMonth :: Rule
|
||||
@ -189,7 +189,7 @@ ruleMonth = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ month v
|
||||
tt $ month v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ ruleSeason4 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 3 20
|
||||
to = monthDay 6 21
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleYearLatent2 :: Rule
|
||||
@ -214,7 +214,7 @@ ruleYearLatent2 = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year v
|
||||
tt . mkLatent $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ ruleTimeAfterNext = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 1 True td
|
||||
tt $ predNth 1 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ ruleNoon = Rule
|
||||
, pattern =
|
||||
[ regex "\xc815\xc624"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 12
|
||||
, prod = \_ -> tt $ hour False 12
|
||||
}
|
||||
|
||||
ruleToday :: Rule
|
||||
@ -246,7 +246,7 @@ ruleToday = Rule
|
||||
, pattern =
|
||||
[ regex "\xc624\xb298|\xb2f9\xc77c|\xae08\xc77c"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 0
|
||||
}
|
||||
|
||||
ruleIntegerHourofdayRelativeMinutes :: Rule
|
||||
@ -278,7 +278,7 @@ ruleHourofdayIntegerAsRelativeMinutes = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute True hours n
|
||||
tt $ hourMinute True hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ ruleHourofdayHalfAsRelativeMinutes = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
|
||||
_) -> Just . Token Time $ hourMinute True hours 30
|
||||
_) -> tt $ hourMinute True hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ ruleSeconds = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ second v
|
||||
tt $ second v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ ruleTimeOrdinalCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token Ordinal od:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ ruleTheDayBeforeYesterday = Rule
|
||||
[ regex "(\xc5ca)?\xadf8(\xc81c|\xc7ac)"
|
||||
]
|
||||
, prod = \_ ->
|
||||
Just . Token Time . cycleNthAfter False TG.Day (-1) $ cycleNth TG.Day (-1)
|
||||
tt . cycleNthAfter False TG.Day (-1) $ cycleNth TG.Day (-1)
|
||||
}
|
||||
|
||||
ruleDayofweek :: Rule
|
||||
@ -353,13 +353,13 @@ ruleDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) -> case match of
|
||||
"\xc6d4" -> Just . Token Time $ dayOfWeek 1
|
||||
"\xd654" -> Just . Token Time $ dayOfWeek 2
|
||||
"\xc218" -> Just . Token Time $ dayOfWeek 3
|
||||
"\xbaa9" -> Just . Token Time $ dayOfWeek 4
|
||||
"\xae08" -> Just . Token Time $ dayOfWeek 5
|
||||
"\xd1a0" -> Just . Token Time $ dayOfWeek 6
|
||||
"\xc77c" -> Just . Token Time $ dayOfWeek 7
|
||||
"\xc6d4" -> tt $ dayOfWeek 1
|
||||
"\xd654" -> tt $ dayOfWeek 2
|
||||
"\xc218" -> tt $ dayOfWeek 3
|
||||
"\xbaa9" -> tt $ dayOfWeek 4
|
||||
"\xae08" -> tt $ dayOfWeek 5
|
||||
"\xd1a0" -> tt $ dayOfWeek 6
|
||||
"\xc77c" -> tt $ dayOfWeek 7
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -373,7 +373,7 @@ ruleNextCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 1
|
||||
tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -397,7 +397,7 @@ ruleTimeofdayApproximately = Rule
|
||||
, regex "\xc815\xb3c4|\xcbe4"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ ruleDurationFromNow = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) ->
|
||||
Just . Token Time $ inDuration dd
|
||||
tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ ruleLunch = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 12
|
||||
to = hour False 14
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@ ruleLastCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ - 1
|
||||
tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ ruleAfternoon = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 12
|
||||
to = hour False 19
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ ruleChristmasEve = Rule
|
||||
, pattern =
|
||||
[ regex "(\xd06c\xb9ac\xc2a4\xb9c8\xc2a4)?\xc774\xbe0c"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 24
|
||||
, prod = \_ -> tt $ monthDay 12 24
|
||||
}
|
||||
|
||||
ruleInduringThePartofday :: Rule
|
||||
@ -471,7 +471,7 @@ ruleInduringThePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -485,7 +485,7 @@ ruleIntersectBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -499,7 +499,7 @@ ruleMmdd = Rule
|
||||
(Token RegexMatch (GroupMatch (mm:dd:_)):_) -> do
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ ruleAfterDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) ->
|
||||
Just . Token Time . withDirection TTime.After $ inDuration dd
|
||||
tt . withDirection TTime.After $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ ruleTimeofdayLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ hour True v
|
||||
tt . mkLatent $ hour True v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -537,7 +537,7 @@ ruleExactlyTimeofday = Rule
|
||||
, regex "\xc815\xac01"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ ruleSeason3 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 12 21
|
||||
to = monthDay 3 20
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleSeason :: Rule
|
||||
@ -562,7 +562,7 @@ ruleSeason = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 6 21
|
||||
to = monthDay 9 23
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleDayWithKoreanNumeral :: Rule
|
||||
@ -588,7 +588,7 @@ ruleDayWithKoreanNumeral = Rule
|
||||
"\xd314" -> 8
|
||||
"\xad6c" -> 9
|
||||
_ -> 1
|
||||
in Just . Token Time . dayOfMonth $ 10 * dozens + units
|
||||
in tt . dayOfMonth $ 10 * dozens + units
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -600,15 +600,15 @@ ruleDayWithKoreanNumeral2 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) -> case match of
|
||||
"\xc77c" -> Just . Token Time $ dayOfMonth 1
|
||||
"\xc774" -> Just . Token Time $ dayOfMonth 2
|
||||
"\xc0bc" -> Just . Token Time $ dayOfMonth 3
|
||||
"\xc0ac" -> Just . Token Time $ dayOfMonth 4
|
||||
"\xc624" -> Just . Token Time $ dayOfMonth 5
|
||||
"\xc721" -> Just . Token Time $ dayOfMonth 6
|
||||
"\xce60" -> Just . Token Time $ dayOfMonth 7
|
||||
"\xd314" -> Just . Token Time $ dayOfMonth 8
|
||||
"\xad6c" -> Just . Token Time $ dayOfMonth 9
|
||||
"\xc77c" -> tt $ dayOfMonth 1
|
||||
"\xc774" -> tt $ dayOfMonth 2
|
||||
"\xc0bc" -> tt $ dayOfMonth 3
|
||||
"\xc0ac" -> tt $ dayOfMonth 4
|
||||
"\xc624" -> tt $ dayOfMonth 5
|
||||
"\xc721" -> tt $ dayOfMonth 6
|
||||
"\xce60" -> tt $ dayOfMonth 7
|
||||
"\xd314" -> tt $ dayOfMonth 8
|
||||
"\xad6c" -> tt $ dayOfMonth 9
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -622,7 +622,7 @@ ruleTimeofday2 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -635,7 +635,7 @@ ruleDurationAgo = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) ->
|
||||
Just . Token Time $ durationAgo dd
|
||||
tt $ durationAgo dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -650,7 +650,7 @@ ruleLastNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -666,7 +666,7 @@ ruleTimeNthTime = Rule
|
||||
(Token Time td1:
|
||||
Token Ordinal (OrdinalData {TOrdinal.value = v}):
|
||||
Token Time td2:
|
||||
_) -> Just . Token Time . predNth (v - 1) False $ intersect (td1, td2)
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -681,7 +681,7 @@ ruleWithinDuration = Rule
|
||||
(Token Duration dd:_) ->
|
||||
let from = cycleNth TG.Second 0
|
||||
to = inDuration dd
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ ruleMidnighteodendOfDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xc790\xc815"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 0
|
||||
, prod = \_ -> tt $ hour False 0
|
||||
}
|
||||
|
||||
ruleIntersect :: Rule
|
||||
@ -703,7 +703,7 @@ ruleIntersect = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ ruleAboutTimeofday = Rule
|
||||
, Predicate isATimeOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ ruleEndOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 1 False td
|
||||
tt $ predNth 1 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -754,7 +754,7 @@ ruleWeekend = Rule
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleTimeDayofweek :: Rule
|
||||
@ -767,7 +767,7 @@ ruleTimeDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ predLastOf td2 td1
|
||||
tt $ predLastOf td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ ruleNextTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 True td
|
||||
tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -806,7 +806,7 @@ ruleTimeCycle2 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleLastOf grain td
|
||||
tt $ cycleLastOf grain td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -821,7 +821,7 @@ ruleYyyymmdd = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -836,7 +836,7 @@ ruleNextNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -849,7 +849,7 @@ ruleMorning = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 4
|
||||
to = hour False 12
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -862,7 +862,7 @@ ruleThisCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 0
|
||||
tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ ruleThisTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -888,7 +888,7 @@ ruleTimeofday3 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -898,7 +898,7 @@ ruleMemorialDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xd604\xcda9\xc77c"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 6 6
|
||||
, prod = \_ -> tt $ monthDay 6 6
|
||||
}
|
||||
|
||||
ruleYearLatent :: Rule
|
||||
@ -910,7 +910,7 @@ ruleYearLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year v
|
||||
tt . mkLatent $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -920,7 +920,7 @@ ruleYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "\xc5b4\xc81c"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 1
|
||||
}
|
||||
|
||||
ruleSeason2 :: Rule
|
||||
@ -932,7 +932,7 @@ ruleSeason2 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 9 23
|
||||
to = monthDay 12 21
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleAfterTimeofday :: Rule
|
||||
@ -944,7 +944,7 @@ ruleAfterTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time . notLatent $ withDirection TTime.After td
|
||||
tt . notLatent $ withDirection TTime.After td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -954,7 +954,7 @@ ruleChristmas = Rule
|
||||
, pattern =
|
||||
[ regex "\xd06c\xb9ac\xc2a4\xb9c8\xc2a4"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 25
|
||||
, prod = \_ -> tt $ monthDay 12 25
|
||||
}
|
||||
|
||||
ruleTimeofdayAmpm :: Rule
|
||||
@ -966,7 +966,7 @@ ruleTimeofdayAmpm = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token RegexMatch (GroupMatch (_:ap:_)):_) ->
|
||||
Just . Token Time . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
tt . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -980,7 +980,7 @@ ruleTimeCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleLastOf grain td
|
||||
tt $ cycleLastOf grain td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -997,7 +997,7 @@ ruleAfterPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1011,7 +1011,7 @@ ruleTimeofday = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ hour True v
|
||||
tt $ hour True v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1021,7 +1021,7 @@ ruleHangulDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xd55c\xae00\xb0a0"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 10 9
|
||||
, prod = \_ -> tt $ monthDay 10 9
|
||||
}
|
||||
|
||||
ruleHhmm :: Rule
|
||||
@ -1034,7 +1034,7 @@ ruleHhmm = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time $ hourMinute True h m
|
||||
tt $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1049,7 +1049,7 @@ ruleYearQuarter = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter False TG.Quarter (v - 1) td
|
||||
tt $ cycleNthAfter False TG.Quarter (v - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1062,7 +1062,7 @@ ruleYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,7 @@ ruleChildrensDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xc5b4\xb9b0\xc774\xb0a0"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 5 5
|
||||
, prod = \_ -> tt $ monthDay 5 5
|
||||
}
|
||||
|
||||
ruleAbsorptionOfAfterNamedDay :: Rule
|
||||
@ -1095,7 +1095,7 @@ ruleByTime = Rule
|
||||
, regex "\xae4c\xc9c0"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $
|
||||
(Token Time td:_) -> tt $
|
||||
interval TTime.Open (cycleNth TG.Second 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1111,7 +1111,7 @@ ruleHhmmMilitaryAmpm = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):Token RegexMatch (GroupMatch (ap:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time . timeOfDayAMPM (hourMinute True h m) $
|
||||
tt . timeOfDayAMPM (hourMinute True h m) $
|
||||
Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1126,7 +1126,7 @@ ruleQuarter = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . cycleNthAfter False TG.Quarter (v - 1) $
|
||||
tt . cycleNthAfter False TG.Quarter (v - 1) $
|
||||
cycleNth TG.Year 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1141,7 +1141,7 @@ ruleTimeofdayTimeofdayInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1151,7 +1151,7 @@ ruleNationalFoundationDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xac1c\xcc9c\xc808"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 10 3
|
||||
, prod = \_ -> tt $ monthDay 10 3
|
||||
}
|
||||
|
||||
ruleEveningnight :: Rule
|
||||
@ -1163,7 +1163,7 @@ ruleEveningnight = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 18
|
||||
to = hour False 0
|
||||
in Just . Token Time . partOfDay . mkLatent $
|
||||
in tt . partOfDay . mkLatent $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -1173,7 +1173,7 @@ ruleIndependenceMovementDay = Rule
|
||||
, pattern =
|
||||
[ regex "\xc0bc\xc77c\xc808"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 3 1
|
||||
, prod = \_ -> tt $ monthDay 3 1
|
||||
}
|
||||
|
||||
ruleMmddyyyy :: Rule
|
||||
@ -1187,7 +1187,7 @@ ruleMmddyyyy = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1197,7 +1197,7 @@ ruleTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "\xb0b4\xc77c|\xba85\xc77c|\xb0bc"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleAmpmTimeofday :: Rule
|
||||
@ -1210,7 +1210,7 @@ ruleAmpmTimeofday = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):
|
||||
Token Time td:
|
||||
_) -> Just . Token Time . timeOfDayAMPM td $
|
||||
_) -> tt . timeOfDayAMPM td $
|
||||
elem match ["\xc624\xc804", "\xc544\xce68"]
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1225,7 +1225,7 @@ ruleYear2 = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1240,7 +1240,7 @@ ruleHhmmss = Rule
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
s <- parseInt ss
|
||||
Just . Token Time $ hourMinuteSecond True h m s
|
||||
tt $ hourMinuteSecond True h m s
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@ ruleNamedday = Rule
|
||||
, pattern =
|
||||
[ regex "segunda((\\s|\\-)feira)?|seg\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 1
|
||||
, prod = \_ -> tt $ dayOfWeek 1
|
||||
}
|
||||
|
||||
ruleSHourmintimeofday :: Rule
|
||||
@ -53,7 +53,7 @@ ruleTheDayAfterTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "depois de amanh(\x00e3|a)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 2
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 2
|
||||
}
|
||||
|
||||
ruleNamedmonth12 :: Rule
|
||||
@ -62,7 +62,7 @@ ruleNamedmonth12 = Rule
|
||||
, pattern =
|
||||
[ regex "dezembro|dez\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 12
|
||||
, prod = \_ -> tt $ month 12
|
||||
}
|
||||
|
||||
ruleNamedday2 :: Rule
|
||||
@ -71,7 +71,7 @@ ruleNamedday2 = Rule
|
||||
, pattern =
|
||||
[ regex "ter(\x00e7|c)a((\\s|\\-)feira)?|ter\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 2
|
||||
, prod = \_ -> tt $ dayOfWeek 2
|
||||
}
|
||||
|
||||
ruleNatal :: Rule
|
||||
@ -80,7 +80,7 @@ ruleNatal = Rule
|
||||
, pattern =
|
||||
[ regex "natal"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 25
|
||||
, prod = \_ -> tt $ monthDay 12 25
|
||||
}
|
||||
|
||||
ruleNaoDate :: Rule
|
||||
@ -91,7 +91,7 @@ ruleNaoDate = Rule
|
||||
, Predicate $ isGrainOfTime TG.Day
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ ruleIntersectByDaOrDe = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ rulePassadosNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ ruleLastTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ ruleNamedday6 = Rule
|
||||
, pattern =
|
||||
[ regex "s(\x00e1|a)bado|s(\x00e1|a)b\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 6
|
||||
, prod = \_ -> tt $ dayOfWeek 6
|
||||
}
|
||||
|
||||
ruleDatetimeDatetimeInterval :: Rule
|
||||
@ -156,7 +156,7 @@ ruleDatetimeDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Open (td1, td2)
|
||||
tt $ interval TTime.Open (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ ruleNamedmonth7 = Rule
|
||||
, pattern =
|
||||
[ regex "julho|jul\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 7
|
||||
, prod = \_ -> tt $ month 7
|
||||
}
|
||||
|
||||
ruleEvening :: Rule
|
||||
@ -178,7 +178,7 @@ ruleEvening = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 18
|
||||
to = hour False 0
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ ruleDayOfMonthSt = Rule
|
||||
, pattern =
|
||||
[ regex "primeiro|um|1o"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfMonth 1
|
||||
, prod = \_ -> tt $ dayOfMonth 1
|
||||
}
|
||||
|
||||
ruleNow :: Rule
|
||||
@ -197,7 +197,7 @@ ruleNow = Rule
|
||||
, pattern =
|
||||
[ regex "(hoje)|(neste|nesse) momento"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 0
|
||||
}
|
||||
|
||||
ruleDimTimeDaMadrugada :: Rule
|
||||
@ -211,7 +211,7 @@ ruleDimTimeDaMadrugada = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 1, hour False 4)
|
||||
in Just . Token Time $ intersect (td, td2)
|
||||
in tt $ intersect (td, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ ruleHhhmmTimeofday = Rule
|
||||
(Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
|
||||
h <- parseInt m1
|
||||
m <- parseInt m2
|
||||
Just . Token Time $ hourMinute True h m
|
||||
tt $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ ruleNamedday4 = Rule
|
||||
, pattern =
|
||||
[ regex "quinta((\\s|\\-)feira)?|qui\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 4
|
||||
, prod = \_ -> tt $ dayOfWeek 4
|
||||
}
|
||||
|
||||
ruleProximoCycle :: Rule
|
||||
@ -247,7 +247,7 @@ ruleProximoCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 1
|
||||
tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ ruleCycleAntesDeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain (-1) td
|
||||
tt $ cycleNthAfter False grain (-1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ ruleEsteCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 0
|
||||
tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ ruleSHourminTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ ruleSeason4 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 3 20
|
||||
to = monthDay 6 21
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleYearLatent2 :: Rule
|
||||
@ -314,7 +314,7 @@ ruleYearLatent2 = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ ruleNoon = Rule
|
||||
, pattern =
|
||||
[ regex "meio[\\s\\-]?dia"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 12
|
||||
, prod = \_ -> tt $ hour False 12
|
||||
}
|
||||
|
||||
ruleProximasNCycle :: Rule
|
||||
@ -352,7 +352,7 @@ ruleProximasNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ ruleThisnextDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 True td
|
||||
tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ ruleTheDayBeforeYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "anteontem|antes de ontem"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 2
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 2
|
||||
}
|
||||
|
||||
ruleHourofdayIntegerAsRelativeMinutes :: Rule
|
||||
@ -390,7 +390,7 @@ ruleHourofdayIntegerAsRelativeMinutes = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHourofdayAndRelativeMinutes :: Rule
|
||||
@ -407,7 +407,7 @@ ruleHourofdayAndRelativeMinutes = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleIntegerParaAsHourofdayAsRelativeMinutes :: Rule
|
||||
@ -439,7 +439,7 @@ ruleHourofdayIntegerAsRelativeMinutes2 = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHourofdayAndRelativeMinutes2 :: Rule
|
||||
@ -457,7 +457,7 @@ ruleHourofdayAndRelativeMinutes2 = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleIntegerParaAsHourofdayAsRelativeMinutes2 :: Rule
|
||||
@ -486,7 +486,7 @@ ruleHourofdayQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 15
|
||||
_) -> tt $ hourMinute is12H hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHourofdayAndQuarter :: Rule
|
||||
@ -498,7 +498,7 @@ ruleHourofdayAndQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 15
|
||||
_) -> tt $ hourMinute is12H hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleQuarterParaAsHourofdayAsRelativeMinutes :: Rule
|
||||
@ -522,7 +522,7 @@ ruleHourofdayHalf = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 30
|
||||
_) -> tt $ hourMinute is12H hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHourofdayAndHalf :: Rule
|
||||
@ -534,7 +534,7 @@ ruleHourofdayAndHalf = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 30
|
||||
_) -> tt $ hourMinute is12H hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHalfParaAsHourofdayAsRelativeMinutes :: Rule
|
||||
@ -558,7 +558,7 @@ ruleHourofdayThreeQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 45
|
||||
_) -> tt $ hourMinute is12H hours 45
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHourofdayAndThreeQuarter :: Rule
|
||||
@ -570,7 +570,7 @@ ruleHourofdayAndThreeQuarter = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 45
|
||||
_) -> tt $ hourMinute is12H hours 45
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleThreeQuarterParaAsHourofdayAsRelativeMinutes :: Rule
|
||||
@ -591,7 +591,7 @@ ruleNamedmonth = Rule
|
||||
, pattern =
|
||||
[ regex "janeiro|jan\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 1
|
||||
, prod = \_ -> tt $ month 1
|
||||
}
|
||||
|
||||
ruleTiradentes :: Rule
|
||||
@ -600,7 +600,7 @@ ruleTiradentes = Rule
|
||||
, pattern =
|
||||
[ regex "tiradentes"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 4 21
|
||||
, prod = \_ -> tt $ monthDay 4 21
|
||||
}
|
||||
|
||||
ruleInThePartofday :: Rule
|
||||
@ -612,7 +612,7 @@ ruleInThePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -625,7 +625,7 @@ rulePartofdayDessaSemana = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -635,7 +635,7 @@ ruleNamedmonth3 = Rule
|
||||
, pattern =
|
||||
[ regex "mar(\x00e7|c)o|mar\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 3
|
||||
, prod = \_ -> tt $ month 3
|
||||
}
|
||||
|
||||
ruleDepoisDasTimeofday :: Rule
|
||||
@ -647,7 +647,7 @@ ruleDepoisDasTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ withDirection TTime.After td
|
||||
tt $ withDirection TTime.After td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -661,7 +661,7 @@ ruleDdmm = Rule
|
||||
(Token RegexMatch (GroupMatch (dd:mm:_)):_) -> do
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ ruleEmDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time $ inDuration dd
|
||||
tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -687,7 +687,7 @@ ruleAfternoon = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 12
|
||||
to = hour False 19
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -697,7 +697,7 @@ ruleNamedmonth4 = Rule
|
||||
, pattern =
|
||||
[ regex "abril|abr\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 4
|
||||
, prod = \_ -> tt $ month 4
|
||||
}
|
||||
|
||||
ruleDimTimeDaManha :: Rule
|
||||
@ -711,7 +711,7 @@ ruleDimTimeDaManha = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 4, hour False 12)
|
||||
in Just . Token Time $ intersect (td, td2)
|
||||
in tt $ intersect (td, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -726,7 +726,7 @@ ruleNCycleProximoqueVem = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -736,7 +736,7 @@ ruleMidnight = Rule
|
||||
, pattern =
|
||||
[ regex "meia[\\s\\-]?noite"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 0
|
||||
, prod = \_ -> tt $ hour False 0
|
||||
}
|
||||
|
||||
ruleNamedday5 :: Rule
|
||||
@ -745,7 +745,7 @@ ruleNamedday5 = Rule
|
||||
, pattern =
|
||||
[ regex "sexta((\\s|\\-)feira)?|sex\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 5
|
||||
, prod = \_ -> tt $ dayOfWeek 5
|
||||
}
|
||||
|
||||
ruleDdddMonthinterval :: Rule
|
||||
@ -769,7 +769,7 @@ ruleDdddMonthinterval = Rule
|
||||
d2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth d1, td)
|
||||
to = intersect (dayOfMonth d2, td)
|
||||
Just . Token Time $ interval TTime.Closed (from, to)
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -782,7 +782,7 @@ ruleTimeofdayLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ hour True v
|
||||
tt . mkLatent $ hour True v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -795,7 +795,7 @@ ruleUltimoTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -805,7 +805,7 @@ ruleNamedmonth2 = Rule
|
||||
, pattern =
|
||||
[ regex "fevereiro|fev\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 2
|
||||
, prod = \_ -> tt $ month 2
|
||||
}
|
||||
|
||||
ruleNamedmonthnameddayPast :: Rule
|
||||
@ -817,7 +817,7 @@ ruleNamedmonthnameddayPast = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ ruleSeason3 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 12 21
|
||||
to = monthDay 3 20
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleSeason :: Rule
|
||||
@ -842,7 +842,7 @@ ruleSeason = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 6 21
|
||||
to = monthDay 9 23
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleRightNow :: Rule
|
||||
@ -851,7 +851,7 @@ ruleRightNow = Rule
|
||||
, pattern =
|
||||
[ regex "agora|j(\x00e1|a)|(nesse|neste) instante"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Second 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Second 0
|
||||
}
|
||||
|
||||
ruleFazemDuration :: Rule
|
||||
@ -863,7 +863,7 @@ ruleFazemDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time $ durationAgo dd
|
||||
tt $ durationAgo dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ ruleAmanhPelaPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -891,7 +891,7 @@ ruleHhmmMilitaryTimeofday = Rule
|
||||
(Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
|
||||
h <- parseInt m1
|
||||
m <- parseInt m2
|
||||
Just . Token Time . mkLatent $ hourMinute False h m
|
||||
tt . mkLatent $ hourMinute False h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ ruleNamedmonthnameddayNext = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 1 False td
|
||||
tt $ predNth 1 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -917,7 +917,7 @@ ruleIntersect = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -931,7 +931,7 @@ ruleTimeofdayPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -946,7 +946,7 @@ ruleDeDatetimeDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Open (td1, td2)
|
||||
tt $ interval TTime.Open (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -956,7 +956,7 @@ ruleNamedmonth6 = Rule
|
||||
, pattern =
|
||||
[ regex "junho|jun\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 6
|
||||
, prod = \_ -> tt $ month 6
|
||||
}
|
||||
|
||||
ruleDentroDeDuration :: Rule
|
||||
@ -970,7 +970,7 @@ ruleDentroDeDuration = Rule
|
||||
(_:Token Duration dd:_) ->
|
||||
let from = cycleNth TG.Second 0
|
||||
to = inDuration dd
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -983,7 +983,7 @@ ruleSTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -993,7 +993,7 @@ ruleNamedmonth8 = Rule
|
||||
, pattern =
|
||||
[ regex "agosto|ago\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 8
|
||||
, prod = \_ -> tt $ month 8
|
||||
}
|
||||
|
||||
ruleDimTimeDaTarde :: Rule
|
||||
@ -1007,7 +1007,7 @@ ruleDimTimeDaTarde = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 12, hour False 18)
|
||||
in Just . Token Time $ intersect (td, td2)
|
||||
in tt $ intersect (td, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1020,7 +1020,7 @@ ruleWeekend = Rule
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleDayofweekSHourmin :: Rule
|
||||
@ -1036,7 +1036,7 @@ ruleDayofweekSHourmin = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_:Token Time td3:_) ->
|
||||
let td = intersect (td1, td2)
|
||||
in Just . Token Time $ intersect (td, td3)
|
||||
in tt $ intersect (td, td3)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1048,7 +1048,7 @@ ruleCycleQueVem = Rule
|
||||
, regex "que vem|seguintes?"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_) -> Just . Token Time $ cycleNth grain 1
|
||||
(Token TimeGrain grain:_) -> tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1058,7 +1058,7 @@ ruleAnoNovo = Rule
|
||||
, pattern =
|
||||
[ regex "ano novo|reveillon"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 1 1
|
||||
, prod = \_ -> tt $ monthDay 1 1
|
||||
}
|
||||
|
||||
ruleNextTime :: Rule
|
||||
@ -1070,7 +1070,7 @@ ruleNextTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 True td
|
||||
tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1084,7 +1084,7 @@ ruleDeYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ year n
|
||||
tt $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1094,7 +1094,7 @@ ruleVesperaDeAnoNovo = Rule
|
||||
, pattern =
|
||||
[ regex "v(\x00e9|e)spera d[eo] ano[\\s\\-]novo"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 31
|
||||
, prod = \_ -> tt $ monthDay 12 31
|
||||
}
|
||||
|
||||
ruleNPassadosCycle :: Rule
|
||||
@ -1108,7 +1108,7 @@ ruleNPassadosCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1122,7 +1122,7 @@ ruleDiaDayofmonthNonOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth v
|
||||
tt . mkLatent $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1137,7 +1137,7 @@ ruleYyyymmdd = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1150,7 +1150,7 @@ ruleTimeofdayHoras = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1164,7 +1164,7 @@ ruleTwoTimeTokensSeparatedBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1178,7 +1178,7 @@ ruleTwoTimeTokensSeparatedBy2 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td2, td1)
|
||||
tt $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1191,7 +1191,7 @@ ruleMorning = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 4
|
||||
to = hour False 12
|
||||
in Just . Token Time . mkLatent .partOfDay $
|
||||
in tt . mkLatent .partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -1204,7 +1204,7 @@ ruleThisPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1217,7 +1217,7 @@ ruleThisTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1227,7 +1227,7 @@ ruleProclamaoDaRepblica = Rule
|
||||
, pattern =
|
||||
[ regex "proclama(c|\x00e7)(a|\x00e3)o da rep(\x00fa|u)blica"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 11 15
|
||||
, prod = \_ -> tt $ monthDay 11 15
|
||||
}
|
||||
|
||||
ruleYearLatent :: Rule
|
||||
@ -1239,7 +1239,7 @@ ruleYearLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year n
|
||||
tt . mkLatent $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1249,7 +1249,7 @@ ruleYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "ontem"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 1
|
||||
}
|
||||
|
||||
ruleSeason2 :: Rule
|
||||
@ -1261,7 +1261,7 @@ ruleSeason2 = Rule
|
||||
, prod = \_ ->
|
||||
let from = monthDay 9 23
|
||||
to = monthDay 12 21
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleDiaDoTrabalhador :: Rule
|
||||
@ -1270,7 +1270,7 @@ ruleDiaDoTrabalhador = Rule
|
||||
, pattern =
|
||||
[ regex "dia do trabalh(o|ador)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 5 1
|
||||
, prod = \_ -> tt $ monthDay 5 1
|
||||
}
|
||||
|
||||
ruleNCycleAtras :: Rule
|
||||
@ -1284,7 +1284,7 @@ ruleNCycleAtras = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1297,7 +1297,7 @@ ruleTimeofdayAmpm = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token RegexMatch (GroupMatch (ap:_)):_) ->
|
||||
Just . Token Time . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
tt . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1325,7 +1325,7 @@ ruleEntreDatetimeEDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Open (td1, td2)
|
||||
tt $ interval TTime.Open (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1352,7 +1352,7 @@ ruleEntreDdEtDdMonthinterval = Rule
|
||||
dd2 <- parseInt d2
|
||||
let dom1 = intersect (dayOfMonth dd1, td)
|
||||
dom2 = intersect (dayOfMonth dd2, td)
|
||||
in Just . Token Time $ interval TTime.Closed (dom1, dom2)
|
||||
in tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1365,7 +1365,7 @@ ruleCyclePassado = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ - 1
|
||||
tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1375,7 +1375,7 @@ ruleNamedmonth5 = Rule
|
||||
, pattern =
|
||||
[ regex "maio|mai\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 5
|
||||
, prod = \_ -> tt $ month 5
|
||||
}
|
||||
|
||||
ruleNamedday7 :: Rule
|
||||
@ -1384,7 +1384,7 @@ ruleNamedday7 = Rule
|
||||
, pattern =
|
||||
[ regex "domingo|dom\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 7
|
||||
, prod = \_ -> tt $ dayOfWeek 7
|
||||
}
|
||||
|
||||
ruleNossaSenhoraAparecida :: Rule
|
||||
@ -1393,7 +1393,7 @@ ruleNossaSenhoraAparecida = Rule
|
||||
, pattern =
|
||||
[ regex "nossa senhora (aparecida)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 10 12
|
||||
, prod = \_ -> tt $ monthDay 10 12
|
||||
}
|
||||
|
||||
ruleFinados :: Rule
|
||||
@ -1402,7 +1402,7 @@ ruleFinados = Rule
|
||||
, pattern =
|
||||
[ regex "finados|dia dos mortos"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 11 2
|
||||
, prod = \_ -> tt $ monthDay 11 2
|
||||
}
|
||||
|
||||
ruleYear :: Rule
|
||||
@ -1414,7 +1414,7 @@ ruleYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ year n
|
||||
tt $ year n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1424,7 +1424,7 @@ ruleNamedmonth10 = Rule
|
||||
, pattern =
|
||||
[ regex "outubro|out\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 10
|
||||
, prod = \_ -> tt $ month 10
|
||||
}
|
||||
|
||||
ruleAntesDasTimeofday :: Rule
|
||||
@ -1436,7 +1436,7 @@ ruleAntesDasTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ withDirection TTime.Before td
|
||||
tt $ withDirection TTime.Before td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1451,7 +1451,7 @@ ruleNProximasCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1466,7 +1466,7 @@ ruleDdmmyyyy = Rule
|
||||
y <- parseInt m3
|
||||
m <- parseInt m2
|
||||
d <- parseInt m1
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1476,7 +1476,7 @@ ruleNamedmonth11 = Rule
|
||||
, pattern =
|
||||
[ regex "novembro|nov\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 11
|
||||
, prod = \_ -> tt $ month 11
|
||||
}
|
||||
|
||||
ruleIndependecia :: Rule
|
||||
@ -1485,7 +1485,7 @@ ruleIndependecia = Rule
|
||||
, pattern =
|
||||
[ regex "independ(\x00ea|e)ncia"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 9 7
|
||||
, prod = \_ -> tt $ monthDay 9 7
|
||||
}
|
||||
|
||||
ruleNamedday3 :: Rule
|
||||
@ -1494,7 +1494,7 @@ ruleNamedday3 = Rule
|
||||
, pattern =
|
||||
[ regex "quarta((\\s|\\-)feira)?|qua\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 3
|
||||
, prod = \_ -> tt $ dayOfWeek 3
|
||||
}
|
||||
|
||||
ruleTomorrow :: Rule
|
||||
@ -1503,7 +1503,7 @@ ruleTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "amanh(\x00e3|a)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleNamedmonth9 :: Rule
|
||||
@ -1512,7 +1512,7 @@ ruleNamedmonth9 = Rule
|
||||
, pattern =
|
||||
[ regex "setembro|set\\.?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 9
|
||||
, prod = \_ -> tt $ month 9
|
||||
}
|
||||
|
||||
ruleTimezone :: Rule
|
||||
|
@ -31,7 +31,7 @@ ruleAcum = Rule
|
||||
, pattern =
|
||||
[ regex "(chiar)? ?acum|imediat"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Second 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Second 0
|
||||
}
|
||||
|
||||
ruleNamedday :: Rule
|
||||
@ -40,7 +40,7 @@ ruleNamedday = Rule
|
||||
, pattern =
|
||||
[ regex "lu(n(ea|i)?)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 1
|
||||
, prod = \_ -> tt $ dayOfWeek 1
|
||||
}
|
||||
|
||||
ruleDupamiaza :: Rule
|
||||
@ -49,7 +49,7 @@ ruleDupamiaza = Rule
|
||||
, pattern =
|
||||
[ regex "dupamiaz(a|\x0103)|dup(a|\x0103) amiaz(a|\x0103)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . mkLatent . partOfDay $
|
||||
, prod = \_ -> tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 12, hour False 19)
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ ruleNamedmonth12 = Rule
|
||||
, pattern =
|
||||
[ regex "dec(embrie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 12
|
||||
, prod = \_ -> tt $ month 12
|
||||
}
|
||||
|
||||
ruleNamedday2 :: Rule
|
||||
@ -68,7 +68,7 @@ ruleNamedday2 = Rule
|
||||
, pattern =
|
||||
[ regex "ma(r((t|\x021b)(ea|i))?)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 2
|
||||
, prod = \_ -> tt $ dayOfWeek 2
|
||||
}
|
||||
|
||||
ruleValentinesDay :: Rule
|
||||
@ -77,7 +77,7 @@ ruleValentinesDay = Rule
|
||||
, pattern =
|
||||
[ regex "sf\\.?((a|\x00e2)ntul)? Valentin"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 2 14
|
||||
, prod = \_ -> tt $ monthDay 2 14
|
||||
}
|
||||
|
||||
ruleSinceTimeofday :: Rule
|
||||
@ -88,7 +88,7 @@ ruleSinceTimeofday = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ withDirection TTime.After td
|
||||
(_:Token Time td:_) -> tt $ withDirection TTime.After td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ ruleNewYearsDay = Rule
|
||||
, pattern =
|
||||
[ regex "(siua de )? an(ul)? nou"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 1 1
|
||||
, prod = \_ -> tt $ monthDay 1 1
|
||||
}
|
||||
|
||||
ruleNamedday6 :: Rule
|
||||
@ -107,7 +107,7 @@ ruleNamedday6 = Rule
|
||||
, pattern =
|
||||
[ regex "s(a|\x00e2)mb(a|\x0103)t(a|\x0103)|s(a|\x00e2)m|s(a|\x00e2)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 6
|
||||
, prod = \_ -> tt $ dayOfWeek 6
|
||||
}
|
||||
|
||||
ruleNamedmonth7 :: Rule
|
||||
@ -116,7 +116,7 @@ ruleNamedmonth7 = Rule
|
||||
, pattern =
|
||||
[ regex "iul(ie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 7
|
||||
, prod = \_ -> tt $ month 7
|
||||
}
|
||||
|
||||
ruleOrdinalTrimestruYear :: Rule
|
||||
@ -130,7 +130,7 @@ ruleOrdinalTrimestruYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter False TG.Quarter (n - 1) td
|
||||
tt $ cycleNthAfter False TG.Quarter (n - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ ruleLastCycleOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleLastOf grain td
|
||||
tt $ cycleLastOf grain td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ ruleMonthDdddInterval = Rule
|
||||
d2 <- parseInt m2
|
||||
let dom1 = intersect (dayOfMonth d1, td)
|
||||
dom2 = intersect (dayOfMonth d2, td)
|
||||
Just . Token Time $ interval TTime.Closed (dom1, dom2)
|
||||
tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ ruleNamedday4 = Rule
|
||||
, pattern =
|
||||
[ regex "jo(ia?)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 4
|
||||
, prod = \_ -> tt $ dayOfWeek 4
|
||||
}
|
||||
|
||||
ruleInDuration :: Rule
|
||||
@ -213,7 +213,7 @@ ruleInDuration = Rule
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) -> Just . Token Time $ inDuration dd
|
||||
(_:Token Duration dd:_) -> tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ ruleIeri = Rule
|
||||
, pattern =
|
||||
[ regex "ieri"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 1
|
||||
}
|
||||
|
||||
ruleCycleAcesta :: Rule
|
||||
@ -234,7 +234,7 @@ ruleCycleAcesta = Rule
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) -> Just . Token Time $ cycleNth grain 0
|
||||
(_:Token TimeGrain grain:_) -> tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ ruleYearLatent2 = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year v
|
||||
tt . mkLatent $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ ruleAzi = Rule
|
||||
, pattern =
|
||||
[ regex "a(st(a|\x0103))?zi"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 0
|
||||
}
|
||||
|
||||
ruleNoon :: Rule
|
||||
@ -266,7 +266,7 @@ ruleNoon = Rule
|
||||
, pattern =
|
||||
[ regex "noon"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 12
|
||||
, prod = \_ -> tt $ hour False 12
|
||||
}
|
||||
|
||||
ruleTimeTrecuta :: Rule
|
||||
@ -277,7 +277,7 @@ ruleTimeTrecuta = Rule
|
||||
, regex "(trecut(a|\x0103)?)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ predNth (-1) False td
|
||||
(_:Token Time td:_) -> tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ ruleThisnextDayofweek = Rule
|
||||
, regex "aceasta|(a|\x0103)sta|urm(a|\x0103)toare"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $ predNth 0 True td
|
||||
(Token Time td:_) -> tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ ruleBetweenTimeofdayAndTimeofdayInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ ruleNamedmonth = Rule
|
||||
, pattern =
|
||||
[ regex "ian(uarie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 1
|
||||
, prod = \_ -> tt $ month 1
|
||||
}
|
||||
|
||||
ruleUrmatoareaCycle :: Rule
|
||||
@ -325,7 +325,7 @@ ruleUrmatoareaCycle = Rule
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) -> Just . Token Time $ cycleNth grain 1
|
||||
(_:Token TimeGrain grain:_) -> tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ ruleCycleAcesta2 = Rule
|
||||
, regex "aceasta|acest|(a|\x0103)sta|curent(a|\x0103)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_) -> Just . Token Time $ cycleNth grain 0
|
||||
(Token TimeGrain grain:_) -> tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ ruleNamedmonth3 = Rule
|
||||
, pattern =
|
||||
[ regex "martie|mar"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 3
|
||||
, prod = \_ -> tt $ month 3
|
||||
}
|
||||
|
||||
ruleCraciun :: Rule
|
||||
@ -356,7 +356,7 @@ ruleCraciun = Rule
|
||||
, pattern =
|
||||
[ regex "(ziua de )?cr(a|\x0103)ciun"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 25
|
||||
, prod = \_ -> tt $ monthDay 12 25
|
||||
}
|
||||
|
||||
ruleTrimestruNumeralYear :: Rule
|
||||
@ -370,7 +370,7 @@ ruleTrimestruNumeralYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token Time td:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleNthAfter False TG.Quarter (v - 1) td
|
||||
tt $ cycleNthAfter False TG.Quarter (v - 1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ ruleDdmm = Rule
|
||||
(Token RegexMatch (GroupMatch (dd:mm:_)):_) -> do
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ ruleLaTimeofday = Rule
|
||||
, Predicate isATimeOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ ruleNamedmonth4 = Rule
|
||||
, pattern =
|
||||
[ regex "apr(ilie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 4
|
||||
, prod = \_ -> tt $ month 4
|
||||
}
|
||||
|
||||
ruleBlackFriday :: Rule
|
||||
@ -415,7 +415,7 @@ ruleBlackFriday = Rule
|
||||
, pattern =
|
||||
[ regex "black frid?day"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ nthDOWOfMonth 4 5 11
|
||||
, prod = \_ -> tt $ nthDOWOfMonth 4 5 11
|
||||
}
|
||||
|
||||
ruleChristmasEve :: Rule
|
||||
@ -424,7 +424,7 @@ ruleChristmasEve = Rule
|
||||
, pattern =
|
||||
[ regex "ajun(ul)? (de )?cr(a|\x0103)ciun"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 24
|
||||
, prod = \_ -> tt $ monthDay 12 24
|
||||
}
|
||||
|
||||
rulePentruDuration :: Rule
|
||||
@ -435,7 +435,7 @@ rulePentruDuration = Rule
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) -> Just . Token Time $ inDuration dd
|
||||
(_:Token Duration dd:_) -> tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ ruleHourofdayIntegerAsRelativeMinutes = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute is12H hours n
|
||||
tt $ hourMinute is12H hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ ruleHourofdaySfert = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 15
|
||||
_) -> tt $ hourMinute is12H hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ ruleHourofdayJumatate = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
|
||||
_) -> Just . Token Time $ hourMinute is12H hours 30
|
||||
_) -> tt $ hourMinute is12H hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ ruleNamedday5 = Rule
|
||||
, pattern =
|
||||
[ regex "vi(n(er(ea|i))?)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 5
|
||||
, prod = \_ -> tt $ dayOfWeek 5
|
||||
}
|
||||
|
||||
ruleDiseara :: Rule
|
||||
@ -499,7 +499,7 @@ ruleDiseara = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in Just . Token Time . partOfDay $ intersect (td1, td2)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
}
|
||||
|
||||
ruleIntersectBy :: Rule
|
||||
@ -512,7 +512,7 @@ ruleIntersectBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ ruleDayofmonthNumeral = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth v
|
||||
tt . mkLatent $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ ruleNthTimeAfterTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token Time td1:_:Token Time td2:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ predNthAfter (v - 1) td1 td2
|
||||
tt $ predNthAfter (v - 1) td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ ruleMmdd = Rule
|
||||
(Token RegexMatch (GroupMatch (mm:dd:_)):_) -> do
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ ruleTimeofdayLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ hour True v
|
||||
tt . mkLatent $ hour True v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ ruleFromTimeofdayTimeofdayInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -593,7 +593,7 @@ ruleNamedmonth2 = Rule
|
||||
, pattern =
|
||||
[ regex "feb(ruarie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 2
|
||||
, prod = \_ -> tt $ month 2
|
||||
}
|
||||
|
||||
ruleSeason3 :: Rule
|
||||
@ -602,7 +602,7 @@ ruleSeason3 = Rule
|
||||
, pattern =
|
||||
[ regex "primavar(a|\x0103)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $
|
||||
, prod = \_ -> tt $
|
||||
interval TTime.Open (monthDay 3 20, monthDay 6 21)
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ ruleUrmatoareleNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -627,7 +627,7 @@ ruleSeason = Rule
|
||||
, pattern =
|
||||
[ regex "toamn(a|\x0103)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $
|
||||
, prod = \_ -> tt $
|
||||
interval TTime.Open (monthDay 9 23, monthDay 12 21)
|
||||
}
|
||||
|
||||
@ -640,7 +640,7 @@ ruleDupaDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time . withDirection TTime.After $ inDuration dd
|
||||
tt . withDirection TTime.After $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -650,7 +650,7 @@ ruleNewYearsEve = Rule
|
||||
, pattern =
|
||||
[ regex "(ajun(ul)? )?(de )?an(ul)? nou"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 31
|
||||
, prod = \_ -> tt $ monthDay 12 31
|
||||
}
|
||||
|
||||
ruleByTheEndOfTime :: Rule
|
||||
@ -662,7 +662,7 @@ ruleByTheEndOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (cycleNth TG.Second 0, td)
|
||||
tt $ interval TTime.Closed (cycleNth TG.Second 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -700,7 +700,7 @@ ruleIntersect = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -712,7 +712,7 @@ ruleAboutTimeofday = Rule
|
||||
, Predicate isATimeOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(_:Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -725,7 +725,7 @@ ruleUntilTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ withDirection TTime.Before td
|
||||
tt $ withDirection TTime.Before td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -747,7 +747,7 @@ ruleNamedmonth6 = Rule
|
||||
, pattern =
|
||||
[ regex "iun(ie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 6
|
||||
, prod = \_ -> tt $ month 6
|
||||
}
|
||||
|
||||
ruleIntreDatetimeSiDatetimeInterval :: Rule
|
||||
@ -761,7 +761,7 @@ ruleIntreDatetimeSiDatetimeInterval = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ interval TTime.Closed (td1, td2)
|
||||
tt $ interval TTime.Closed (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ ruleNthTimeOfTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token Time td1:_:Token Time td2:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . predNth (v - 1) False $ intersect (td2, td1)
|
||||
tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -787,7 +787,7 @@ ruleNamedmonth8 = Rule
|
||||
, pattern =
|
||||
[ regex "aug(ust)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 8
|
||||
, prod = \_ -> tt $ month 8
|
||||
}
|
||||
|
||||
ruleTimePartofday :: Rule
|
||||
@ -799,7 +799,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -812,7 +812,7 @@ ruleWeekend = Rule
|
||||
, prod = \_ ->
|
||||
let fri = intersect (dayOfWeek 5, hour False 18)
|
||||
mon = intersect (dayOfWeek 1, hour False 0)
|
||||
in Just . Token Time $ interval TTime.Open (fri, mon)
|
||||
in tt $ interval TTime.Open (fri, mon)
|
||||
}
|
||||
|
||||
rulePeDayofmonthNonOrdinal :: Rule
|
||||
@ -825,7 +825,7 @@ rulePeDayofmonthNonOrdinal = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ dayOfMonth v
|
||||
tt . mkLatent $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -838,7 +838,7 @@ ruleTimeAceastaacestaasta = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ ruleEomendOfMonth = Rule
|
||||
, pattern =
|
||||
[ regex "sf(a|\x00e2)r(s|\x0219)itul lunii"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Month 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Month 1
|
||||
}
|
||||
|
||||
rulePartofdayAsta :: Rule
|
||||
@ -860,7 +860,7 @@ rulePartofdayAsta = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -872,7 +872,7 @@ ruleUltimaCycle = Rule
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) -> Just . Token Time . cycleNth grain $ - 1
|
||||
(_:Token TimeGrain grain:_) -> tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -884,7 +884,7 @@ ruleCycleUrmatoare = Rule
|
||||
, regex "(urm(a|\x0103)to(are|r)|viito(are|r))"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) -> Just . Token Time $ cycleNth grain 1
|
||||
(_:Token TimeGrain grain:_) -> tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -898,7 +898,7 @@ ruleTheDayofmonthNumeral = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ dayOfMonth v
|
||||
tt $ dayOfMonth v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -913,7 +913,7 @@ ruleYyyymmdd = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -926,7 +926,7 @@ ruleCycleTrecut = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ - 1
|
||||
tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -953,7 +953,7 @@ ruleDurationInainteDeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_:Token Time td:_) ->
|
||||
Just . Token Time $ durationBefore dd td
|
||||
tt $ durationBefore dd td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -978,7 +978,7 @@ ruleDurationInUrma = Rule
|
||||
, regex "(i|\x00ee)n urm(a|\x0103)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) -> Just . Token Time $ durationAgo dd
|
||||
(Token Duration dd:_) -> tt $ durationAgo dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -990,7 +990,7 @@ ruleDurationDeAcum = Rule
|
||||
, regex "de (acum|azi)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) -> Just . Token Time $ inDuration dd
|
||||
(Token Duration dd:_) -> tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1001,7 +1001,7 @@ ruleSezonAnotimp = Rule
|
||||
[ regex "var(a|\x0103)"
|
||||
]
|
||||
, prod = \_ ->
|
||||
Just . Token Time $ interval TTime.Open (monthDay 6 21, monthDay 9 23)
|
||||
tt $ interval TTime.Open (monthDay 6 21, monthDay 9 23)
|
||||
}
|
||||
|
||||
ruleSearaNoapte :: Rule
|
||||
@ -1010,7 +1010,7 @@ ruleSearaNoapte = Rule
|
||||
, pattern =
|
||||
[ regex "sear(a|\x0103)|noapte"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . mkLatent . partOfDay $
|
||||
, prod = \_ -> tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 18, hour False 0)
|
||||
}
|
||||
|
||||
@ -1023,7 +1023,7 @@ ruleYearLatent = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ year v
|
||||
tt . mkLatent $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1034,7 +1034,7 @@ ruleSeason2 = Rule
|
||||
[ regex "iarn(a|\x0103)"
|
||||
]
|
||||
, prod = \_ ->
|
||||
Just . Token Time $ interval TTime.Open (monthDay 12 21, monthDay 3 20)
|
||||
tt $ interval TTime.Open (monthDay 12 21, monthDay 3 20)
|
||||
}
|
||||
|
||||
ruleUltimeleNCycle :: Rule
|
||||
@ -1048,7 +1048,7 @@ ruleUltimeleNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1060,7 +1060,7 @@ ruleAfterTimeofday = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ withDirection TTime.After td
|
||||
(_:Token Time td:_) -> tt $ withDirection TTime.After td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1070,7 +1070,7 @@ ruleDimineata = Rule
|
||||
, pattern =
|
||||
[ regex "diminea(t|\x021b)(a|\x0103)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . mkLatent . partOfDay $
|
||||
, prod = \_ -> tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 4, hour False 12)
|
||||
}
|
||||
|
||||
@ -1082,7 +1082,7 @@ ruleTimeUrmatoarer = Rule
|
||||
, Predicate isNotLatent
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $ predNth 0 True td
|
||||
(_:Token Time td:_) -> tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1092,7 +1092,7 @@ ruleNamedmonth5 = Rule
|
||||
, pattern =
|
||||
[ regex "mai"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 5
|
||||
, prod = \_ -> tt $ month 5
|
||||
}
|
||||
|
||||
ruleTimeofdayFix :: Rule
|
||||
@ -1103,7 +1103,7 @@ ruleTimeofdayFix = Rule
|
||||
, regex "(fix|exact)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) -> Just . Token Time $ notLatent td
|
||||
(Token Time td:_) -> tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1113,7 +1113,7 @@ ruleNamedday7 = Rule
|
||||
, pattern =
|
||||
[ regex "du(m(inic(a|\x0103))?)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 7
|
||||
, prod = \_ -> tt $ dayOfWeek 7
|
||||
}
|
||||
|
||||
ruleHhmm :: Rule
|
||||
@ -1126,7 +1126,7 @@ ruleHhmm = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time $ hourMinute True h m
|
||||
tt $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1136,7 +1136,7 @@ ruleMaine = Rule
|
||||
, pattern =
|
||||
[ regex "m(a|\x00e2)ine"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleTimezone :: Rule
|
||||
@ -1162,7 +1162,7 @@ ruleYear = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1172,7 +1172,7 @@ ruleNamedmonth10 = Rule
|
||||
, pattern =
|
||||
[ regex "oct(ombrie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 10
|
||||
, prod = \_ -> tt $ month 10
|
||||
}
|
||||
|
||||
ruleHalloweenDay :: Rule
|
||||
@ -1181,7 +1181,7 @@ ruleHalloweenDay = Rule
|
||||
, pattern =
|
||||
[ regex "hall?owe?en"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 10 31
|
||||
, prod = \_ -> tt $ monthDay 10 31
|
||||
}
|
||||
|
||||
ruleNamedmonthDayofmonthNonOrdinal :: Rule
|
||||
@ -1223,7 +1223,7 @@ ruleDayofmonthnumberNamedmonthYear = Rule
|
||||
_) -> do
|
||||
v <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
Just . Token Time $ intersect (dom, year v)
|
||||
tt $ intersect (dom, year v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1250,7 +1250,7 @@ ruleLastDayofweekOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ predLastOf td1 td2
|
||||
tt $ predLastOf td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1264,7 +1264,7 @@ ruleOrdinalTrimestru = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
tt . cycleNthAfter True TG.Quarter (n - 1) $
|
||||
cycleNth TG.Year 0
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1277,7 +1277,7 @@ ruleByTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> Just . Token Time $
|
||||
(_:Token Time td:_) -> tt $
|
||||
interval TTime.Open (cycleNth TG.Second 0, td)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1293,7 +1293,7 @@ ruleDdmmyyyy = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1303,7 +1303,7 @@ ruleNamedmonth11 = Rule
|
||||
, pattern =
|
||||
[ regex "noi(embrie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 11
|
||||
, prod = \_ -> tt $ month 11
|
||||
}
|
||||
|
||||
ruleNamedday3 :: Rule
|
||||
@ -1312,7 +1312,7 @@ ruleNamedday3 = Rule
|
||||
, pattern =
|
||||
[ regex "mi(e(rcur(ea|i))?)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 3
|
||||
, prod = \_ -> tt $ dayOfWeek 3
|
||||
}
|
||||
|
||||
ruleMmddyyyy :: Rule
|
||||
@ -1326,7 +1326,7 @@ ruleMmddyyyy = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1336,7 +1336,7 @@ ruleEoyendOfYear = Rule
|
||||
, pattern =
|
||||
[ regex "sf(a|\x00e2)r(s|\x0219)itul anului"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Year 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Year 1
|
||||
}
|
||||
|
||||
ruleMothersDay :: Rule
|
||||
@ -1345,7 +1345,7 @@ ruleMothersDay = Rule
|
||||
, pattern =
|
||||
[ regex "ziua (mamei|memeii)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ nthDOWOfMonth 1 7 5
|
||||
, prod = \_ -> tt $ nthDOWOfMonth 1 7 5
|
||||
}
|
||||
|
||||
ruleNameddayDayofmonthNumeral :: Rule
|
||||
@ -1366,7 +1366,7 @@ ruleNamedmonth9 = Rule
|
||||
, pattern =
|
||||
[ regex "sept(embrie)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 9
|
||||
, prod = \_ -> tt $ month 9
|
||||
}
|
||||
|
||||
ruleHhmmss :: Rule
|
||||
@ -1380,7 +1380,7 @@ ruleHhmmss = Rule
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
s <- parseInt ss
|
||||
Just . Token Time $ hourMinuteSecond True h m s
|
||||
tt $ hourMinuteSecond True h m s
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,7 @@ ruleNamedday = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x4e00|\x5468\x4e00|\x793c\x62dc\x4e00|\x79ae\x62dc\x4e00|\x9031\x4e00"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 1
|
||||
, prod = \_ -> tt $ dayOfWeek 1
|
||||
}
|
||||
|
||||
ruleTheDayAfterTomorrow :: Rule
|
||||
@ -42,7 +42,7 @@ ruleTheDayAfterTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "\x540e\x5929|\x5f8c\x5929"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 2
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 2
|
||||
}
|
||||
|
||||
ruleNamedmonth12 :: Rule
|
||||
@ -51,7 +51,7 @@ ruleNamedmonth12 = Rule
|
||||
, pattern =
|
||||
[ regex "\x5341\x4e8c\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 12
|
||||
, prod = \_ -> tt $ month 12
|
||||
}
|
||||
|
||||
ruleRelativeMinutesTotillbeforeIntegerHourofday :: Rule
|
||||
@ -100,7 +100,7 @@ ruleRelativeMinutesAfterpastIntegerHourofday = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute True hours n
|
||||
tt $ hourMinute True hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ ruleRelativeMinutesAfterpastNoonmidnight = Rule
|
||||
token:
|
||||
_) -> do
|
||||
n <- getIntValue token
|
||||
Just . Token Time $ hourMinute True hours n
|
||||
tt $ hourMinute True hours n
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ ruleQuarterAfterpastIntegerHourofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
|
||||
_) -> Just . Token Time $ hourMinute True hours 15
|
||||
_) -> tt $ hourMinute True hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleQuarterAfterpastNoonmidnight :: Rule
|
||||
@ -169,7 +169,7 @@ ruleQuarterAfterpastNoonmidnight = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
|
||||
_) -> Just . Token Time $ hourMinute True hours 15
|
||||
_) -> tt $ hourMinute True hours 15
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ ruleHalfAfterpastIntegerHourofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
|
||||
_) -> Just . Token Time $ hourMinute True hours 30
|
||||
_) -> tt $ hourMinute True hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleHalfAfterpastNoonmidnight :: Rule
|
||||
@ -220,7 +220,7 @@ ruleHalfAfterpastNoonmidnight = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
|
||||
_) -> Just . Token Time $ hourMinute True hours 30
|
||||
_) -> tt $ hourMinute True hours 30
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ ruleNamedday2 = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x4e8c|\x5468\x4e8c|\x793c\x62dc\x4e8c|\x79ae\x62dc\x4e8c|\x9031\x4e8c"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 2
|
||||
, prod = \_ -> tt $ dayOfWeek 2
|
||||
}
|
||||
|
||||
ruleValentinesDay :: Rule
|
||||
@ -239,7 +239,7 @@ ruleValentinesDay = Rule
|
||||
, pattern =
|
||||
[ regex "\x60c5\x4eba(\x8282|\x7bc0)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 2 14
|
||||
, prod = \_ -> tt $ monthDay 2 14
|
||||
}
|
||||
|
||||
ruleHhmmTimeofday :: Rule
|
||||
@ -252,7 +252,7 @@ ruleHhmmTimeofday = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time $ hourMinute True h m
|
||||
tt $ hourMinute True h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ ruleThisDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ ruleNthTimeOfTime2 = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Ordinal od:Token Time td2:_) -> Just . Token Time .
|
||||
(Token Time td1:_:Token Ordinal od:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -290,7 +290,7 @@ ruleNewYearsDay = Rule
|
||||
, pattern =
|
||||
[ regex "\x5143\x65e6(\x8282|\x7bc0)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 1 1
|
||||
, prod = \_ -> tt $ monthDay 1 1
|
||||
}
|
||||
|
||||
ruleLastTime :: Rule
|
||||
@ -302,7 +302,7 @@ ruleLastTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ ruleNamedday6 = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x516d|\x5468\x516d|\x793c\x62dc\x516d|\x79ae\x62dc\x516d|\x9031\x516d"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 6
|
||||
, prod = \_ -> tt $ dayOfWeek 6
|
||||
}
|
||||
|
||||
ruleNamedmonth7 :: Rule
|
||||
@ -321,7 +321,7 @@ ruleNamedmonth7 = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e03\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 7
|
||||
, prod = \_ -> tt $ month 7
|
||||
}
|
||||
|
||||
ruleInDuration :: Rule
|
||||
@ -333,7 +333,7 @@ ruleInDuration = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Duration dd:_) ->
|
||||
Just . Token Time $ inDuration dd
|
||||
tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ ruleNow = Rule
|
||||
, pattern =
|
||||
[ regex "\x73b0\x5728|\x6b64\x65f6|\x6b64\x523b|\x5f53\x524d|\x73fe\x5728|\x6b64\x6642|\x7576\x524d"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Second 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Second 0
|
||||
}
|
||||
|
||||
ruleNationalDay :: Rule
|
||||
@ -352,7 +352,7 @@ ruleNationalDay = Rule
|
||||
, pattern =
|
||||
[ regex "(\x56fd\x5e86|\x570b\x6176)(\x8282|\x7bc0)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 10 1
|
||||
, prod = \_ -> tt $ monthDay 10 1
|
||||
}
|
||||
|
||||
ruleNamedday4 :: Rule
|
||||
@ -361,7 +361,7 @@ ruleNamedday4 = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x56db|\x5468\x56db|\x793c\x62dc\x56db|\x79ae\x62dc\x56db|\x9031\x56db"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 4
|
||||
, prod = \_ -> tt $ dayOfWeek 4
|
||||
}
|
||||
|
||||
ruleTheCycleAfterTime :: Rule
|
||||
@ -375,7 +375,7 @@ ruleTheCycleAfterTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain 1 td
|
||||
tt $ cycleNthAfter False grain 1 td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ ruleTheCycleBeforeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token Time td:_) ->
|
||||
Just . Token Time $ cycleNthAfter False grain (-1) td
|
||||
tt $ cycleNthAfter False grain (-1) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ ruleNoon = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e2d\x5348"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 12
|
||||
, prod = \_ -> tt $ hour False 12
|
||||
}
|
||||
|
||||
ruleToday :: Rule
|
||||
@ -409,7 +409,7 @@ ruleToday = Rule
|
||||
, pattern =
|
||||
[ regex "\x4eca\x5929"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 0
|
||||
}
|
||||
|
||||
ruleThisnextDayofweek :: Rule
|
||||
@ -421,7 +421,7 @@ ruleThisnextDayofweek = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 True td
|
||||
tt $ predNth 0 True td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ ruleTheDayBeforeYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "\x524d\x5929"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 2
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 2
|
||||
}
|
||||
|
||||
ruleLaborDay :: Rule
|
||||
@ -440,7 +440,7 @@ ruleLaborDay = Rule
|
||||
, pattern =
|
||||
[ regex "\x52b3\x52a8\x8282|\x52de\x52d5\x7bc0"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 5 1
|
||||
, prod = \_ -> tt $ monthDay 5 1
|
||||
}
|
||||
|
||||
ruleNextCycle :: Rule
|
||||
@ -452,7 +452,7 @@ ruleNextCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 1
|
||||
tt $ cycleNth grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ ruleNamedmonth = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e00\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 1
|
||||
, prod = \_ -> tt $ month 1
|
||||
}
|
||||
|
||||
ruleNamedmonth3 :: Rule
|
||||
@ -471,7 +471,7 @@ ruleNamedmonth3 = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e09\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 3
|
||||
, prod = \_ -> tt $ month 3
|
||||
}
|
||||
|
||||
ruleDurationFromNow :: Rule
|
||||
@ -483,7 +483,7 @@ ruleDurationFromNow = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) ->
|
||||
Just . Token Time $ inDuration dd
|
||||
tt $ inDuration dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ ruleLastCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time . cycleNth grain $ - 1
|
||||
tt . cycleNth grain $ - 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ ruleAfternoon = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 12
|
||||
to = hour False 19
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ ruleNamedmonth4 = Rule
|
||||
, pattern =
|
||||
[ regex "\x56db\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 4
|
||||
, prod = \_ -> tt $ month 4
|
||||
}
|
||||
|
||||
ruleMidnight :: Rule
|
||||
@ -528,7 +528,7 @@ ruleMidnight = Rule
|
||||
, pattern =
|
||||
[ regex "\x5348\x591c|\x51cc\x6668"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ hour False 0
|
||||
, prod = \_ -> tt $ hour False 0
|
||||
}
|
||||
|
||||
ruleInduringThePartofday :: Rule
|
||||
@ -540,7 +540,7 @@ ruleInduringThePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ ruleNamedday5 = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x4e94|\x5468\x4e94|\x793c\x62dc\x4e94|\x79ae\x62dc\x4e94|\x9031\x4e94"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 5
|
||||
, prod = \_ -> tt $ dayOfWeek 5
|
||||
}
|
||||
|
||||
ruleIntersectBy :: Rule
|
||||
@ -563,7 +563,7 @@ ruleIntersectBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -577,7 +577,7 @@ ruleMmdd = Rule
|
||||
(Token RegexMatch (GroupMatch (mm:dd:_)):_) -> do
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ monthDay m d
|
||||
tt $ monthDay m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -587,7 +587,7 @@ ruleNamedmonth2 = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e8c\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 2
|
||||
, prod = \_ -> tt $ month 2
|
||||
}
|
||||
|
||||
ruleIntegerLatentTimeofday :: Rule
|
||||
@ -599,7 +599,7 @@ ruleIntegerLatentTimeofday = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ hour True v
|
||||
tt . mkLatent $ hour True v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -613,7 +613,7 @@ ruleYearNumericWithYearSymbol = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ year v
|
||||
tt $ year v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -626,7 +626,7 @@ ruleDurationAgo = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Duration dd:_) ->
|
||||
Just . Token Time $ durationAgo dd
|
||||
tt $ durationAgo dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -640,7 +640,7 @@ ruleHhmmMilitaryTimeofday = Rule
|
||||
(Token RegexMatch (GroupMatch (hh:mm:_)):_) -> do
|
||||
h <- parseInt hh
|
||||
m <- parseInt mm
|
||||
Just . Token Time . mkLatent $ hourMinute False h m
|
||||
tt . mkLatent $ hourMinute False h m
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -655,7 +655,7 @@ ruleLastNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain (- v)
|
||||
tt $ cycleN True grain (- v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ ruleIntersect = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -678,7 +678,7 @@ ruleNamedmonth6 = Rule
|
||||
, pattern =
|
||||
[ regex "\x516d\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 6
|
||||
, prod = \_ -> tt $ month 6
|
||||
}
|
||||
|
||||
ruleNthTimeOfTime :: Rule
|
||||
@ -690,7 +690,7 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Ordinal od:Token Time td2:_) -> Just . Token Time .
|
||||
(Token Time td1:Token Ordinal od:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -701,7 +701,7 @@ ruleNamedmonth8 = Rule
|
||||
, pattern =
|
||||
[ regex "\x516b\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 8
|
||||
, prod = \_ -> tt $ month 8
|
||||
}
|
||||
|
||||
ruleWeekend :: Rule
|
||||
@ -713,7 +713,7 @@ ruleWeekend = Rule
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in Just . Token Time $ interval TTime.Open (from, to)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleLastYear :: Rule
|
||||
@ -722,7 +722,7 @@ ruleLastYear = Rule
|
||||
, pattern =
|
||||
[ regex "\x53bb\x5e74"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Year $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Year $ - 1
|
||||
}
|
||||
|
||||
ruleDimTimePartofday :: Rule
|
||||
@ -734,7 +734,7 @@ ruleDimTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -747,7 +747,7 @@ ruleNextTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 1 False td
|
||||
tt $ predNth 1 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -762,7 +762,7 @@ ruleYyyymmdd = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ ruleNextNCycle = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:Token TimeGrain grain:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time $ cycleN True grain v
|
||||
tt $ cycleN True grain v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -790,7 +790,7 @@ ruleMorning = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 4
|
||||
to = hour False 12
|
||||
in Just . Token Time . mkLatent . partOfDay $
|
||||
in tt . mkLatent . partOfDay $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -800,7 +800,7 @@ ruleNextYear = Rule
|
||||
, pattern =
|
||||
[ regex "\x660e\x5e74"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Year 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Year 1
|
||||
}
|
||||
|
||||
ruleThisCycle :: Rule
|
||||
@ -812,7 +812,7 @@ ruleThisCycle = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) ->
|
||||
Just . Token Time $ cycleNth grain 0
|
||||
tt $ cycleNth grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -825,7 +825,7 @@ ruleThisTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth 0 False td
|
||||
tt $ predNth 0 False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -835,7 +835,7 @@ ruleYesterday = Rule
|
||||
, pattern =
|
||||
[ regex "\x6628\x5929"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time . cycleNth TG.Day $ - 1
|
||||
, prod = \_ -> tt . cycleNth TG.Day $ - 1
|
||||
}
|
||||
|
||||
ruleChristmas :: Rule
|
||||
@ -844,7 +844,7 @@ ruleChristmas = Rule
|
||||
, pattern =
|
||||
[ regex "(\x5723\x8bde|\x8056\x8a95)(\x8282|\x7bc0)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 12 25
|
||||
, prod = \_ -> tt $ monthDay 12 25
|
||||
}
|
||||
|
||||
ruleLastNight :: Rule
|
||||
@ -856,7 +856,7 @@ ruleLastNight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day $ - 1
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in Just . Token Time . partOfDay $ intersect (td1, td2)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
}
|
||||
|
||||
ruleTimeofdayAmpm :: Rule
|
||||
@ -868,7 +868,7 @@ ruleTimeofdayAmpm = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:Token RegexMatch (GroupMatch (ap:_)):_) ->
|
||||
Just . Token Time . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
tt . timeOfDayAMPM td $ Text.toLower ap == "a"
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -878,7 +878,7 @@ ruleArmysDay = Rule
|
||||
, pattern =
|
||||
[ regex "\x5efa(\x519b\x8282|\x8ecd\x7bc0)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 8 1
|
||||
, prod = \_ -> tt $ monthDay 8 1
|
||||
}
|
||||
|
||||
ruleNamedmonthDayofmonth :: Rule
|
||||
@ -903,7 +903,7 @@ ruleLastTuesdayLastJuly = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
Just . Token Time $ predNth (-1) False td
|
||||
tt $ predNth (-1) False td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -913,7 +913,7 @@ ruleNamedmonth5 = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e94\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 5
|
||||
, prod = \_ -> tt $ month 5
|
||||
}
|
||||
|
||||
ruleNamedday7 :: Rule
|
||||
@ -922,7 +922,7 @@ ruleNamedday7 = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x65e5|\x661f\x671f\x5929|\x793c\x62dc\x5929|\x5468\x65e5|\x79ae\x62dc\x5929|\x9031\x65e5"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 7
|
||||
, prod = \_ -> tt $ dayOfWeek 7
|
||||
}
|
||||
|
||||
rulePartofdayDimTime :: Rule
|
||||
@ -934,7 +934,7 @@ rulePartofdayDimTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
Just . Token Time $ intersect (td1, td2)
|
||||
tt $ intersect (td1, td2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -948,7 +948,7 @@ ruleMonthNumericWithMonthSymbol = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_) -> do
|
||||
v <- getIntValue token
|
||||
Just . Token Time . mkLatent $ month v
|
||||
tt . mkLatent $ month v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -961,7 +961,7 @@ ruleTonight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in Just . Token Time . partOfDay $ intersect (td1, td2)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
}
|
||||
|
||||
ruleTomorrowNight :: Rule
|
||||
@ -973,7 +973,7 @@ ruleTomorrowNight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 1
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in Just . Token Time . partOfDay $ intersect (td1, td2)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
}
|
||||
|
||||
ruleNamedmonth10 :: Rule
|
||||
@ -982,7 +982,7 @@ ruleNamedmonth10 = Rule
|
||||
, pattern =
|
||||
[ regex "\x5341\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 10
|
||||
, prod = \_ -> tt $ month 10
|
||||
}
|
||||
|
||||
ruleChildrensDay :: Rule
|
||||
@ -991,7 +991,7 @@ ruleChildrensDay = Rule
|
||||
, pattern =
|
||||
[ regex "(\x513f|\x5152)\x7ae5(\x8282|\x7bc0)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 6 1
|
||||
, prod = \_ -> tt $ monthDay 6 1
|
||||
}
|
||||
|
||||
ruleThisYear :: Rule
|
||||
@ -1000,7 +1000,7 @@ ruleThisYear = Rule
|
||||
, pattern =
|
||||
[ regex "\x4eca\x5e74"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Year 0
|
||||
, prod = \_ -> tt $ cycleNth TG.Year 0
|
||||
}
|
||||
|
||||
ruleAbsorptionOfAfterNamedDay :: Rule
|
||||
@ -1021,7 +1021,7 @@ ruleNamedmonth11 = Rule
|
||||
, pattern =
|
||||
[ regex "\x5341\x4e00\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 11
|
||||
, prod = \_ -> tt $ month 11
|
||||
}
|
||||
|
||||
ruleWomensDay :: Rule
|
||||
@ -1030,7 +1030,7 @@ ruleWomensDay = Rule
|
||||
, pattern =
|
||||
[ regex "(\x5987|\x5a66)\x5973(\x8282|\x7bc0)"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ monthDay 3 8
|
||||
, prod = \_ -> tt $ monthDay 3 8
|
||||
}
|
||||
|
||||
ruleEveningnight :: Rule
|
||||
@ -1042,7 +1042,7 @@ ruleEveningnight = Rule
|
||||
, prod = \_ ->
|
||||
let from = hour False 18
|
||||
to = hour False 0
|
||||
in Just . Token Time . partOfDay . mkLatent $
|
||||
in tt . partOfDay . mkLatent $
|
||||
interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
@ -1052,7 +1052,7 @@ ruleNamedday3 = Rule
|
||||
, pattern =
|
||||
[ regex "\x661f\x671f\x4e09|\x5468\x4e09|\x793c\x62dc\x4e09|\x79ae\x62dc\x4e09|\x9031\x4e09"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ dayOfWeek 3
|
||||
, prod = \_ -> tt $ dayOfWeek 3
|
||||
}
|
||||
|
||||
ruleMmddyyyy :: Rule
|
||||
@ -1066,7 +1066,7 @@ ruleMmddyyyy = Rule
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
d <- parseInt dd
|
||||
Just . Token Time $ yearMonthDay y m d
|
||||
tt $ yearMonthDay y m d
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1076,7 +1076,7 @@ ruleTomorrow = Rule
|
||||
, pattern =
|
||||
[ regex "\x660e\x5929"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ cycleNth TG.Day 1
|
||||
, prod = \_ -> tt $ cycleNth TG.Day 1
|
||||
}
|
||||
|
||||
ruleTimeofdayOclock :: Rule
|
||||
@ -1088,7 +1088,7 @@ ruleTimeofdayOclock = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
Just . Token Time $ notLatent td
|
||||
tt $ notLatent td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1098,7 +1098,7 @@ ruleNamedmonth9 = Rule
|
||||
, pattern =
|
||||
[ regex "\x4e5d\x6708(\x4efd)?"
|
||||
]
|
||||
, prod = \_ -> Just . Token Time $ month 9
|
||||
, prod = \_ -> tt $ month 9
|
||||
}
|
||||
|
||||
ruleTimezone :: Rule
|
||||
|
Loading…
Reference in New Issue
Block a user