mirror of
https://github.com/facebook/duckling.git
synced 2025-01-07 14:29:37 +03:00
Use intervalMB instead of interval
Summary: This continues the work from: "[Duckling] Don't produce trivially empty Tokens" All the Rules should use intervalMB from now on. Reviewed By: patapizza Differential Revision: D4906072 fbshipit-source-id: 277b961
This commit is contained in:
parent
a91e787bb7
commit
fe39a55a4c
@ -157,7 +157,7 @@ ruleNthTimeOfTime2 = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -371,8 +371,8 @@ ruleMonthDdddInterval = Rule
|
||||
_) -> do
|
||||
v1 <- parseInt m1
|
||||
v2 <- parseInt m2
|
||||
let from = intersect (td, dayOfMonth v1)
|
||||
to = intersect (td, dayOfMonth v2)
|
||||
from <- intersectMB td (dayOfMonth v1)
|
||||
to <- intersectMB td (dayOfMonth v2)
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -460,8 +460,8 @@ ruleTheIdesOfNamedmonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (td, dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13)
|
||||
Token Time <$>
|
||||
intersectMB td (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -977,7 +977,7 @@ ruleAfterWork = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 17, hour False 21)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleLastNCycle :: Rule
|
||||
@ -1113,7 +1113,7 @@ ruleNthTimeOfTime = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1135,7 +1135,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1145,10 +1145,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "(week(\\s|-)?end)(en)?"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleAboutDuration :: Rule
|
||||
@ -1314,7 +1314,7 @@ ruleThisPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1379,7 +1379,7 @@ ruleAfterLunch = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 13, hour False 17)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleOnANamedday :: Rule
|
||||
@ -1546,7 +1546,7 @@ ruleTonight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleYear :: Rule
|
||||
@ -1755,7 +1755,7 @@ rulePartofdayOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1823,7 +1823,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
_) -> do
|
||||
n <- parseInt match
|
||||
td2 <- intersectDOM td token
|
||||
tt $ intersect (td2, year n)
|
||||
Token Time <$> intersectMB td2 (year n)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ ruleNthTimeOfTime2 = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -340,8 +340,8 @@ ruleMonthDdddInterval = Rule
|
||||
_) -> do
|
||||
v1 <- parseInt m1
|
||||
v2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth v1, td)
|
||||
to = intersect (dayOfMonth v2, td)
|
||||
from <- intersectMB (dayOfMonth v1) td
|
||||
to <- intersectMB (dayOfMonth v2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -441,8 +441,8 @@ ruleTheIdesOfNamedmonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13, td)
|
||||
Token Time <$>
|
||||
intersectMB (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -918,7 +918,7 @@ ruleAfterWork = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 17, hour False 21)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleBeforeYesterday :: Rule
|
||||
@ -1082,7 +1082,7 @@ ruleNthTimeOfTime = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1104,7 +1104,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1114,10 +1114,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "wochen ?ende?"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleTagDerDeutschenEinheit :: Rule
|
||||
@ -1279,8 +1279,8 @@ ruleThisPartofday = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> tt . partOfDay $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
(_:Token Time td:_) -> Token Time . partOfDay <$>
|
||||
intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1354,7 +1354,7 @@ ruleAfterLunch = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 13, hour False 17)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleOnANamedday :: Rule
|
||||
@ -1562,7 +1562,7 @@ ruleTonight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleYear :: Rule
|
||||
@ -1770,7 +1770,7 @@ rulePartofdayOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1853,7 +1853,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
_) -> do
|
||||
n <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year n)
|
||||
Token Time <$> intersectMB dom (year n)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -226,8 +226,8 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -242,8 +242,8 @@ ruleTheNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ ruleDOMOrdinalMonthYear = Rule
|
||||
(token:Token Time td:Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||
intVal <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year intVal)
|
||||
Token Time <$> intersectMB dom (year intVal)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -427,8 +427,8 @@ ruleIdesOfMonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (td, dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13)
|
||||
Token Time <$>
|
||||
intersectMB td (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -765,8 +765,8 @@ rulePODThis = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> tt . partOfDay . notLatent $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
(_:Token Time td:_) -> Token Time . partOfDay . notLatent <$>
|
||||
intersectMB (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
|
||||
tt . partOfDay . notLatent $ intersect (today, evening)
|
||||
Token Time . partOfDay . notLatent <$> intersectMB today evening
|
||||
}
|
||||
|
||||
ruleAfterPartofday :: Rule
|
||||
@ -793,8 +793,8 @@ ruleAfterPartofday = Rule
|
||||
"work" -> Just (hour False 17, hour False 21)
|
||||
"school" -> Just (hour False 15, hour False 21)
|
||||
_ -> Nothing
|
||||
tt . partOfDay . notLatent $
|
||||
intersect (cycleNth TG.Day 0, interval TTime.Open pair)
|
||||
Token Time . partOfDay . notLatent <$>
|
||||
intersectMB (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:_) -> tt $ intersect (pod, td)
|
||||
(Token Time td:Token Time pod:_) -> Token Time <$> intersectMB pod td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -820,7 +820,7 @@ rulePODofTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time pod:_:Token Time td:_) -> tt $ intersect (pod, td)
|
||||
(Token Time pod:_:Token Time td:_) -> Token Time <$> intersectMB pod td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -828,10 +828,10 @@ ruleWeekend :: Rule
|
||||
ruleWeekend = Rule
|
||||
{ name = "week-end"
|
||||
, pattern = [regex "(week(\\s|-)?end|wkend)"]
|
||||
, prod = \_ ->
|
||||
let fri = intersect (dayOfWeek 5, hour False 18)
|
||||
mon = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (fri, mon)
|
||||
, prod = \_ -> do
|
||||
fri <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
mon <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (fri, mon)
|
||||
}
|
||||
|
||||
ruleSeasons :: Rule
|
||||
@ -900,9 +900,9 @@ ruleIntervalMonthDDDD = Rule
|
||||
:_) -> do
|
||||
dd1 <- parseInt d1
|
||||
dd2 <- parseInt d2
|
||||
let dom1 = intersect (dayOfMonth dd1, td)
|
||||
dom2 = intersect (dayOfMonth dd2, td)
|
||||
in tt $ interval TTime.Closed (dom1, dom2)
|
||||
dom1 <- intersectMB (dayOfMonth dd1) td
|
||||
dom2 <- intersectMB (dayOfMonth dd2) td
|
||||
tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -721,8 +721,8 @@ ruleDdddMonthinterval = Rule
|
||||
_) -> do
|
||||
d1 <- parseInt m1
|
||||
d2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth d1, td)
|
||||
to = intersect (dayOfMonth d2, td)
|
||||
from <- intersectMB (dayOfMonth d1) td
|
||||
to <- intersectMB (dayOfMonth d2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -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 tt $ intersect (td, mkLatent $ partOfDay tarde)
|
||||
in Token Time <$> intersectMB td (mkLatent $ partOfDay tarde)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -819,7 +819,7 @@ ruleIntegerInThePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -873,7 +873,7 @@ ruleTimeofdayPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB 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 tt $ intersect (td, mkLatent $ partOfDay manana)
|
||||
in Token Time <$> intersectMB td (mkLatent $ partOfDay manana)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -922,7 +922,7 @@ ruleNthTimeDeTime2 = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -964,10 +964,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "week[ -]?end|fin de semana"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleOrdinalQuarterYear :: Rule
|
||||
@ -1047,7 +1047,7 @@ ruleTwoTimeTokensSeparatedBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1085,8 +1085,8 @@ ruleThisPartofday = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> tt . partOfDay $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
(_:Token Time td:_) -> Token Time . partOfDay <$>
|
||||
intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1197,8 +1197,8 @@ ruleEntreDdEtDdMonthinterval = Rule
|
||||
_) -> do
|
||||
v1 <- parseInt m1
|
||||
v2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth v1, td)
|
||||
to = intersect (dayOfMonth v2, td)
|
||||
from <- intersectMB (dayOfMonth v1) td
|
||||
to <- intersectMB (dayOfMonth v2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1448,7 +1448,7 @@ ruleNthTimeDeTime = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,8 @@ ruleCePartofday = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> tt . partOfDay . notLatent $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
(_:Token Time td:_) -> Token Time . partOfDay . notLatent <$>
|
||||
intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -198,8 +198,8 @@ ruleDatetimeddMonthinterval = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token RegexMatch (GroupMatch (match:_)):Token Time td2:_) -> do
|
||||
n <- parseInt match
|
||||
let from = intersect (td2, td1)
|
||||
to = intersect (dayOfMonth n, td2)
|
||||
from <- intersectMB td2 td1
|
||||
to <- intersectMB (dayOfMonth n) td2
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -290,8 +290,8 @@ ruleDatetimedayofweekDdMonthinterval = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:_:Token RegexMatch (GroupMatch (match:_)):Token Time td2:_) -> do
|
||||
n <- parseInt match
|
||||
let from = intersect (td2, td1)
|
||||
to = intersect (dayOfMonth n, td2)
|
||||
from <- intersectMB td2 td1
|
||||
to <- intersectMB (dayOfMonth n) td2
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -477,7 +477,7 @@ ruleDimTimeDuMatin = Rule
|
||||
(Token Time td:_) ->
|
||||
let morning = partOfDay . mkLatent $
|
||||
interval TTime.Open (hour False 0, hour False 12)
|
||||
in tt $ intersect (td, morning)
|
||||
in Token Time <$> intersectMB td morning
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -492,9 +492,9 @@ ruleOrdinalWeekendDeTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
td2 = intersect (td, interval TTime.Open (from, to))
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
td2 <- intersectMB td (interval TTime.Open (from, to))
|
||||
tt $ predNth (n - 1) False td2
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -837,8 +837,8 @@ ruleDdddMonthinterval = Rule
|
||||
(Token RegexMatch (GroupMatch (m1:_)):_:Token RegexMatch (GroupMatch (m2:_)):Token Time td:_) -> do
|
||||
d1 <- parseInt m1
|
||||
d2 <- parseInt m2
|
||||
let from = intersect (td, dayOfMonth d1)
|
||||
to = intersect (td, dayOfMonth d2)
|
||||
from <- intersectMB td (dayOfMonth d1)
|
||||
to <- intersectMB td (dayOfMonth d2)
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -871,8 +871,8 @@ ruleDuDddayofweekDdMonthinterval = Rule
|
||||
(_:Token RegexMatch (GroupMatch (m1:_)):_:_:Token RegexMatch (GroupMatch (m2:_)):Token Time td:_) -> do
|
||||
d1 <- parseInt m1
|
||||
d2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth d1, td)
|
||||
to = intersect (dayOfMonth d2, td)
|
||||
from <- intersectMB (dayOfMonth d1) td
|
||||
to <- intersectMB (dayOfMonth d2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -885,10 +885,10 @@ ruleDbutNamedmonthinterval = Rule
|
||||
, Predicate isAMonth
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from = intersect (dayOfMonth 1, td)
|
||||
to = intersect (dayOfMonth 5, td)
|
||||
in tt $ interval TTime.Closed (from, to)
|
||||
(_:Token Time td:_) -> do
|
||||
from <- intersectMB (dayOfMonth 1) td
|
||||
to <- intersectMB (dayOfMonth 5) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1048,7 +1048,7 @@ ruleDimTimeDuSoir = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 16, hour False 0)
|
||||
in tt $ intersect (td, td2)
|
||||
in Token Time <$> intersectMB td td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1074,7 +1074,7 @@ ruleAprsLeDjeuner = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 13, hour False 17)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleIntersect :: Rule
|
||||
@ -1107,10 +1107,10 @@ rulePremireQuinzaineDeNamedmonthinterval = Rule
|
||||
, Predicate isAMonth
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from = intersect (dayOfMonth 1, td)
|
||||
to = intersect (dayOfMonth 14, td)
|
||||
in tt $ interval TTime.Closed (from, to)
|
||||
(_:Token Time td:_) -> do
|
||||
from <- intersectMB (dayOfMonth 1) td
|
||||
to <- intersectMB (dayOfMonth 14) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1169,7 +1169,7 @@ ruleAprsLeTravail = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 17, hour False 21)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleNamedmonth8 :: Rule
|
||||
@ -1193,7 +1193,7 @@ ruleLeDayofmonthDatetime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
tt $ intersect (dayOfMonth n, td)
|
||||
Token Time <$> intersectMB (dayOfMonth n) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1203,10 +1203,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "week(\\s|-)?end"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleCedansLeCycle :: Rule
|
||||
@ -1260,7 +1260,7 @@ ruleAvantLeDjeuner = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 10, hour False 12)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleDernierWeekendDeTime :: Rule
|
||||
@ -1271,10 +1271,10 @@ ruleDernierWeekendDeTime = Rule
|
||||
, Predicate isAMonth
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ predLastOf (interval TTime.Open (from, to)) td
|
||||
(_:Token Time td:_) -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ predLastOf (interval TTime.Open (from, to)) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1301,7 +1301,7 @@ ruleDimTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1354,10 +1354,10 @@ ruleDeuximeQuinzaineDeNamedmonthinterval = Rule
|
||||
, Predicate isAMonth
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from = intersect (dayOfMonth 15, td)
|
||||
to = cycleLastOf TG.Day td
|
||||
in tt $ interval TTime.Closed (from, to)
|
||||
(_:Token Time td:_) -> do
|
||||
from <- intersectMB (dayOfMonth 15) td
|
||||
let to = cycleLastOf TG.Day td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1371,7 +1371,7 @@ rulePartofdayDuDimTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1465,8 +1465,8 @@ ruleDuDatetimedayofweekDdMonthinterval = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:_:Token RegexMatch (GroupMatch (m:_)):Token Time td2:_) -> do
|
||||
n <- parseInt m
|
||||
let from = intersect (td2, td1)
|
||||
to = intersect (dayOfMonth n, td2)
|
||||
from <- intersectMB td2 td1
|
||||
to <- intersectMB (dayOfMonth n) td2
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1542,10 +1542,10 @@ ruleFinNamedmonthinterval = Rule
|
||||
, Predicate isAMonth
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from = intersect (dayOfMonth 25, td)
|
||||
to = cycleLastOf TG.Day td
|
||||
in tt $ interval TTime.Closed (from, to)
|
||||
(_:Token Time td:_) -> do
|
||||
from <- intersectMB (dayOfMonth 25) td
|
||||
let to = cycleLastOf TG.Day td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1631,8 +1631,8 @@ ruleEntreDdEtDdMonthinterval = Rule
|
||||
(_:Token RegexMatch (GroupMatch (m1:_)):_:Token RegexMatch (GroupMatch (m2:_)):Token Time td:_) -> do
|
||||
n1 <- parseInt m1
|
||||
n2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth n1, td)
|
||||
to = intersect (dayOfMonth n2, td)
|
||||
from <- intersectMB (dayOfMonth n1) td
|
||||
to <- intersectMB (dayOfMonth n2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -1864,10 +1864,10 @@ ruleSoirDeNol = Rule
|
||||
, pattern =
|
||||
[ regex "soir(\x00e9e)? de no(e|\x00eb)l"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (monthDay 12 24, hour False 18)
|
||||
to = intersect (monthDay 12 25, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (monthDay 12 24) (hour False 18)
|
||||
to <- intersectMB (monthDay 12 25) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleDayofweekDayofmonthTimeofday :: Rule
|
||||
@ -1881,7 +1881,7 @@ ruleDayofweekDayofmonthTimeofday = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:token:Token Time td2:_) -> do
|
||||
dom <- intersectDOM td1 token
|
||||
tt $ intersect (dom, td2)
|
||||
Token Time <$> intersectMB dom td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1955,10 +1955,10 @@ ruleNamedmonth13 = Rule
|
||||
, Predicate isAMonth
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from = intersect (dayOfMonth 10, td)
|
||||
to = intersect (dayOfMonth 19, td)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
(_:Token Time td:_) -> do
|
||||
from <- intersectMB (dayOfMonth 10) td
|
||||
to <- intersectMB (dayOfMonth 19) td
|
||||
tt $ interval TTime.Open (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1976,8 +1976,8 @@ ruleDayofweekErdayofweekDdMonthinterval = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:_:_:_:Token RegexMatch (GroupMatch (m:_)):Token Time td:_) -> do
|
||||
n <- parseInt m
|
||||
let from = intersect (dayOfMonth 1, td)
|
||||
to = intersect (dayOfMonth n, td)
|
||||
from <- intersectMB (dayOfMonth 1) td
|
||||
to <- intersectMB (dayOfMonth n) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
(token:Token Time td:Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||
intVal <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year intVal)
|
||||
Token Time <$> intersectMB dom (year intVal)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ module Duckling.Time.Helpers
|
||||
-- Production
|
||||
, cycleLastOf, cycleN, cycleNth, cycleNthAfter, dayOfMonth, dayOfWeek
|
||||
, daysOfWeekOfMonth, durationAfter, durationAgo, durationBefore, form, hour
|
||||
, hourMinute, hourMinuteSecond, inDuration, intersect, intersectDOM, interval
|
||||
, hourMinute, hourMinuteSecond, inDuration, intersectDOM, interval
|
||||
, inTimezone, longWEBefore, minute, minutesAfter, minutesBefore, mkLatent
|
||||
, month, monthDay, notLatent, nthDOWOfMonth, partOfDay, predLastOf, predNth
|
||||
, predNthAfter, second, timeOfDayAMPM, withDirection, year, yearMonthDay
|
||||
@ -486,7 +486,7 @@ nthDOWOfMonth n dow m = intersect (dowsM, week)
|
||||
intersectDOM :: TimeData -> Token -> Maybe TimeData
|
||||
intersectDOM td token = do
|
||||
n <- getIntValue token
|
||||
Just $ intersect (dayOfMonth n, td)
|
||||
intersectMB (dayOfMonth n) td
|
||||
|
||||
minutesBefore :: Int -> TimeData -> Maybe TimeData
|
||||
minutesBefore n TimeData {TTime.form = Just (TTime.TimeOfDay (Just 0) is12H)} =
|
||||
|
@ -113,7 +113,7 @@ ruleStanotte = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 1
|
||||
td2 = interval TTime.Open (hour False 0, hour False 4)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleDomattina :: Rule
|
||||
@ -125,7 +125,7 @@ ruleDomattina = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 1
|
||||
td2 = interval TTime.Open (hour False 4, hour False 12)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleNamedmonth12 :: Rule
|
||||
@ -181,7 +181,7 @@ ruleStamattina = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 4, hour False 12)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleNamedday2 :: Rule
|
||||
@ -310,8 +310,8 @@ ruleDdddMonthInterval = Rule
|
||||
_) -> do
|
||||
v1 <- parseInt m1
|
||||
v2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth v1, td)
|
||||
to = intersect (dayOfMonth v2, td)
|
||||
from <- intersectMB (dayOfMonth v1) td
|
||||
to <- intersectMB (dayOfMonth v2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -365,7 +365,7 @@ ruleNthTimeOfTime2 = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -497,8 +497,8 @@ ruleLeIdiDiNamedmonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13, td)
|
||||
Token Time <$>
|
||||
intersectMB (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1103,7 +1103,7 @@ ruleDimTimeAlPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1270,7 +1270,7 @@ rulePartofdayOfDimTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1286,7 +1286,7 @@ ruleDimTimeDelMattino = Rule
|
||||
let from = hour False 0
|
||||
to = hour False 12
|
||||
td2 = mkLatent . partOfDay $ interval TTime.Open (from, to)
|
||||
in tt $ intersect (td, td2)
|
||||
in Token Time <$> intersectMB td td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1360,7 +1360,7 @@ ruleTimeNotte = Rule
|
||||
(Token Time td:_) ->
|
||||
let td1 = cycleNthAfter False TG.Day 1 td
|
||||
td2 = interval TTime.Open (hour False 0, hour False 4)
|
||||
in tt $ intersect (td1, td2)
|
||||
in Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1382,7 +1382,7 @@ ruleStasera = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleSeason3 :: Rule
|
||||
@ -1433,7 +1433,7 @@ ruleInThePartofdayOfDimTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1479,7 +1479,7 @@ ruleTimeNotte2 = Rule
|
||||
(_:Token Time td:_) ->
|
||||
let td1 = cycleNthAfter False TG.Day 1 td
|
||||
td2 = interval TTime.Open (hour False 0, hour False 4)
|
||||
in tt $ intersect (td1, td2)
|
||||
in Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1561,8 +1561,8 @@ ruleTheNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1585,8 +1585,8 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1624,10 +1624,10 @@ ruleTimeofdayTimeofdayDayofmonthInterval = Rule
|
||||
, Predicate isNotLatent
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:Token Time td3:_) ->
|
||||
let from = intersect (td1, td3)
|
||||
to = intersect (td2, td3)
|
||||
in tt $ interval TTime.Closed (from, to)
|
||||
(Token Time td1:_:Token Time td2:Token Time td3:_) -> do
|
||||
from <- intersectMB td1 td3
|
||||
to <- intersectMB td2 td3
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1637,10 +1637,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "week[ -]?end|fine ?settimana|we"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleIlWeekendDelTime :: Rule
|
||||
@ -1651,12 +1651,12 @@ ruleIlWeekendDelTime = Rule
|
||||
, Predicate $ isGrainOfTime TG.Day
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
let from1 = intersect (cycleNthAfter False TG.Week 0 td, dayOfWeek 5)
|
||||
from = intersect (from1, hour False 18)
|
||||
to1 = intersect (cycleNthAfter False TG.Week 1 td, dayOfWeek 1)
|
||||
to = intersect (to1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
(_:Token Time td:_) -> do
|
||||
from1 <- intersectMB (cycleNthAfter False TG.Week 0 td) (dayOfWeek 5)
|
||||
from <- intersectMB from1 (hour False 18)
|
||||
to1 <- intersectMB (cycleNthAfter False TG.Week 1 td) (dayOfWeek 1)
|
||||
to <- intersectMB to1 (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1696,7 +1696,7 @@ ruleDimTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1780,7 +1780,7 @@ ruleTimeEntroLeTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt . withDirection TTime.Before $ intersect (td1, td2)
|
||||
Token Time . withDirection TTime.Before <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1834,8 +1834,8 @@ ruleNthTimeOfTime3 = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(_:Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1920,7 +1920,7 @@ ruleThisPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1960,7 +1960,7 @@ ruleTwoTimeTokensSeparatedByDi = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -2052,7 +2052,7 @@ ruleNight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 1
|
||||
td2 = interval TTime.Open (hour False 0, hour False 4)
|
||||
in tt . partOfDay . mkLatent $ intersect (td1, td2)
|
||||
in Token Time . partOfDay . mkLatent <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleOgnissanti :: Rule
|
||||
@ -2238,7 +2238,7 @@ ruleTwoTimeTokensInARow = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -2353,7 +2353,7 @@ ruleIntersectByDiDellaDel = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ ruleTimeNthTime = Rule
|
||||
(Token Time td1:
|
||||
Token Ordinal (OrdinalData {TOrdinal.value = v}):
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td1, td2)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -751,10 +751,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "\xc8fc\xb9d0"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleTimeDayofweek :: Rule
|
||||
@ -997,7 +997,7 @@ ruleAfterPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,8 @@ ruleNthTimeOfTime2 = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -405,9 +405,9 @@ ruleMonthDdddInterval = Rule
|
||||
_) -> do
|
||||
dd1 <- parseInt d1
|
||||
dd2 <- parseInt d2
|
||||
let dom1 = intersect (dayOfMonth dd1, td)
|
||||
dom2 = intersect (dayOfMonth dd2, td)
|
||||
in tt $ interval TTime.Closed (dom1, dom2)
|
||||
dom1 <- intersectMB (dayOfMonth dd1) td
|
||||
dom2 <- intersectMB (dayOfMonth dd2) td
|
||||
tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -484,8 +484,8 @@ ruleTheIdesOfNamedmonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13, td)
|
||||
Token Time <$>
|
||||
intersectMB (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -946,7 +946,7 @@ ruleAfterWork = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 17, hour False 21)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleLastNCycle :: Rule
|
||||
@ -1082,8 +1082,8 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1105,7 +1105,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1115,10 +1115,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "((week(\\s|-)?end)|helg)(en|a)?"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleEomendOfMonth :: Rule
|
||||
@ -1276,8 +1276,8 @@ ruleThisPartofday = Rule
|
||||
, Predicate isAPartOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) -> tt . partOfDay $
|
||||
intersect (cycleNth TG.Day 0, td)
|
||||
(_:Token Time td:_) -> Token Time . partOfDay <$>
|
||||
intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1329,7 +1329,7 @@ ruleAfterLunch = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 13, hour False 17)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleOnANamedday :: Rule
|
||||
@ -1497,7 +1497,7 @@ ruleTonight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleYear :: Rule
|
||||
@ -1706,7 +1706,7 @@ rulePartofdayOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1774,7 +1774,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
_) -> do
|
||||
y <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year y)
|
||||
Token Time <$> intersectMB dom (year y)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -346,9 +346,9 @@ ruleMonthDdddInterval = Rule
|
||||
:_) -> do
|
||||
dd1 <- parseInt d1
|
||||
dd2 <- parseInt d2
|
||||
let dom1 = intersect (dayOfMonth dd1, td)
|
||||
dom2 = intersect (dayOfMonth dd2, td)
|
||||
in tt $ interval TTime.Closed (dom1, dom2)
|
||||
dom1 <- intersectMB (dayOfMonth dd1) td
|
||||
dom2 <- intersectMB (dayOfMonth dd2) td
|
||||
tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -408,8 +408,8 @@ ruleTheIdesOfNamedmonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13, td)
|
||||
Token Time <$>
|
||||
intersectMB (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1054,8 +1054,8 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Ordinal od:Token Time td1:_:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1077,7 +1077,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1087,10 +1087,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "((wek|week|wik)(\\s|-)?end|wkend)"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleEomendOfMonth :: Rule
|
||||
@ -1220,7 +1220,7 @@ ruleThisPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1285,8 +1285,8 @@ ruleNthTimeTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Ordinal od:Token Time td1:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Ordinal od:Token Time td1:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1778,7 +1778,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
_) -> do
|
||||
y <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year y)
|
||||
Token Time <$> intersectMB dom (year y)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ ruleDimTimeDaMadrugada = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 1, hour False 4)
|
||||
in tt $ intersect (td, td2)
|
||||
in Token Time <$> intersectMB td td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ ruleSHourminTimeofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -625,7 +625,7 @@ rulePartofdayDessaSemana = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -711,7 +711,7 @@ ruleDimTimeDaManha = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 4, hour False 12)
|
||||
in tt $ intersect (td, td2)
|
||||
in Token Time <$> intersectMB td td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -767,8 +767,8 @@ ruleDdddMonthinterval = Rule
|
||||
_) -> do
|
||||
d1 <- parseInt m1
|
||||
d2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth d1, td)
|
||||
to = intersect (dayOfMonth d2, td)
|
||||
from <- intersectMB (dayOfMonth d1) td
|
||||
to <- intersectMB (dayOfMonth d2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -877,7 +877,7 @@ ruleAmanhPelaPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -931,7 +931,7 @@ ruleTimeofdayPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1007,7 +1007,7 @@ ruleDimTimeDaTarde = Rule
|
||||
(Token Time td:_) ->
|
||||
let td2 = mkLatent . partOfDay $
|
||||
interval TTime.Open (hour False 12, hour False 18)
|
||||
in tt $ intersect (td, td2)
|
||||
in Token Time <$> intersectMB td td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1017,10 +1017,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "final de semana|fim de semana|fds"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleDayofweekSHourmin :: Rule
|
||||
@ -1034,9 +1034,9 @@ ruleDayofweekSHourmin = Rule
|
||||
, Predicate isATimeOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_:Token Time td3:_) ->
|
||||
let td = intersect (td1, td2)
|
||||
in tt $ intersect (td, td3)
|
||||
(Token Time td1:_:Token Time td2:_:Token Time td3:_) -> do
|
||||
td <- intersectMB td1 td2
|
||||
Token Time <$> intersectMB td td3
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1164,7 +1164,7 @@ ruleTwoTimeTokensSeparatedBy = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1178,7 +1178,7 @@ ruleTwoTimeTokensSeparatedBy2 = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td2, td1)
|
||||
Token Time <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1204,7 +1204,7 @@ ruleThisPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1350,9 +1350,9 @@ ruleEntreDdEtDdMonthinterval = Rule
|
||||
_) -> do
|
||||
dd1 <- parseInt d1
|
||||
dd2 <- parseInt d2
|
||||
let dom1 = intersect (dayOfMonth dd1, td)
|
||||
dom2 = intersect (dayOfMonth dd2, td)
|
||||
in tt $ interval TTime.Closed (dom1, dom2)
|
||||
dom1 <- intersectMB (dayOfMonth dd1) td
|
||||
dom2 <- intersectMB (dayOfMonth dd2) td
|
||||
tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -190,8 +190,8 @@ ruleMonthDdddInterval = Rule
|
||||
_) -> do
|
||||
d1 <- parseInt m1
|
||||
d2 <- parseInt m2
|
||||
let dom1 = intersect (dayOfMonth d1, td)
|
||||
dom2 = intersect (dayOfMonth d2, td)
|
||||
dom1 <- intersectMB (dayOfMonth d1) td
|
||||
dom2 <- intersectMB (dayOfMonth d2) td
|
||||
tt $ interval TTime.Closed (dom1, dom2)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -499,7 +499,7 @@ ruleDiseara = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleIntersectBy :: Rule
|
||||
@ -777,7 +777,7 @@ ruleNthTimeOfTime = Rule
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:Token Time td1:_:Token Time td2:_) -> do
|
||||
v <- getIntValue token
|
||||
tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -799,7 +799,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -809,10 +809,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "(week(\\s|\\-)?end|wkend)"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let fri = intersect (dayOfWeek 5, hour False 18)
|
||||
mon = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (fri, mon)
|
||||
, prod = \_ -> do
|
||||
fri <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
mon <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (fri, mon)
|
||||
}
|
||||
|
||||
rulePeDayofmonthNonOrdinal :: Rule
|
||||
@ -860,7 +860,7 @@ rulePartofdayAsta = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1223,7 +1223,7 @@ ruleDayofmonthnumberNamedmonthYear = Rule
|
||||
_) -> do
|
||||
v <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year v)
|
||||
Token Time <$> intersectMB dom (year v)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ ruleNthTimeOfTime2 = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -397,8 +397,8 @@ ruleMonthDdddInterval = Rule
|
||||
_) -> do
|
||||
v1 <- parseInt m1
|
||||
v2 <- parseInt m2
|
||||
let from = intersect (dayOfMonth v1, td)
|
||||
to = intersect (dayOfMonth v2, td)
|
||||
from <- intersectMB (dayOfMonth v1) td
|
||||
to <- intersectMB (dayOfMonth v2) td
|
||||
tt $ interval TTime.Closed (from, to)
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -476,8 +476,8 @@ ruleTheIdesOfNamedmonth = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
|
||||
tt $
|
||||
intersect (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13, td)
|
||||
Token Time <$>
|
||||
intersectMB (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -941,7 +941,7 @@ ruleAfterWork = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 17, hour False 21)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleLastNCycle :: Rule
|
||||
@ -1081,7 +1081,7 @@ ruleNthTimeOfTime = Rule
|
||||
Token Time td1:
|
||||
_:
|
||||
Token Time td2:
|
||||
_) -> tt . predNth (v - 1) False $ intersect (td2, td1)
|
||||
_) -> Token Time . predNth (v - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1103,7 +1103,7 @@ ruleTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1113,10 +1113,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "((week(\\s|-)?end)|helg)(en)?"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleEomendOfMonth :: Rule
|
||||
@ -1279,7 +1279,7 @@ ruleThisPartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token Time td:_) ->
|
||||
tt . partOfDay $ intersect (cycleNth TG.Day 0, td)
|
||||
Token Time . partOfDay <$> intersectMB (cycleNth TG.Day 0) td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1331,7 +1331,7 @@ ruleAfterLunch = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 13, hour False 17)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleOnANamedday :: Rule
|
||||
@ -1498,7 +1498,7 @@ ruleTonight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day 0
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleYear :: Rule
|
||||
@ -1688,7 +1688,7 @@ rulePartofdayOfTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -1747,7 +1747,7 @@ ruleDayofmonthordinalNamedmonthYear = Rule
|
||||
_) -> do
|
||||
y <- parseInt match
|
||||
dom <- intersectDOM td token
|
||||
tt $ intersect (dom, year y)
|
||||
Token Time <$> intersectMB dom (year y)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
|
@ -279,8 +279,8 @@ ruleNthTimeOfTime2 = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:_:Token Ordinal od:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Time td1:_:Token Ordinal od:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -690,8 +690,8 @@ ruleNthTimeOfTime = Rule
|
||||
, dimension Time
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Ordinal od:Token Time td2:_) -> tt .
|
||||
predNth (TOrdinal.value od - 1) False $ intersect (td2, td1)
|
||||
(Token Time td1:Token Ordinal od:Token Time td2:_) -> Token Time .
|
||||
predNth (TOrdinal.value od - 1) False <$> intersectMB td2 td1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -710,10 +710,10 @@ ruleWeekend = Rule
|
||||
, pattern =
|
||||
[ regex "\x5468\x672b|\x9031\x672b"
|
||||
]
|
||||
, prod = \_ ->
|
||||
let from = intersect (dayOfWeek 5, hour False 18)
|
||||
to = intersect (dayOfWeek 1, hour False 0)
|
||||
in tt $ interval TTime.Open (from, to)
|
||||
, prod = \_ -> do
|
||||
from <- intersectMB (dayOfWeek 5) (hour False 18)
|
||||
to <- intersectMB (dayOfWeek 1) (hour False 0)
|
||||
tt $ interval TTime.Open (from, to)
|
||||
}
|
||||
|
||||
ruleLastYear :: Rule
|
||||
@ -734,7 +734,7 @@ ruleDimTimePartofday = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
@ -856,7 +856,7 @@ ruleLastNight = Rule
|
||||
, prod = \_ ->
|
||||
let td1 = cycleNth TG.Day $ - 1
|
||||
td2 = interval TTime.Open (hour False 18, hour False 0)
|
||||
in tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleTimeofdayAmpm :: Rule
|
||||
@ -934,7 +934,7 @@ rulePartofdayDimTime = Rule
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Time td1:Token Time td2:_) ->
|
||||
tt $ intersect (td1, td2)
|
||||
Token Time <$> intersectMB td1 td2
|
||||
_ -> 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 tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB 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 tt . partOfDay $ intersect (td1, td2)
|
||||
in Token Time . partOfDay <$> intersectMB td1 td2
|
||||
}
|
||||
|
||||
ruleNamedmonth10 :: Rule
|
||||
|
Loading…
Reference in New Issue
Block a user