{-# LANGUAGE GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.Time.IT.Rules
( rules
) where
import Data.Text (Text)
import Prelude
import qualified Data.Text as Text
import Duckling.Dimensions.Types
import Duckling.Duration.Helpers (isGrain)
import Duckling.Numeral.Helpers (parseInt)
import Duckling.Numeral.Types (NumeralData(..))
import Duckling.Ordinal.Types (OrdinalData(..))
import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Time.Types (TimeData(..))
import Duckling.Types
import qualified Duckling.Numeral.Types as TNumeral
import qualified Duckling.Ordinal.Types as TOrdinal
import qualified Duckling.Time.Types as TTime
import qualified Duckling.TimeGrain.Types as TG
ruleFestaDellaRepubblica :: Rule
ruleFestaDellaRepubblica :: Rule
ruleFestaDellaRepubblica = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"festa della repubblica"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((festa del)?la )?repubblica"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
6 Int
2
}
ruleEpifania :: Rule
ruleEpifania :: Rule
ruleEpifania = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"epifania"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(epifania|befana)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
1 Int
6
}
ruleDayofmonthNamedmonth :: Rule
ruleDayofmonthNamedmonth :: Rule
ruleDayofmonthNamedmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<day-of-month> <named-month>"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isDOMInteger
, Predicate -> PatternItem
Predicate Predicate
isAMonth
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> Token -> Maybe TimeData
intersectDOM a
TimeData
td Token
token
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTheDayAfterTomorrow :: Rule
ruleTheDayAfterTomorrow :: Rule
ruleTheDayAfterTomorrow = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the day after tomorrow"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(il giorno )?dopo\\s?domani"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth Grain
TG.Day Int
2
}
ruleInafterDuration :: Rule
ruleInafterDuration :: Rule
ruleInafterDuration = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"in/after <duration>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"[tf]ra|in|dopo"
, Dimension DurationData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension DurationData
Duration
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Duration a
dd:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ DurationData -> TimeData
inDuration a
DurationData
dd
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTheLastCycle :: Rule
ruleTheLastCycle :: Rule
ruleTheLastCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the last <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(([nd]el)?l' ?ultim|(il|la) passat|([nd]el)?l[ao] scors)[oa]"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (Int -> TimeData) -> Int -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Grain -> Int -> TimeData
cycleNth a
Grain
grain (Int -> Maybe Token) -> Int -> Maybe Token
forall a b. (a -> b) -> a -> b
$ - Int
1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleStanotte :: Rule
ruleStanotte :: Rule
ruleStanotte = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"stanotte"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(sta|nella )notte|(in|nella) nottata"
]
, prod :: Production
prod = \[Token]
_ -> do
let td1 :: TimeData
td1 = Grain -> Int -> TimeData
cycleNth Grain
TG.Day Int
1
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
0) (Bool -> Int -> TimeData
hour Bool
False Int
4)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
td1 TimeData
td2
}
ruleDomattina :: Rule
ruleDomattina :: Rule
ruleDomattina = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"domattina"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"domattina"
]
, prod :: Production
prod = \[Token]
_ -> do
let td1 :: TimeData
td1 = Grain -> Int -> TimeData
cycleNth Grain
TG.Day Int
1
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
4) (Bool -> Int -> TimeData
hour Bool
False Int
12)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
td1 TimeData
td2
}
ruleTheCycleNext :: Rule
ruleTheCycleNext :: Rule
ruleTheCycleNext = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the <cycle> next"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"l'|il|la|[nd]el(la)?"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"prossim[oa]"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleCycleNext :: Rule
ruleCycleNext :: Rule
ruleCycleNext = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<cycle> next"
, pattern :: Pattern
pattern =
[ Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"prossim[oa]"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
TimeGrain a
grain:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleFestaDellaLiberazione :: Rule
ruleFestaDellaLiberazione :: Rule
ruleFestaDellaLiberazione = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"festa della liberazione"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((festa|anniversario) della|(al)?la) liberazione"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
4 Int
25
}
ruleStamattina :: Rule
ruleStamattina :: Rule
ruleStamattina = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"stamattina"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"stamattina"
]
, prod :: Production
prod = \[Token]
_ -> do
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
4) (Bool -> Int -> TimeData
hour Bool
False Int
12)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
today TimeData
td2
}
ruleYearNotLatent :: Rule
ruleYearNotLatent :: Rule
ruleYearNotLatent = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"year (1000-2100 not latent)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1000 Int
2100
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
year Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleValentinesDay :: Rule
ruleValentinesDay :: Rule
ruleValentinesDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"valentine's day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"san valentino|festa degli innamorati"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
2 Int
14
}
ruleTheOrdinalCycleOfTime :: Rule
ruleTheOrdinalCycleOfTime :: Rule
ruleTheOrdinalCycleOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the <ordinal> <cycle> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l[a']|[nd]el(l[a'])?"
, Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"di|del(l[a'])?"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Ordinal a
od:Token Dimension a
TimeGrain a
grain:Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
True a
Grain
grain (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleOrdinalQuarter :: Rule
ruleOrdinalQuarter :: Rule
ruleOrdinalQuarter = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> quarter"
, pattern :: Pattern
pattern =
[ Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Grain -> Predicate
isGrain Grain
TG.Quarter
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
True Grain
TG.Quarter (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$
Grain -> Int -> TimeData
cycleNth Grain
TG.Year Int
0
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTheOrdinalQuarter :: Rule
ruleTheOrdinalQuarter :: Rule
ruleTheOrdinalQuarter = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the <ordinal> quarter"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|[nd]el(l')?|l'"
, Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Grain -> Predicate
isGrain Grain
TG.Quarter
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
True Grain
TG.Quarter (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$
Grain -> Int -> TimeData
cycleNth Grain
TG.Year Int
0
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleCycleOrdinalQuarterYear :: Rule
ruleCycleOrdinalQuarterYear :: Rule
ruleCycleOrdinalQuarterYear = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> quarter <year>"
, pattern :: Pattern
pattern =
[ Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Grain -> Predicate
isGrain Grain
TG.Quarter
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:Token
_:Token Dimension a
Time a
td:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False Grain
TG.Quarter (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleCycleTheOrdinalTime :: Rule
ruleCycleTheOrdinalTime :: Rule
ruleCycleTheOrdinalTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the <ordinal> <cycle> <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|[nd]el(l')?|l'"
, Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token Dimension a
TimeGrain a
grain:Token Dimension a
Time a
td:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
True a
Grain
grain (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDdddMonthInterval :: Rule
ruleDdddMonthInterval :: Rule
ruleDdddMonthInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dd-dd <month> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(3[01]|[12]\\d|0?[1-9])"
, String -> PatternItem
regex String
"\\-"
, String -> PatternItem
regex String
"(3[01]|[12]\\d|0?[1-9])"
, Predicate -> PatternItem
Predicate Predicate
isAMonth
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (m1:_)):
Token
_:
Token Dimension a
RegexMatch (GroupMatch (m2:_)):
Token Dimension a
Time a
td:
[Token]
_) -> do
Int
v1 <- Text -> Maybe Int
parseInt Text
m1
Int
v2 <- Text -> Maybe Int
parseInt Text
m2
TimeData
from <- TimeData -> TimeData -> Maybe TimeData
intersect (Int -> TimeData
dayOfMonth Int
v1) a
TimeData
td
TimeData
to <- TimeData -> TimeData -> Maybe TimeData
intersect (Int -> TimeData
dayOfMonth Int
v2) a
TimeData
td
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed TimeData
from TimeData
to
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeLast :: Rule
ruleTimeLast :: Rule
ruleTimeLast = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> last"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"(ultim|scors|passat)[oaie]"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> TimeData -> TimeData
predNth (-Int
1) Bool
False a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleThisDayofweek :: Rule
ruleThisDayofweek :: Rule
ruleThisDayofweek = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"this <day-of-week>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"quest[oaie]"
, Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> TimeData -> TimeData
predNth Int
0 Bool
True a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleUna :: Rule
ruleUna :: Rule
ruleUna = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"una"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"una"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> TimeData
hour Bool
True Int
1
}
ruleNthTimeOfTime2 :: Rule
ruleNthTimeOfTime2 :: Rule
ruleNthTimeOfTime2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"nth <time> of <time>"
, pattern :: Pattern
pattern =
[ Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"di|del(l[oa'])|in"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Ordinal OrdinalData {TOrdinal.value = v}:
Token Dimension a
Time a
td1:
Token
_:
Token Dimension a
Time a
td2:
[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Bool -> TimeData -> TimeData
predNth (Int
v Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Bool
False (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td2 a
TimeData
td1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNewYearsDay :: Rule
ruleNewYearsDay :: Rule
ruleNewYearsDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"new year's day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(capodanno|primo dell' ?anno)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
1 Int
1
}
ruleLastTime :: Rule
ruleLastTime :: Rule
ruleLastTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"last <time> "
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(ultim|scors|passat)[oaie]"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> TimeData -> TimeData
predNth (-Int
1) Bool
False a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleIlDayofmonthDeNamedmonth :: Rule
ruleIlDayofmonthDeNamedmonth :: Rule
ruleIlDayofmonthDeNamedmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"il <day-of-month> <named-month>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l'"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
, Predicate -> PatternItem
Predicate Predicate
isAMonth
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> Token -> Maybe TimeData
intersectDOM a
TimeData
td Token
token
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDatetimeDatetimeInterval :: Rule
ruleDatetimeDatetimeInterval :: Rule
ruleDatetimeDatetimeInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<datetime> - <datetime> (interval)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isNotLatent
, String -> PatternItem
regex String
"\\-|[fs]ino a(l(l[e'])?)?"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleEvening :: Rule
ruleEvening :: Rule
ruleEvening = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"evening"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ser(ata|[ae])"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Bool -> Int -> TimeData
hour Bool
False Int
18
to :: TimeData
to = Bool -> Int -> TimeData
hour Bool
False Int
0
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> TimeData)
-> (TimeData -> TimeData) -> TimeData -> TimeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleDayOfMonthSt :: Rule
ruleDayOfMonthSt :: Rule
ruleDayOfMonthSt = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"day of month (1st)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(primo|1o|1º|1°)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
dayOfMonth Int
1
}
ruleInDuration :: Rule
ruleInDuration :: Rule
ruleInDuration = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"in|entro <duration>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(in|entro)"
, Dimension DurationData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension DurationData
Duration
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (match:_)):
Token Dimension a
Duration a
dd:
[Token]
_) -> case Text -> Text
Text.toLower Text
match of
Text
"entro" -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
now (DurationData -> TimeData
inDuration a
DurationData
dd)
Text
"in" -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ DurationData -> TimeData
inDuration a
DurationData
dd
Text
_ -> Maybe Token
forall a. Maybe a
Nothing
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleInNamedmonth :: Rule
ruleInNamedmonth :: Rule
ruleInNamedmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"in <named-month>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"in|del mese( di)?"
, Predicate -> PatternItem
Predicate Predicate
isAMonth
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
x:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just Token
x
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleLeIdiDiNamedmonth :: Rule
ruleLeIdiDiNamedmonth :: Rule
ruleLeIdiDiNamedmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"le idi di <named-month>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(le )?idi di"
, Predicate -> PatternItem
Predicate Predicate
isAMonth
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time td :: a
td@TimeData {TTime.form = Just (TTime.Month m)}:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeData -> TimeData -> Maybe TimeData
intersect (Int -> TimeData
dayOfMonth (Int -> TimeData) -> Int -> TimeData
forall a b. (a -> b) -> a -> b
$ if Int -> [Int] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Int
m [Int
3, Int
5, Int
7, Int
10] then Int
15 else Int
13) a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleRightNow :: Rule
ruleRightNow :: Rule
ruleRightNow = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"right now"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(subito|(immediata|attual)mente|(proprio )?adesso|(in questo|al) momento|ora)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt TimeData
now
}
ruleToday :: Rule
ruleToday :: Rule
ruleToday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"today"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(di )?oggi|in giornata"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt TimeData
today
}
ruleLastCycleOfTime :: Rule
ruleLastCycleOfTime :: Rule
ruleLastCycleOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"last <cycle> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l')ultim[oa]"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"di|del(l[oa'])"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> TimeData -> TimeData
cycleLastOf a
Grain
grain a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhRelativeminutesDelPomeriggiotimeofday2 :: Rule
ruleHhRelativeminutesDelPomeriggiotimeofday2 :: Rule
ruleHhRelativeminutesDelPomeriggiotimeofday2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh <relative-minutes> del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
Token
_:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayIntegerAsRelativeMinutes :: Rule
ruleHourofdayIntegerAsRelativeMinutes :: Rule
ruleHourofdayIntegerAsRelativeMinutes = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> <integer> (as relative minutes)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> (Token -> [Bool]) -> Predicate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Predicate] -> Token -> [Bool]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Predicate
isNotLatent, Predicate
isAnHourOfDay]
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayAndRelativeMinutes :: Rule
ruleHourofdayAndRelativeMinutes :: Rule
ruleHourofdayAndRelativeMinutes = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> and <relative minutes>"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
Token
_:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleRelativeMinutesToIntegerAsHourofday :: Rule
ruleRelativeMinutesToIntegerAsHourofday :: Rule
ruleRelativeMinutesToIntegerAsHourofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"relative minutes to <integer> (as hour-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"a"
, Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:Token
_:Token Dimension a
Time a
td:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
n a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayMinusIntegerAsRelativeMinutes :: Rule
ruleHourofdayMinusIntegerAsRelativeMinutes :: Rule
ruleHourofdayMinusIntegerAsRelativeMinutes = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> minus <integer> (as relative minutes)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"meno"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:Token
_:Token
token:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
n a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhRelativeminutesDelPomeriggiotimeofday :: Rule
ruleHhRelativeminutesDelPomeriggiotimeofday :: Rule
ruleHhRelativeminutesDelPomeriggiotimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh <relative-minutes> del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> (Token -> [Bool]) -> Predicate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Predicate] -> Token -> [Bool]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Predicate
isNotLatent, Predicate
isAnHourOfDay]
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhIntegerminutesDelPomeriggiotimeofday2 :: Rule
ruleHhIntegerminutesDelPomeriggiotimeofday2 :: Rule
ruleHhIntegerminutesDelPomeriggiotimeofday2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh <relative-minutes> minutes del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"min(ut[oi]|\\.)? d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
Token
_:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayIntegerMinutes :: Rule
ruleHourofdayIntegerMinutes :: Rule
ruleHourofdayIntegerMinutes = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> <integer> minutes"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> (Token -> [Bool]) -> Predicate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Predicate] -> Token -> [Bool]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Predicate
isNotLatent, Predicate
isAnHourOfDay]
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"min(ut[oi]|\\.)?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayAndIntegerMinutes :: Rule
ruleHourofdayAndIntegerMinutes :: Rule
ruleHourofdayAndIntegerMinutes = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> and <integer> minutes"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"min(ut[oi]|\\.)?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
Token
_:
Token
token:
[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleMinutesToIntegerAsHourofday :: Rule
ruleMinutesToIntegerAsHourofday :: Rule
ruleMinutesToIntegerAsHourofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"minutes to <integer> (as hour-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"min(ut[oi]|\\.)? a"
, Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:Token
_:Token Dimension a
Time a
td:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
n a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayMinusIntegerMinutes :: Rule
ruleHourofdayMinusIntegerMinutes :: Rule
ruleHourofdayMinusIntegerMinutes = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> minus <integer> minutes"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"meno"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"min(ut[oi]|\\.)?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:
Token
_:
Token
token:
[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
v a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhIntegerminutesDelPomeriggiotimeofday :: Rule
ruleHhIntegerminutesDelPomeriggiotimeofday :: Rule
ruleHhIntegerminutesDelPomeriggiotimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh <integer> minutes del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
59
, String -> PatternItem
regex String
"min(ut[oi]|\\.)? d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
Token
token:
[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhQuartDelPomeriggiotimeofday2 :: Rule
ruleHhQuartDelPomeriggiotimeofday2 :: Rule
ruleHhQuartDelPomeriggiotimeofday2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh quart del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e un quarto d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
[Token]
_) ->
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
in TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
15
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayQuart :: Rule
ruleHourofdayQuart :: Rule
ruleHourofdayQuart = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> quart"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"un quarto"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
15
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayAndAQuart :: Rule
ruleHourofdayAndAQuart :: Rule
ruleHourofdayAndAQuart = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> and a quart"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e un quarto"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
15
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleQuartAsHourofday :: Rule
ruleQuartAsHourofday :: Rule
ruleQuartAsHourofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"a quart to <integer> (as hour-of-day)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"un quarto a"
, Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
15 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayMinusQuart :: Rule
ruleHourofdayMinusQuart :: Rule
ruleHourofdayMinusQuart = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> minus quart"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"meno un quarto"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
15 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhQuartDelPomeriggiotimeofday :: Rule
ruleHhQuartDelPomeriggiotimeofday :: Rule
ruleHhQuartDelPomeriggiotimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh quart del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"un quarto d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
[Token]
_) ->
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
in TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
15
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhHalfDelPomeriggiotimeofday2 :: Rule
ruleHhHalfDelPomeriggiotimeofday2 :: Rule
ruleHhHalfDelPomeriggiotimeofday2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh half del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e mezzo d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
[Token]
_) ->
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
in TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
30
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayHalf :: Rule
ruleHourofdayHalf :: Rule
ruleHourofdayHalf = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> half"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"mezzo"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
30
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayAndHalf :: Rule
ruleHourofdayAndHalf :: Rule
ruleHourofdayAndHalf = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> and half"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e mezzo"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
30
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHalfToIntegerAsHourofday :: Rule
ruleHalfToIntegerAsHourofday :: Rule
ruleHalfToIntegerAsHourofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"half to <integer> (as hour-of-day)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"mezzo a"
, Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
30 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayMinusHalf :: Rule
ruleHourofdayMinusHalf :: Rule
ruleHourofdayMinusHalf = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> minus half"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"meno mezzo"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
30 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhHalfDelPomeriggiotimeofday :: Rule
ruleHhHalfDelPomeriggiotimeofday :: Rule
ruleHhHalfDelPomeriggiotimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh half del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"mezzo d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
[Token]
_) ->
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
in TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
30
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhThreeQuarterDelPomeriggiotimeofday2 :: Rule
ruleHhThreeQuarterDelPomeriggiotimeofday2 :: Rule
ruleHhThreeQuarterDelPomeriggiotimeofday2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh three quarters del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e (3|tre) quarti? d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
[Token]
_) ->
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
in TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
45
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayThreeQuarters :: Rule
ruleHourofdayThreeQuarters :: Rule
ruleHourofdayThreeQuarters = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> three quarters"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"(3|tre) quarti?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
45
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayAndThreeQuarter :: Rule
ruleHourofdayAndThreeQuarter :: Rule
ruleHourofdayAndThreeQuarter = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> and three quarters"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"e (3|tre) quarti?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) is12H)}:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
is12H Int
hours Int
45
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleThreeQuarterToIntegerAsHourofday :: Rule
ruleThreeQuarterToIntegerAsHourofday :: Rule
ruleThreeQuarterToIntegerAsHourofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"three quarter to <integer> (as hour-of-day)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(3|tre) quarti? a"
, Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
45 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHourofdayMinusThreeQuarter :: Rule
ruleHourofdayMinusThreeQuarter :: Rule
ruleHourofdayMinusThreeQuarter = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<hour-of-day> minus three quarter"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"meno (3|tre) quarti?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> TimeData -> Maybe TimeData
minutesBefore Int
45 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhThreeQuarterDelPomeriggiotimeofday :: Rule
ruleHhThreeQuarterDelPomeriggiotimeofday :: Rule
ruleHhThreeQuarterDelPomeriggiotimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh three quarter del pomeriggio(time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAnHourOfDay
, String -> PatternItem
regex String
"(3|tre) quarti? d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
[Token]
_) ->
let h :: Int
h = if Int
hours Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
12 then Int
hours else Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12
in TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
45
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhhmmTimeofday :: Rule
ruleHhhmmTimeofday :: Rule
ruleHhhmmTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh(:|h)mm (time-of-day)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((?:[01]?\\d)|(?:2[0-3]))[:h]([0-5]\\d)"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (m1:m2:_)):[Token]
_) -> do
Int
h <- Text -> Maybe Int
parseInt Text
m1
Int
m <- Text -> Maybe Int
parseInt Text
m2
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
m
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDalIntAlInt :: Rule
ruleDalIntAlInt :: Rule
ruleDalIntAlInt = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dal <integer> al <integer> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"dal(?:l')?"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
, String -> PatternItem
regex String
"([fs]ino )?al(l')?"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token1:Token
_:Token
token2:[Token]
_) -> do
Int
v1 <- Token -> Maybe Int
getIntValue Token
token1
Int
v2 <- Token -> Maybe Int
getIntValue Token
token2
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed (Int -> TimeData
dayOfMonth Int
v1) (Int -> TimeData
dayOfMonth Int
v2)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTraIlIntEIlInt :: Rule
ruleTraIlIntEIlInt :: Rule
ruleTraIlIntEIlInt = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"tra il <integer> e il <integer> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"tra( (il|l'))?"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
, String -> PatternItem
regex String
"e( (il|l'))?"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token1:Token
_:Token
token2:[Token]
_) -> do
Int
v1 <- Token -> Maybe Int
getIntValue Token
token1
Int
v2 <- Token -> Maybe Int
getIntValue Token
token2
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed (Int -> TimeData
dayOfMonth Int
v1) (Int -> TimeData
dayOfMonth Int
v2)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeofdayOra :: Rule
ruleTimeofdayOra :: Rule
ruleTimeofdayOra = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time-of-day> ora"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"or[ea]"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNextTime2 :: Rule
ruleNextTime2 :: Rule
ruleNextTime2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"next <time>"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"dopo|prossim[ao]"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> TimeData -> TimeData
predNth Int
1 Bool
False a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleSantoStefano :: Rule
ruleSantoStefano :: Rule
ruleSantoStefano = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"santo stefano"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"s(anto|\\.) stefano"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
12 Int
26
}
ruleIlTime :: Rule
ruleIlTime :: Rule
ruleIlTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"il <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l'"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
x:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just Token
x
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleFestaDelPap :: Rule
ruleFestaDelPap :: Rule
ruleFestaDelPap = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"festa del papà"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"festa del pap(a|à)|(festa di )?s(an|\\.) giuseppe"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
3 Int
19
}
ruleEntroIlDuration :: Rule
ruleEntroIlDuration :: Rule
ruleEntroIlDuration = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"entro il <duration>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(entro|durante|per( tutt[ao])?) (il|l[a'])|in|nel(l[a'])?"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
now (Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
1)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDimTimeAlPartofday :: Rule
ruleDimTimeAlPartofday :: Rule
ruleDimTimeAlPartofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<dim time> al <part-of-day>"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"al|nel(la)?|in|d(i|el(la)?)"
, Predicate -> PatternItem
Predicate Predicate
isAPartOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleSeason4 :: Rule
ruleSeason4 :: Rule
ruleSeason4 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"season"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(in )?primavera"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Int -> Int -> TimeData
monthDay Int
3 Int
20
to :: TimeData
to = Int -> Int -> TimeData
monthDay Int
6 Int
21
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleYearLatent2 :: Rule
ruleYearLatent2 :: Rule
ruleYearLatent2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"year (latent)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
2101 Int
10000
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
year Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNoon :: Rule
ruleNoon :: Rule
ruleNoon = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"noon"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"mezz?ogiorno"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> TimeData
hour Bool
False Int
12
}
ruleTheDayBeforeYesterday :: Rule
ruleTheDayBeforeYesterday :: Rule
ruleTheDayBeforeYesterday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the day before yesterday"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l')?altro\\s?ieri"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (Int -> TimeData) -> Int -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Grain -> Int -> TimeData
cycleNth Grain
TG.Day (Int -> Maybe Token) -> Int -> Maybe Token
forall a b. (a -> b) -> a -> b
$ - Int
2
}
ruleNextCycle :: Rule
ruleNextCycle :: Rule
ruleNextCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"next <cycle> "
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((il|la|[nd]el(la)?) )?prossim[oa]"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDaysOfWeek :: [Rule]
ruleDaysOfWeek :: [Rule]
ruleDaysOfWeek = [(Text, String)] -> [Rule]
mkRuleDaysOfWeek
[ ( Text
"Lunedi" , String
"luned(i|ì)|lun?\\.?" )
, ( Text
"Martedi" , String
"marted(i|ì)|mar\\.?" )
, ( Text
"Mercoledi", String
"mercoled(i|ì)|mer\\.?" )
, ( Text
"Giovedi" , String
"gioved(i|ì)|gio\\.?" )
, ( Text
"Venerdi" , String
"venerd(i|ì)|ven\\.?" )
, ( Text
"Sabato" , String
"sabato|sab\\.?" )
, ( Text
"Domenica" , String
"domenica|dom\\.?" )
]
ruleMonths :: [Rule]
ruleMonths :: [Rule]
ruleMonths = [(Text, String)] -> [Rule]
mkRuleMonths
[ ( Text
"Gennaio" , String
"gennaio|genn?\\.?" )
, ( Text
"Febbraio" , String
"febbraio|febb?\\.?" )
, ( Text
"Marzo" , String
"marzo|mar\\.?" )
, ( Text
"Aprile" , String
"aprile|apr\\.?" )
, ( Text
"Maggio" , String
"maggio|magg?\\.?" )
, ( Text
"Giugno" , String
"giugno|giu\\.?" )
, ( Text
"Luglio" , String
"luglio|lug\\.?" )
, ( Text
"Agosto" , String
"agosto|ago\\.?" )
, ( Text
"Settembre", String
"settembre|sett?\\.?" )
, ( Text
"Ottobre" , String
"ottobre|ott\\.?" )
, ( Text
"Novembre" , String
"novembre|nov\\.?" )
, ( Text
"Dicembre" , String
"dicembre|dic\\.?" )
]
rulePeriodicHolidays :: [Rule]
rulePeriodicHolidays :: [Rule]
rulePeriodicHolidays = [(Text, String, TimeData)] -> [Rule]
mkRuleHolidays
[ ( Text
"Giornata dell'Africa", String
"giornata (dell('((unit(à|a)|unione) )?|a (liberazione|libert(à|a)) ))?africa(na)?", Int -> Int -> TimeData
monthDay Int
5 Int
25 )
, ( Text
"Giornata dell'Industrializzazione dell'Africa", String
"giornata (dell')?industrializzazione (dell')?africa(na)", Int -> Int -> TimeData
monthDay Int
11 Int
20 )
, ( Text
"Pesce d'aprile", String
"pesce d'aprile", Int -> Int -> TimeData
monthDay Int
4 Int
1 )
, ( Text
"Giornata della lingua araba", String
"giornata della lingua araba", Int -> Int -> TimeData
monthDay Int
12 Int
18 )
, ( Text
"Assunzione di Maria", String
"assunzione di maria", Int -> Int -> TimeData
monthDay Int
8 Int
15 )
, ( Text
"Boxing Day", String
"boxing day", Int -> Int -> TimeData
monthDay Int
12 Int
26 )
, ( Text
"Giornata della lingua cinese", String
"giornata della lingua cinese", Int -> Int -> TimeData
monthDay Int
4 Int
20 )
, ( Text
"Giornata della memoria per tutte le vittime della guerra chimica", String
"Giornata della memoria per tutte le vittime della guerra chimica", Int -> Int -> TimeData
monthDay Int
4 Int
29 )
, ( Text
"Giornata Internazionale della memoria delle vittime del genocidio del Rwanda", String
"giornata internazionale della (memoria|riflessione) (delle vittime )?del genocidio del rwanda", Int -> Int -> TimeData
monthDay Int
4 Int
7 )
, ( Text
"Giorno della gente di mare", String
"giornata (mondiale )? del( marittimo|la gente di mare)", Int -> Int -> TimeData
monthDay Int
6 Int
25 )
, ( Text
"Giornata della Terra", String
"giornata della terra", Int -> Int -> TimeData
monthDay Int
4 Int
22 )
, ( Text
"Giornata della lingua inglese", String
"giornata della lingua inglese", Int -> Int -> TimeData
monthDay Int
4 Int
23 )
, ( Text
"San Francesco d'Assisi", String
"san francesco d'assisi", Int -> Int -> TimeData
monthDay Int
10 Int
4 )
, ( Text
"Giorno dei genitori", String
"giorno dei genitori", Int -> Int -> TimeData
monthDay Int
6 Int
1 )
, ( Text
"Giornata Mondiale dei diritti umani", String
"giornata (mondiale )?dei diritti umani", Int -> Int -> TimeData
monthDay Int
12 Int
10 )
, ( Text
"Giornata Internazionale di sensibilizzazione sull'albinismo", String
"giornata internazionale di sensibilizzazione sull'albinismo", Int -> Int -> TimeData
monthDay Int
6 Int
13 )
, ( Text
"Giornata Internazionale Anticorruzione", String
"giornata internazionale anticorruzione", Int -> Int -> TimeData
monthDay Int
12 Int
9 )
, ( Text
"Giornata Internazionale Asteroid Day", String
"international asteroid day", Int -> Int -> TimeData
monthDay Int
6 Int
30 )
, ( Text
"Giornata Mondiale dell'orgoglio bisessuale", String
"giornata mondiale dell('orgoglio|a visibilit(a|à)) bisessuale", Int -> Int -> TimeData
monthDay Int
9 Int
23 )
, ( Text
"Giornata Internazionale della memoria sul disastro di Chernobyl", String
"giornata internazionale della memoria del disastro di chernobyl", Int -> Int -> TimeData
monthDay Int
4 Int
26 )
, ( Text
"Giornata Internazionale dell'aviazione civile", String
"giornata internazionale dell'aviazione civile", Int -> Int -> TimeData
monthDay Int
12 Int
7 )
, ( Text
"Giornata Internazionale delle dogane", String
"giornata internazionale delle dogane", Int -> Int -> TimeData
monthDay Int
1 Int
26 )
, ( Text
"Giornata Internazionale contro l'abuso di droghe e il traffico illecito", String
"giornata internazionale contro l'abuso di droghe e il traffico illecito", Int -> Int -> TimeData
monthDay Int
6 Int
26 )
, ( Text
"Giornata Internazionale contro i test nucleari", String
"giornata internazionale contro i test nucleari", Int -> Int -> TimeData
monthDay Int
8 Int
29 )
, ( Text
"Giornata Mondiale della biodiversità", String
"giornata mondiale della biodiversit(a|à)", Int -> Int -> TimeData
monthDay Int
5 Int
22 )
, ( Text
"Giornata Internazionale dei Monumenti e dei Siti", String
"giornata internazionale dei monumenti e dei siti", Int -> Int -> TimeData
monthDay Int
4 Int
18 )
, ( Text
"Giornata Internazionale per prevenire lo sfruttamento dell'ambiente in guerra e conflitti armati", String
"giornata internazionale per prevenire lo sfruttamento dell'ambiente in guerra e conflitti armati", Int -> Int -> TimeData
monthDay Int
11 Int
6 )
, ( Text
"Giornata Internazionale per la Cooperazione Sud-Sud", String
"giornata internazionale per la Cooperazione sud(\\-|\\s)sud", Int -> Int -> TimeData
monthDay Int
9 Int
12 )
, ( Text
"Giornata Internazionale della tolleranza", String
"giornata internazionale della tolleranza", Int -> Int -> TimeData
monthDay Int
11 Int
16 )
, ( Text
"Giornata Internazionale per l'abolizione della schiavitù", String
"giornata internazionale per l'abolizione della schiavit(u|ù)", Int -> Int -> TimeData
monthDay Int
12 Int
2 )
, ( Text
"Giornata Internazionale per l'eliminazione della discriminazione razziale", String
"giornata internazionale per l'eliminazione della discriminazione razziale", Int -> Int -> TimeData
monthDay Int
3 Int
21 )
, ( Text
"Giornata Internazionale contro la violenza sessuale nei conflitti armati", String
"giornata internazionale contro la violenza sessuale nei conflitti( armati)?", Int -> Int -> TimeData
monthDay Int
6 Int
19 )
, ( Text
"Giornata Internazionale per l'eliminazione della violenza contro le donne", String
"giornata internazionale per l'eliminazione della violenza contro le donne", Int -> Int -> TimeData
monthDay Int
11 Int
25 )
, ( Text
"Giornata Internazionale contro la Povertà", String
"giornata internazionale (contro |per l'e(radic|limin)azione del)la povert(a|à)", Int -> Int -> TimeData
monthDay Int
10 Int
17 )
, ( Text
"Giornata Internazionale per la preservazione dello strato di ozono", String
"giornata internazionale per la preservazione dello strato di ozono", Int -> Int -> TimeData
monthDay Int
9 Int
16 )
, ( Text
"Giornata Internazionale per la Commemorazione della Tratta degli Schiavi e la sua abolizione", String
"giornata internazionale per la commemorazione della tratta degli schiavi e la sua abolizione", Int -> Int -> TimeData
monthDay Int
8 Int
23 )
, ( Text
"Giornata Internazionale per il diritto alla verità sulle gravi violazioni dei diritti umani e per la dignità delle vittime", String
"giornata internazionale per il diritto alla verit(a|à) sulle gravi violazioni dei diritti umani e per la dignit(a|à) delle vittime", Int -> Int -> TimeData
monthDay Int
3 Int
24 )
, ( Text
"Giornata Internazionale per l'eliminazione totale delle armi nucleari", String
"giornata internazionale per l'eliminazione totale delle armi nucleari", Int -> Int -> TimeData
monthDay Int
9 Int
26 )
, ( Text
"Giornata Internazionale a sostegno delle vittime di tortura", String
"giornata Internazionale a sostegno delle vittime di tortura", Int -> Int -> TimeData
monthDay Int
6 Int
26 )
, ( Text
"Giornata Internazionale della Carità", String
"giornata internazionale della carit(a|à)", Int -> Int -> TimeData
monthDay Int
9 Int
5 )
, ( Text
"Giornata Internazionale di commemorazione in memoria delle vittime dell'Olocausto", String
"giornata internazionale di commemorazione in memoria delle vittime dell'olocausto", Int -> Int -> TimeData
monthDay Int
1 Int
27 )
, ( Text
"Giornata Internazionale della Democrazia", String
"giornata internazionale della democrazia", Int -> Int -> TimeData
monthDay Int
9 Int
15 )
, ( Text
"Giornata Internazionale delle persone con disabilità", String
"giornata internazionale delle persone con disabilit(a|à)", Int -> Int -> TimeData
monthDay Int
12 Int
3 )
, ( Text
"Giornata Internazionale della Famiglia", String
"giornata internazionale dell(a|e) famigli(a|e)", Int -> Int -> TimeData
monthDay Int
5 Int
15 )
, ( Text
"Giornata Internazionale delle Rimesse Familiari", String
"giornata Internazionale delle rimesse familiari", Int -> Int -> TimeData
monthDay Int
6 Int
16 )
, ( Text
"Giornata Internazionale delle foreste", String
"giornata internazionale delle foreste", Int -> Int -> TimeData
monthDay Int
3 Int
21 )
, ( Text
"Giornata Internazionale dell'amicizia", String
"giornata internazionale dell'amicizia", Int -> Int -> TimeData
monthDay Int
7 Int
30 )
, ( Text
"Giornata Internazionale della Felicità", String
"giornata internazionale della felicit(a|à)", Int -> Int -> TimeData
monthDay Int
3 Int
20 )
, ( Text
"Giornata Mondiale del volo umano nello spazio", String
"giornata mondiale del volo umano nello spazio", Int -> Int -> TimeData
monthDay Int
4 Int
12 )
, ( Text
"Giornata Internazionale dei bambini innocenti vittime di aggressioni", String
"giornata internazionale dei bambini innocenti vittime di aggressioni", Int -> Int -> TimeData
monthDay Int
6 Int
4 )
, ( Text
"Giornata Internazionale della nonviolenza", String
"giornata internazionale della nonviolenza", Int -> Int -> TimeData
monthDay Int
10 Int
2 )
, ( Text
"Giornata Internazionale di Nowruz", String
"giornata internazionale di nowruz", Int -> Int -> TimeData
monthDay Int
3 Int
21 )
, ( Text
"Giornata Internazionale delle Persone Anziane", String
"giornata internazionale delle persone anziane", Int -> Int -> TimeData
monthDay Int
10 Int
1 )
, ( Text
"Giornata Internazionale della pace", String
"giornata internazionale della pace", Int -> Int -> TimeData
monthDay Int
9 Int
21 )
, ( Text
"Giornata Internazionale in ricordo delle vittime delle schiavitù e della tratta transatlantica degli schiavi", String
"giornata internazionale in ricordo delle vittime delle schiavitù e della tratta transatlantica degli schiavi", Int -> Int -> TimeData
monthDay Int
3 Int
25 )
, ( Text
"Giornata Internazionale delle donne rurali", String
"giornata internazionale delle donne rurali", Int -> Int -> TimeData
monthDay Int
10 Int
15 )
, ( Text
"Giornata di solidarietà con i funzionari detenuti o scomparsi", String
"giornata di solidariet(a|à) con i funzionari detenuti o scomparsi", Int -> Int -> TimeData
monthDay Int
3 Int
25 )
, ( Text
"Giornata Internazionale di solidarietà per il popolo palestinese", String
"giornata internazionale della solidariet(a|à) con il popolo palestinese", Int -> Int -> TimeData
monthDay Int
11 Int
29 )
, ( Text
"Giornata Internazionale dello sport per lo sviluppo e la pace", String
"giornata internazionale dello sport per lo sviluppo e la pace", Int -> Int -> TimeData
monthDay Int
4 Int
6 )
, ( Text
"Giornata Internazionale dei Peacekeepers delle Nazioni Unite", String
"giornata internazionale dei peacekeepers delle nazioni unite", Int -> Int -> TimeData
monthDay Int
5 Int
29 )
, ( Text
"Giornata Mondiale per le donne e le ragazze nella scienza", String
"giornata mondiale per le donne e le ragazze nella scienza", Int -> Int -> TimeData
monthDay Int
2 Int
11 )
, ( Text
"Giornata Internazionale dello Yoga", String
"giornata internazionale dello yoga", Int -> Int -> TimeData
monthDay Int
6 Int
21 )
, ( Text
"Giornata Internazionale sulla tolleranza zero nei confronti delle mutilazioni genitali femminili", String
"giornata internazionale sulla tolleranza zero nei confronti delle mutilazioni genitali femminili", Int -> Int -> TimeData
monthDay Int
2 Int
6 )
, ( Text
"Giornata Mondiale delle bambine e delle ragazze", String
"giornata mondiale delle bambine e delle ragazze", Int -> Int -> TimeData
monthDay Int
10 Int
11 )
, ( Text
"Giornata Internazionale vittime sparizione forzata", String
"giornata internazionale vittime sparizione forzata", Int -> Int -> TimeData
monthDay Int
8 Int
30 )
, ( Text
"Giornata Internazionale dei popoli indigeni del mondo", String
"giornata internazionale dei popoli indigeni( del mondo)?", Int -> Int -> TimeData
monthDay Int
8 Int
9 )
, ( Text
"Giornata Internazionale per mettere fine all'impunità per i crimini contro i giornalisti", String
"giornata internazionale per mettere fine all'impunit(a|à) per i crimini contro i giornalisti", Int -> Int -> TimeData
monthDay Int
11 Int
2 )
, ( Text
"Giornata Internazionale per l'Eliminazione della Fistola Ostetrica", String
"giornata internazionale per l'eliminazione della fistola ostetrica", Int -> Int -> TimeData
monthDay Int
5 Int
23 )
, ( Text
"Giornata Internazionale per la Riduzione dei Disastri Naturali", String
"giornata internazionale per la riduzione dei disastri naturali", Int -> Int -> TimeData
monthDay Int
10 Int
13 )
, ( Text
"Giornata Internazionale della solidarietà umana", String
"giornata internazionale della solidarietà umana", Int -> Int -> TimeData
monthDay Int
12 Int
20 )
, ( Text
"Giornata Internazionale Jazz Day", String
"international jazz day", Int -> Int -> TimeData
monthDay Int
4 Int
30 )
, ( Text
"Giornata Internazionale dell'alfabetizzazione", String
"giornata internazionale dell'alfabetizzazione", Int -> Int -> TimeData
monthDay Int
9 Int
8 )
, ( Text
"Giornata Internazionale dell'uomo", String
"giornata internazionale dell'uomo", Int -> Int -> TimeData
monthDay Int
11 Int
19 )
, ( Text
"Giornata Internazionale del Migrante", String
"giornata internazionale del migrante", Int -> Int -> TimeData
monthDay Int
12 Int
18 )
, ( Text
"Giornata Internazionale della lingua madre", String
"giornata internazionale della lingua madre", Int -> Int -> TimeData
monthDay Int
2 Int
21 )
, ( Text
"Giornata Internazionale della Montagna", String
"giornata internazionale della montagna", Int -> Int -> TimeData
monthDay Int
12 Int
11 )
, ( Text
"Giornata Internazionale dell'infermiere", String
"giornata internazionale dell'infermiere", Int -> Int -> TimeData
monthDay Int
5 Int
12 )
, ( Text
"Giornata Internazionale contro l'Overdose", String
"giornata internazionale contro l'overdose", Int -> Int -> TimeData
monthDay Int
8 Int
31 )
, ( Text
"Giornata Internazionale del Volontariato per lo Sviluppo Economico e Sociale", String
"giornata internazionale del volontariato per lo sviluppo economico e sociale", Int -> Int -> TimeData
monthDay Int
12 Int
5 )
, ( Text
"Giornata Internazionale delle Vedove", String
"giornata internazionale delle vedove", Int -> Int -> TimeData
monthDay Int
6 Int
23 )
, ( Text
"Giornata Internazionale della donna", String
"giornata internazionale della donna", Int -> Int -> TimeData
monthDay Int
3 Int
8 )
, ( Text
"Giornata Mondiale della gioventù", String
"giornata mondiale della giovent(u|ù)", Int -> Int -> TimeData
monthDay Int
8 Int
12 )
, ( Text
"Giornata Internazionale Nelson Mandela", String
"giornata (internazionale )?nelson mandela", Int -> Int -> TimeData
monthDay Int
7 Int
18 )
, ( Text
"Natale Ortodosso", String
"natale ortodosso", Int -> Int -> TimeData
monthDay Int
1 Int
7 )
, ( Text
"Capodanno ortodosso", String
"capodanno ortodosso", Int -> Int -> TimeData
monthDay Int
1 Int
14 )
, ( Text
"Giornata del servizio pubblico", String
"giornata del servizio pubblico", Int -> Int -> TimeData
monthDay Int
6 Int
23 )
, ( Text
"Giorno di San Giorgio", String
"(giorno di )?san giorgio", Int -> Int -> TimeData
monthDay Int
4 Int
23 )
, ( Text
"Festa di San Patrizio", String
"((festa|giorno) di )?san patrizio", Int -> Int -> TimeData
monthDay Int
3 Int
17 )
, ( Text
"Ricordo e Riconciliazione per Coloro che Hanno Perso la Vita Durante la Seconda Guerra Mondiale", String
"ricordo e riconciliazione per coloro che hanno perso la vita durante la seconda guerra mondiale", Int -> Int -> TimeData
monthDay Int
5 Int
8 )
, ( Text
"Giornata delle Nazioni Unite", String
"giornata delle nazioni unite", Int -> Int -> TimeData
monthDay Int
10 Int
24 )
, ( Text
"United Nations' Mine Awareness Day", String
"united nations'? mine awareness day", Int -> Int -> TimeData
monthDay Int
4 Int
4 )
, ( Text
"United Nations' World Health Day", String
"united nations'? world health day", Int -> Int -> TimeData
monthDay Int
4 Int
7 )
, ( Text
"Universal Children's Day", String
"universal children'?s day", Int -> Int -> TimeData
monthDay Int
11 Int
20 )
, ( Text
"Giornata Mondiale contro l'AIDS", String
"giornata mondiale contro l'aids", Int -> Int -> TimeData
monthDay Int
12 Int
1 )
, ( Text
"Giornata Mondiale per la consapevolezza sull'autismo", String
"giornata mondiale per la consapevolezza sull'autismo", Int -> Int -> TimeData
monthDay Int
4 Int
2 )
, ( Text
"Giornata Mondiale del Lupus", String
"giornata mondiale del lupus", Int -> Int -> TimeData
monthDay Int
5 Int
10 )
, ( Text
"Giornata Mondiale del donatore di sangue", String
"giornata mondiale del donatore di sangue", Int -> Int -> TimeData
monthDay Int
6 Int
14 )
, ( Text
"Giornata Mondiale del libro e del diritto d'autore", String
"giornata mondiale del libro e del( diritto d'autore|le rose)", Int -> Int -> TimeData
monthDay Int
4 Int
23 )
, ( Text
"Giornata Mondiale dell'alfabeto braille", String
"giornata mondiale del(l'alfabeto)? braille", Int -> Int -> TimeData
monthDay Int
1 Int
4 )
, ( Text
"Giornata Mondiale contro il cancro", String
"giornata mondiale contro il cancro", Int -> Int -> TimeData
monthDay Int
2 Int
4 )
, ( Text
"Giornata Mondiale della città", String
"giornata mondiale della citt(a|à)", Int -> Int -> TimeData
monthDay Int
10 Int
31 )
, ( Text
"Giornata Mondiale della paralisi cerebrale infantile", String
"giornata mondiale della paralisi cerebrale( infantile)?", Int -> Int -> TimeData
monthDay Int
10 Int
6 )
, ( Text
"World Day Against Child Labour", String
"world day against child labour", Int -> Int -> TimeData
monthDay Int
6 Int
12 )
, ( Text
"Giornata Mondiale contro la tratta di esseri umani", String
"giornata mondiale contro la tratta di esseri umani", Int -> Int -> TimeData
monthDay Int
7 Int
30 )
, ( Text
"Giornata Mondiale del Patrimonio Audiovisivo", String
"giornata mondiale del patrimonio audiovisivo", Int -> Int -> TimeData
monthDay Int
10 Int
27 )
, ( Text
"Giornata Mondiale della diversità culturale per il dialogo e lo sviluppo", String
"giornata mondiale della diversit(a|à) culturale per il dialogo e lo sviluppo", Int -> Int -> TimeData
monthDay Int
5 Int
21 )
, ( Text
"Giornata Mondiale per la salute e sicurezza sul lavoro", String
"giornata mondiale per la salute e sicurezza sul lavoro", Int -> Int -> TimeData
monthDay Int
4 Int
28 )
, ( Text
"Giornata Internazionale per l'abolizione della schiavitù", String
"giornata internazionale per l'abolizione della schiavit(u|û)", Int -> Int -> TimeData
monthDay Int
12 Int
2 )
, ( Text
"Giornata Mondiale della giustizia sociale", String
"giornata mondiale della giustizia sociale", Int -> Int -> TimeData
monthDay Int
2 Int
20 )
, ( Text
"Giornata Mondiale del malato", String
"giornata mondiale del malato", Int -> Int -> TimeData
monthDay Int
2 Int
11 )
, ( Text
"Giornata Mondiale per la lotta alla desertificazione e alla siccità", String
"giornata mondiale per la lotta alla desertificazione e alla siccit(a|à)", Int -> Int -> TimeData
monthDay Int
6 Int
17 )
, ( Text
"Giornata Mondiale dell'informazione sullo Sviluppo", String
"giornata mondiale dell'informazione sullo sviluppo", Int -> Int -> TimeData
monthDay Int
10 Int
24 )
, ( Text
"Giornata Mondiale del diabete", String
"giornata mondiale del diabete", Int -> Int -> TimeData
monthDay Int
11 Int
14 )
, ( Text
"Giornata Mondiale sulla Sindrome di Down", String
"giornata mondiale (de|su)lla sindrome di down", Int -> Int -> TimeData
monthDay Int
3 Int
21 )
, ( Text
"Giornata Mondiale contro gli abusi sugli anziani", String
"giornata mondiale contro gli abusi sugli anziani", Int -> Int -> TimeData
monthDay Int
6 Int
15 )
, ( Text
"Giornata Mondiale dell'ambiente", String
"giornata mondiale dell'ambiente", Int -> Int -> TimeData
monthDay Int
6 Int
5 )
, ( Text
"Giornata Mondiale dell'alimentazione", String
"giornata mondiale dell'alimentazione", Int -> Int -> TimeData
monthDay Int
10 Int
16 )
, ( Text
"Giornata Internazionale per la Commemorazione e la Dignità delle vittime di Genocidio e della prevenzione di questo crimine", String
"giornata internazionale per la commemorazione (e la dignit(a|à) )?delle vittime di genocidio( e della prevenzione di questo crimine)?", Int -> Int -> TimeData
monthDay Int
12 Int
9 )
, ( Text
"Giornata Mondiale del cuore", String
"giornata mondiale del cuore", Int -> Int -> TimeData
monthDay Int
9 Int
29 )
, ( Text
"Giornata Mondiale dell'epatitey", String
"giornata mondiale dell'epatite", Int -> Int -> TimeData
monthDay Int
7 Int
28 )
, ( Text
"Giornata Mondiale dell'aiuto umanitario", String
"giornata mondiale dell'aiuto umanitario", Int -> Int -> TimeData
monthDay Int
8 Int
19 )
, ( Text
"Giornata Mondiale delle Telecomunicazioni e della società dell'informazione", String
"giornata mondiale (delle Telecomunicazioni e )?della societ(a|à) dell'informazione", Int -> Int -> TimeData
monthDay Int
5 Int
17 )
, ( Text
"Giornata Mondiale della proprietà intellettuale", String
"giornata mondiale della propriet(a|à) intellettuale", Int -> Int -> TimeData
monthDay Int
4 Int
26 )
, ( Text
"Giornata Mondiale contro la malaria", String
"giornata mondiale contro la malaria", Int -> Int -> TimeData
monthDay Int
4 Int
25 )
, ( Text
"Giornata Mondiale della salute mentale", String
"giornata mondiale della salute mentale", Int -> Int -> TimeData
monthDay Int
10 Int
10 )
, ( Text
"Giornata Mondiale della meteorologia", String
"giornata mondiale della meteorologia", Int -> Int -> TimeData
monthDay Int
3 Int
23 )
, ( Text
"Giornata Mondiale senza tabacco", String
"giornata mondiale senza tabacco", Int -> Int -> TimeData
monthDay Int
5 Int
31 )
, ( Text
"Giornata Mondiale degli oceani", String
"giornata mondiale degli oceani", Int -> Int -> TimeData
monthDay Int
6 Int
8 )
, ( Text
"Giornata Mondiale sul Tumore Ovarico", String
"giornata mondiale sul tumore ovarico", Int -> Int -> TimeData
monthDay Int
5 Int
8 )
, ( Text
"Giornata Mondiale contro la polmonite", String
"giornata mondiale contro la polmonite", Int -> Int -> TimeData
monthDay Int
11 Int
12 )
, ( Text
"Giornata Mondiale della Poesia", String
"giornata mondiale della poesia", Int -> Int -> TimeData
monthDay Int
3 Int
21 )
, ( Text
"Giornata Mondiale della popolazione", String
"giornata mondiale della popolazione", Int -> Int -> TimeData
monthDay Int
7 Int
11 )
, ( Text
"Giornata Mondiale della Posta", String
"giornata mondiale della posta", Int -> Int -> TimeData
monthDay Int
10 Int
9 )
, ( Text
"Giornata Mondiale della Prematurità", String
"giornata mondiale de(lla|i) (prematuri(t(a|à))?)", Int -> Int -> TimeData
monthDay Int
11 Int
17 )
, ( Text
"Giornata Mondiale della libertà di stampa", String
"giornata mondiale della libert(a|à) di stampa", Int -> Int -> TimeData
monthDay Int
5 Int
3 )
, ( Text
"Giornata Mondiale contro la rabbia", String
"giornata mondiale contro la rabbia", Int -> Int -> TimeData
monthDay Int
9 Int
28 )
, ( Text
"Giornata Mondiale della radio", String
"giornata mondiale della radio", Int -> Int -> TimeData
monthDay Int
2 Int
13 )
, ( Text
"Giornata Mondiale dei profughi", String
"giornata mondiale de(i profughi|l rifugiato)", Int -> Int -> TimeData
monthDay Int
6 Int
20 )
, ( Text
"Giornata Mondiale della scienza per pace e sviluppo", String
"giornata mondiale della scienza per pace e sviluppo", Int -> Int -> TimeData
monthDay Int
11 Int
10 )
, ( Text
"Giornata Mondiale del Benessere Sessuale", String
"giornata mondiale del benessere sessuale", Int -> Int -> TimeData
monthDay Int
9 Int
4 )
, ( Text
"Giornata Mondiale del Suolo", String
"giornata mondiale del suolo", Int -> Int -> TimeData
monthDay Int
12 Int
5 )
, ( Text
"Giornata Mondiale dell'Ictus", String
"giornata mondiale dell'icuts", Int -> Int -> TimeData
monthDay Int
10 Int
29 )
, ( Text
"Giornata Mondiale per la Prevenzione del Suicidio", String
"giornata mondiale per la prevenzione del suicidio", Int -> Int -> TimeData
monthDay Int
9 Int
10 )
, ( Text
"Giornata Mondiale dell'insegnante", String
"giornata mondiale de(gli |ll')insegnant(e|i)", Int -> Int -> TimeData
monthDay Int
10 Int
5 )
, ( Text
"Giornata Mondiale Della Televisione", String
"giornata mondiale della televisione", Int -> Int -> TimeData
monthDay Int
11 Int
21 )
, ( Text
"Giornata Mondiale del gabinetto", String
"giornata mondiale del gabinetto", Int -> Int -> TimeData
monthDay Int
11 Int
19 )
, ( Text
"Giornata Mondiale del turismo", String
"giornata mondiale del turismo", Int -> Int -> TimeData
monthDay Int
9 Int
27 )
, ( Text
"Giornata Mondiale della tubercolosi", String
"giornata mondiale della tubercolosi", Int -> Int -> TimeData
monthDay Int
3 Int
24 )
, ( Text
"Giornata Mondiale del Tonno", String
"giornata mondiale del tonno", Int -> Int -> TimeData
monthDay Int
5 Int
2 )
, ( Text
"Giornata Mondiale dei Vegani", String
"giornata mondiale (de(i|l) )?vegan(i|o|ismo)?", Int -> Int -> TimeData
monthDay Int
11 Int
1 )
, ( Text
"Giornata Mondiale dei Vegetariani", String
"giornata mondiale de(i|l) vegetari(smo|ani)", Int -> Int -> TimeData
monthDay Int
10 Int
1 )
, ( Text
"Giornata Mondiale dell'acqua", String
"giornata mondiale dell'acqua", Int -> Int -> TimeData
monthDay Int
3 Int
22 )
, ( Text
"Giornata Mondiale delle zone umide", String
"giornata mondiale delle zone umide", Int -> Int -> TimeData
monthDay Int
2 Int
2 )
, ( Text
"Giornata Mondiale della Vita Selvatica", String
"giornata mondiale della (fauna|vita) selvatica", Int -> Int -> TimeData
monthDay Int
3 Int
3 )
, ( Text
"Giornata Internazionale delle competenze giovanili", String
"giornata internazionale delle competenze giovanili", Int -> Int -> TimeData
monthDay Int
7 Int
15 )
, ( Text
"Giornata Mondiale contro la discriminazione", String
"giornata mondiale contro la discriminazione", Int -> Int -> TimeData
monthDay Int
3 Int
1 )
, ( Text
"Giornata Mondiale in memoria delle vittime della strada"
, String
"Giornata (Mondiale )?in memoria delle vittime della strada"
, Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
3 Int
7 Int
11 )
, ( Text
"Giornata Internazionale delle cooperative"
, String
"giornata internazionale delle cooperative", Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
1 Int
6 Int
7 )
, ( Text
"Martin Luther King's Day"
, String
"((MLK|martin luther king,?)( jr\\.?| junior)? day|giornata dei diritti civili)"
, Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
3 Int
1 Int
1
)
, ( Text
"Black Friday", String
"black friday"
, Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False Grain
TG.Day Int
1 (TimeData -> TimeData) -> TimeData -> TimeData
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
4 Int
4 Int
11
)
, ( Text
"Giornata Mondiale dell'Habitat", String
"giornata mondiale dell'habitat", Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
1 Int
1 Int
10 )
, ( Text
"Giornata Mondiale del Rene", String
"giornata mondiale del rene", Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
2 Int
4 Int
3 )
, ( Text
"Giornata Mondiale per i malati di lebbra", String
"giornata mondiale per i malati di lebbra"
, TimeData -> TimeData -> TimeData
predLastOf (Int -> TimeData
dayOfWeek Int
7) (Int -> TimeData
month Int
1) )
, ( Text
"Giornata Mondiale del Mare", String
"giornata mondiale del mare"
, TimeData -> TimeData -> TimeData
predLastOf (Int -> TimeData
dayOfWeek Int
4) (Int -> TimeData
month Int
9) )
, ( Text
"Giornata Mondiale degli uccelli migratori", String
"giornata mondiale degli uccelli migratori"
, Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
2 Int
6 Int
5 )
, ( Text
"Giornata Mondiale della filosofia", String
"giornata mondiale della filosofia", Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
3 Int
4 Int
11 )
, ( Text
"Giornata Mondiale della religione", String
"giornata mondiale della religione", Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
3 Int
7 Int
1 )
, ( Text
"Giornata Mondiale della vista", String
"giornata mondiale della vista", Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
2 Int
4 Int
10 )
]
ruleTheCycleOfTime :: Rule
ruleTheCycleOfTime :: Rule
ruleTheCycleOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the <cycle> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|la"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"del"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
True a
Grain
grain Int
0 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleLunch :: Rule
ruleLunch :: Rule
ruleLunch = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"lunch"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(a )?pranzo"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Bool -> Int -> TimeData
hour Bool
False Int
12
to :: TimeData
to = Bool -> Int -> TimeData
hour Bool
False Int
14
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> TimeData)
-> (TimeData -> TimeData) -> TimeData -> TimeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleDdmm :: Rule
ruleDdmm :: Rule
ruleDdmm = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dd[/-]mm"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(3[01]|[12]\\d|0?[1-9])[/-](0?[1-9]|1[0-2])"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (m1:m2:_)):[Token]
_) -> do
Int
d <- Text -> Maybe Int
parseInt Text
m1
Int
m <- Text -> Maybe Int
parseInt Text
m2
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
m Int
d
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleGliUltimiNCycle :: Rule
ruleGliUltimiNCycle :: Rule
ruleGliUltimiNCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"gli ultimi <n> <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((([nd]el)?le|([nd]e)?gli) )?(scors|ultim)[ei]"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
2 Int
9999
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token Dimension a
TimeGrain a
grain:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData
cycleN Bool
True a
Grain
grain (- Int
v)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleAfternoon :: Rule
ruleAfternoon :: Rule
ruleAfternoon = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"afternoon"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"pomeriggio?"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Bool -> Int -> TimeData
hour Bool
False Int
12
to :: TimeData
to = Bool -> Int -> TimeData
hour Bool
False Int
19
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> TimeData)
-> (TimeData -> TimeData) -> TimeData -> TimeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
rulePartofdayOfDimTime :: Rule
rulePartofdayOfDimTime :: Rule
rulePartofdayOfDimTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<part-of-day> of <dim time>"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isAPartOfDay
, String -> PatternItem
regex String
"d(i|el)"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDimTimeDelMattino :: Rule
ruleDimTimeDelMattino :: Rule
ruleDimTimeDelMattino = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<dim time> del mattino"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, String -> PatternItem
regex String
"del mattino"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> do
let from :: TimeData
from = Bool -> Int -> TimeData
hour Bool
False Int
0
to :: TimeData
to = Bool -> Int -> TimeData
hour Bool
False Int
12
TimeData
td2 <- TimeData -> TimeData
mkLatent (TimeData -> TimeData)
-> (TimeData -> TimeData) -> TimeData -> TimeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> TimeData) -> Maybe TimeData -> Maybe TimeData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleMidnight :: Rule
ruleMidnight :: Rule
ruleMidnight = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"midnight"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"mez?zanott?e"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> TimeData
hour Bool
False Int
0
}
ruleChristmasEve :: Rule
ruleChristmasEve :: Rule
ruleChristmasEve = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"christmas eve"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((al)?la )?vigig?lia( di natale)?"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
12 Int
24
}
ruleNthTimeAfterTime :: Rule
ruleNthTimeAfterTime :: Rule
ruleNthTimeAfterTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"nth <time> after <time>"
, pattern :: Pattern
pattern =
[ Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"dopo"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Ordinal OrdinalData{TOrdinal.value = v}:
Token Dimension a
Time a
td1:
Token
_:
Token Dimension a
Time a
td2:
[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData -> TimeData -> TimeData
predNthAfter (Int
v Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhhmmTimeofday2 :: Rule
ruleHhhmmTimeofday2 :: Rule
ruleHhhmmTimeofday2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hh(:|h)mm (time-of-day)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((?:0?\\d)|(?:1[0-2]))[:h]([0-5]\\d) d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (m1:m2:_)):[Token]
_) -> do
Int
v1 <- Text -> Maybe Int
parseInt Text
m1
Int
v2 <- Text -> Maybe Int
parseInt Text
m2
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False (Int
v1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
12) Int
v2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeNotte :: Rule
ruleTimeNotte :: Rule
ruleTimeNotte = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> notte"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"((in|nella|alla) )?nott(e|ata)"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> do
let td1 :: TimeData
td1 = Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False Grain
TG.Day Int
1 a
TimeData
td
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
0) (Bool -> Int -> TimeData
hour Bool
False Int
4)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
td1 TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleStasera :: Rule
ruleStasera :: Rule
ruleStasera = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"stasera"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"stasera"
]
, prod :: Production
prod = \[Token]
_ -> do
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
18) (Bool -> Int -> TimeData
hour Bool
False Int
0)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
today TimeData
td2
}
ruleSeason3 :: Rule
ruleSeason3 :: Rule
ruleSeason3 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"season"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(in )?inverno"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Int -> Int -> TimeData
monthDay Int
12 Int
21
to :: TimeData
to = Int -> Int -> TimeData
monthDay Int
3 Int
20
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleSeason :: Rule
ruleSeason :: Rule
ruleSeason = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"season"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(in )?estate"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Int -> Int -> TimeData
monthDay Int
6 Int
21
to :: TimeData
to = Int -> Int -> TimeData
monthDay Int
9 Int
23
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleIntegerLatentTimeofday :: Rule
ruleIntegerLatentTimeofday :: Rule
ruleIntegerLatentTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<integer> (latent time-of-day)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
0 Int
24
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> TimeData
hour Bool
False Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleInThePartofdayOfDimTime :: Rule
ruleInThePartofdayOfDimTime :: Rule
ruleInThePartofdayOfDimTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"in the <part-of-day> of <dim time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"nel(la)?"
, Predicate -> PatternItem
Predicate Predicate
isAPartOfDay
, String -> PatternItem
regex String
"d(i|el)"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNewYearsEve :: Rule
ruleNewYearsEve :: Rule
ruleNewYearsEve = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"new year's eve"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((la )?vigig?lia di capodanno|san silvestro)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
12 Int
31
}
ruleFerragosto :: Rule
ruleFerragosto :: Rule
ruleFerragosto = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"ferragosto"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ferragosto|assunzione"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
8 Int
15
}
ruleDurationAgo :: Rule
ruleDurationAgo :: Rule
ruleDurationAgo = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<duration> ago"
, pattern :: Pattern
pattern =
[ Dimension DurationData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension DurationData
Duration
, String -> PatternItem
regex String
"fa"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Duration a
dd:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ DurationData -> TimeData
durationAgo a
DurationData
dd
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeNotte2 :: Rule
ruleTimeNotte2 :: Rule
ruleTimeNotte2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> notte"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((nella|alla) )?nott(e|ata)( d(i|el))"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> do
let td1 :: TimeData
td1 = Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False Grain
TG.Day Int
1 a
TimeData
td
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
0) (Bool -> Int -> TimeData
hour Bool
False Int
4)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
td1 TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeofdayPrecise :: Rule
ruleTimeofdayPrecise :: Rule
ruleTimeofdayPrecise = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time-of-day> precise"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, String -> PatternItem
regex String
"precise"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHhmmMilitaryTimeofday :: Rule
ruleHhmmMilitaryTimeofday :: Rule
ruleHhmmMilitaryTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"hhmm (military time-of-day)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((?:[01]?\\d)|(?:2[0-3]))([0-5]\\d)"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (m1:m2:_)):[Token]
_) -> do
Int
h <- Text -> Maybe Int
parseInt Text
m1
Int
m <- Text -> Maybe Int
parseInt Text
m2
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> Int -> TimeData
hourMinute Bool
False Int
h Int
m
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTheCycleLast :: Rule
ruleTheCycleLast :: Rule
ruleTheCycleLast = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the <cycle> last"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"l'|il|la|[nd]el(la)?"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"(scors|passat)[oa]"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (Int -> TimeData) -> Int -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Grain -> Int -> TimeData
cycleNth a
Grain
grain (Int -> Maybe Token) -> Int -> Maybe Token
forall a b. (a -> b) -> a -> b
$ - Int
1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleFinoAlDatetimeInterval :: Rule
ruleFinoAlDatetimeInterval :: Rule
ruleFinoAlDatetimeInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"fino al <datetime> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"[fs]ino a(l(l[ae'])?)?"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
now a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleAtTimeofday :: Rule
ruleAtTimeofday :: Rule
ruleAtTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"at <time-of-day>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(al)?l[e']|a"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTheNthTimeOfTime :: Rule
ruleTheNthTimeOfTime :: Rule
ruleTheNthTimeOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"the nth <time> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l[a']|[nd]el(l[a'])?"
, Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"di|del(l[a'])?"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Ordinal a
od:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> Bool -> TimeData -> TimeData
predNth (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Bool
False (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td2 a
TimeData
td1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNthTimeOfTime :: Rule
ruleNthTimeOfTime :: Rule
ruleNthTimeOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"nth <time> of <time>"
, pattern :: Pattern
pattern =
[ Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"di|del(l[a'])?"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Ordinal a
od:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> Bool -> TimeData -> TimeData
predNth (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Bool
False (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td2 a
TimeData
td1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDalDatetimeAlDatetimeInterval :: Rule
ruleDalDatetimeAlDatetimeInterval :: Rule
ruleDalDatetimeAlDatetimeInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dal <datetime> al <datetime> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"da(l(l')?)?"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
, String -> PatternItem
regex String
"([fs]ino )?a(l(l')?)?"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeofdayTimeofdayDayofmonthInterval :: Rule
ruleTimeofdayTimeofdayDayofmonthInterval :: Rule
ruleTimeofdayTimeofdayDayofmonthInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time-of-day> - <time-of-day> <day-of-month> (interval)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, String -> PatternItem
regex String
"\\-"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:Token Dimension a
Time a
td3:[Token]
_) -> do
TimeData
from <- TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td3
TimeData
to <- TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td2 a
TimeData
td3
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed TimeData
from TimeData
to
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleWeekend :: Rule
ruleWeekend :: Rule
ruleWeekend = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"week-end"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"week[ -]?end|fine ?settimana|we"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt TimeData
weekend
}
ruleIlWeekendDelTime :: Rule
ruleIlWeekendDelTime :: Rule
ruleIlWeekendDelTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"il week-end del <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il (week[ -]?end|fine ?settimana|we) del"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Grain -> Predicate
isGrainOfTime Grain
TG.Day
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> do
TimeData
from1 <- TimeData -> TimeData -> Maybe TimeData
intersect (Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False Grain
TG.Week Int
0 a
TimeData
td) (Int -> TimeData
dayOfWeek Int
5)
TimeData
from <- TimeData -> TimeData -> Maybe TimeData
intersect TimeData
from1 (Bool -> Int -> TimeData
hour Bool
False Int
18)
TimeData
to1 <- TimeData -> TimeData -> Maybe TimeData
intersect (Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False Grain
TG.Week Int
1 a
TimeData
td) (Int -> TimeData
dayOfWeek Int
1)
TimeData
to <- TimeData -> TimeData -> Maybe TimeData
intersect TimeData
to1 (Bool -> Int -> TimeData
hour Bool
False Int
0)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleEomendOfMonth :: Rule
ruleEomendOfMonth :: Rule
ruleEomendOfMonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"EOM|End of month"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"fine del mese"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth Grain
TG.Month Int
1
}
ruleCommemorazioneDeiDefunti :: Rule
ruleCommemorazioneDeiDefunti :: Rule
ruleCommemorazioneDeiDefunti = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"commemorazione dei defunti"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(((giorno|commemorazione) dei|ai) )?(morti|defunti)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
11 Int
2
}
ruleImmacolataConcezione :: Rule
ruleImmacolataConcezione :: Rule
ruleImmacolataConcezione = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"immacolata concezione"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(all')?immacolata( concezione)?"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
12 Int
8
}
ruleDimTimePartofday :: Rule
ruleDimTimePartofday :: Rule
ruleDimTimePartofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<dim time> <part-of-day>"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, Predicate -> PatternItem
Predicate Predicate
isAPartOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTraIlDatetimeEIlDatetimeInterval :: Rule
ruleTraIlDatetimeEIlDatetimeInterval :: Rule
ruleTraIlDatetimeEIlDatetimeInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"tra il <datetime> e il <datetime> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"tra( il| l')?"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, String -> PatternItem
regex String
"e( il| l')?"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNthTimeAfterTime2 :: Rule
ruleNthTimeAfterTime2 :: Rule
ruleNthTimeAfterTime2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"nth <time> after <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l'"
, Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"dopo"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Ordinal a
od:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData -> TimeData -> TimeData
predNthAfter (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDopoLeTimeofday :: Rule
ruleDopoLeTimeofday :: Rule
ruleDopoLeTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dopo le <time-of-day>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"dopo( l['ea'])?|dal(l['ea'])?"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.After (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDopoTime :: Rule
ruleDopoTime :: Rule
ruleDopoTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dopo <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"dopo|dal?"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.After a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDalInt :: Rule
ruleDalInt :: Rule
ruleDalInt = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dal <integer"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"dal"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.After (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
dayOfMonth Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeEntroLeTime :: Rule
ruleTimeEntroLeTime :: Rule
ruleTimeEntroLeTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> entro le <time>"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"entro( l[e'])?|prima d(i|ell['ea])"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.Before (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleEntroTime :: Rule
ruleEntroTime :: Rule
ruleEntroTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"entro <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"entro( la)?|prima d(i|ella)"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.Before a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleEntroIlInt :: Rule
ruleEntroIlInt :: Rule
ruleEntroIlInt = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"entro il <integer>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"entro il|prima del"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.Before (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
dayOfMonth Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNextTime :: Rule
ruleNextTime :: Rule
ruleNextTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"next <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"prossim[ao]"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> TimeData -> TimeData
predNth Int
1 Bool
False a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNthTimeOfTime3 :: Rule
ruleNthTimeOfTime3 :: Rule
ruleNthTimeOfTime3 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"nth <time> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l'"
, Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"di|del(l[oa'])|in"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Ordinal a
od:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> Bool -> TimeData -> TimeData
predNth (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Bool
False (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td2 a
TimeData
td1
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleIlCycleDopoTime :: Rule
ruleIlCycleDopoTime :: Rule
ruleIlCycleDopoTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"il <cycle> dopo <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"l[a']|il|[nd]el"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"dopo"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
False a
Grain
grain Int
1 a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleYyyymmdd :: Rule
ruleYyyymmdd :: Rule
ruleYyyymmdd = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"yyyy-mm-dd"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(\\d{2,4})-(0?[1-9]|1[0-2])-(3[01]|[12]\\d|0?[1-9])"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (yy:mm:dd:_)):[Token]
_) -> do
Int
y <- Text -> Maybe Int
parseInt Text
yy
Int
m <- Text -> Maybe Int
parseInt Text
mm
Int
d <- Text -> Maybe Int
parseInt Text
dd
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int -> TimeData
yearMonthDay Int
y Int
m Int
d
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNextNCycle :: Rule
ruleNextNCycle :: Rule
ruleNextNCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"next n <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((([nd]e)?i|([nd]el)?le) )?prossim[ei]"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
2 Int
9999
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token Dimension a
TimeGrain a
grain:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData
cycleN Bool
True a
Grain
grain Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleMorning :: Rule
ruleMorning :: Rule
ruleMorning = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"morning"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"mattin(ata|[aoe])"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Bool -> Int -> TimeData
hour Bool
False Int
4
to :: TimeData
to = Bool -> Int -> TimeData
hour Bool
False Int
12
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> TimeData)
-> (TimeData -> TimeData) -> TimeData -> TimeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleTheDayofmonth :: Rule
ruleTheDayofmonth :: Rule
ruleTheDayofmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"il <day-of-month>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"il|l'"
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
dayOfMonth Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleThisPartofday :: Rule
ruleThisPartofday :: Rule
ruleThisPartofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"this <part-of-day>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(que)?st[oa]|i[nl]|(al|nel)(la)?|la"
, Predicate -> PatternItem
Predicate Predicate
isAPartOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
today a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleThisCycle :: Rule
ruleThisCycle :: Rule
ruleThisCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"this <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(in )?quest['oa]|per (il|l['a])"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
0
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleThisTime :: Rule
ruleThisTime :: Rule
ruleThisTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"this <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"quest[oaie']"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> TimeData -> TimeData
predNth Int
0 Bool
False a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTwoTimeTokensSeparatedByDi :: Rule
ruleTwoTimeTokensSeparatedByDi :: Rule
ruleTwoTimeTokensSeparatedByDi = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"two time tokens separated by `di`"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isNotLatent
, String -> PatternItem
regex String
"di"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeofdayCirca :: Rule
ruleTimeofdayCirca :: Rule
ruleTimeofdayCirca = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time-of-day> circa"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, String -> PatternItem
regex String
"circa"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleYearLatent :: Rule
ruleYearLatent :: Rule
ruleYearLatent = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"year (latent)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween (- Int
10000) (-Int
1)
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:[Token]
_) -> do
Int
n <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
year Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleYesterday :: Rule
ruleYesterday :: Rule
ruleYesterday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"yesterday"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ieri"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (Int -> TimeData) -> Int -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Grain -> Int -> TimeData
cycleNth Grain
TG.Day (Int -> Maybe Token) -> Int -> Maybe Token
forall a b. (a -> b) -> a -> b
$ - Int
1
}
ruleSeason2 :: Rule
ruleSeason2 :: Rule
ruleSeason2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"season"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(in )?autunno"
]
, prod :: Production
prod = \[Token]
_ ->
let from :: TimeData
from = Int -> Int -> TimeData
monthDay Int
9 Int
23
to :: TimeData
to = Int -> Int -> TimeData
monthDay Int
12 Int
21
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open TimeData
from TimeData
to
}
ruleCircaPerLeTimeofday :: Rule
ruleCircaPerLeTimeofday :: Rule
ruleCircaPerLeTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"circa per le <time-of-day>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(circa )?per( le)?|circa( alle)?|verso( le)?"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleVersoPartOfDay :: Rule
ruleVersoPartOfDay :: Rule
ruleVersoPartOfDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"verso <part-of-day>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"verso( la| il)?"
, Predicate -> PatternItem
Predicate Predicate
isAPartOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleChristmas :: Rule
ruleChristmas :: Rule
ruleChristmas = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"christmas"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((il )?giorno di )?natale"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
12 Int
25
}
ruleNight :: Rule
ruleNight :: Rule
ruleNight = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"night"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"nott(e|ata)"
]
, prod :: Production
prod = \[Token]
_ -> do
let td1 :: TimeData
td1 = Grain -> Int -> TimeData
cycleNth Grain
TG.Day Int
1
TimeData
td2 <- TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Open (Bool -> Int -> TimeData
hour Bool
False Int
0) (Bool -> Int -> TimeData
hour Bool
False Int
4)
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> (TimeData -> TimeData) -> TimeData -> Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
partOfDay (TimeData -> TimeData)
-> (TimeData -> TimeData) -> TimeData -> TimeData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeData -> TimeData
mkLatent (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect TimeData
td1 TimeData
td2
}
ruleOgnissanti :: Rule
ruleOgnissanti :: Rule
ruleOgnissanti = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"ognissanti"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(tutti i |ognis|festa dei |([ia]l )?giorno dei )santi"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
11 Int
1
}
ruleIntegerDelPartOfDay :: Rule
ruleIntegerDelPartOfDay :: Rule
ruleIntegerDelPartOfDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<integer 0 12> del <part of day>"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
0 Int
12
, String -> PatternItem
regex String
"d(i|el(la)?) (pomeriggio|(sta)?(sera|notte))"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Numeral NumeralData{TNumeral.value = v}:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> TimeData
hour Bool
False (Int
12 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Double -> Int
forall a b. (RealFrac a, Integral b) => a -> b
floor Double
v)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleOrdinalCycleOfTime :: Rule
ruleOrdinalCycleOfTime :: Rule
ruleOrdinalCycleOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> <cycle> of <time>"
, pattern :: Pattern
pattern =
[ Dimension OrdinalData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension OrdinalData
Ordinal
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"di|del(l[a'])?"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Ordinal a
od:Token Dimension a
TimeGrain a
grain:Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData -> TimeData
cycleNthAfter Bool
True a
Grain
grain (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleGliNUltimiCycle :: Rule
ruleGliNUltimiCycle :: Rule
ruleGliNUltimiCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"gli <n> ultimi <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"([nd]e)?i|([nd]el)?le"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
2 Int
9999
, String -> PatternItem
regex String
"(scors|ultim)[ei]"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData
cycleN Bool
True a
Grain
grain (- Int
v)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDalleTimeofdayAlleTimeofdayInterval :: Rule
ruleDalleTimeofdayAlleTimeofdayInterval :: Rule
ruleDalleTimeofdayAlleTimeofdayInterval = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dalle <time-of-day> alle <time-of-day> (interval)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"da(ll[ae'])?"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
, String -> PatternItem
regex String
"\\-|([fs]ino )?a(ll[ae'])?"
, Predicate -> PatternItem
Predicate Predicate
isATimeOfDay
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleEntroLeTimeofday :: Rule
ruleEntroLeTimeofday :: Rule
ruleEntroLeTimeofday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"entro le <time-of-day>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"entro( l[ea'])?|prima d(i|ell['e])"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token)
-> (TimeData -> TimeData) -> TimeData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntervalDirection -> TimeData -> TimeData
withDirection IntervalDirection
TTime.Before (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData
notLatent a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleHalloweenDay :: Rule
ruleHalloweenDay :: Rule
ruleHalloweenDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"halloween day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"hall?owe?en"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
10 Int
31
}
ruleLastDayofweekOfTime :: Rule
ruleLastDayofweekOfTime :: Rule
ruleLastDayofweekOfTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"last <day-of-week> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(([nd]el)?l')?ultim[oa]"
, Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
, String -> PatternItem
regex String
"di|del(l[a'])?"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData -> TimeData
predLastOf a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleNameddayDayofmonth :: Rule
ruleNameddayDayofmonth :: Rule
ruleNameddayDayofmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<named-day> <day-of-month>"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
, Predicate -> PatternItem
Predicate Predicate
isDOMInteger
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:Token
token:[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> Token -> Maybe TimeData
intersectDOM a
TimeData
td Token
token
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleLastDayofweekOfTime2 :: Rule
ruleLastDayofweekOfTime2 :: Rule
ruleLastDayofweekOfTime2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"last <day-of-week> of <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l')ultim[oa]"
, Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
, String -> PatternItem
regex String
"di"
, Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ TimeData -> TimeData -> TimeData
predLastOf a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleDdmmyyyy :: Rule
ruleDdmmyyyy :: Rule
ruleDdmmyyyy = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dd[/-]mm[/-]yyyy"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(3[01]|[12]\\d|0?[1-9])[/-](0?[1-9]|1[0-2])[/-](\\d{2,4})"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
RegexMatch (GroupMatch (m1:m2:m3:_)):[Token]
_) -> do
Int
y <- Text -> Maybe Int
parseInt Text
m3
Int
m <- Text -> Maybe Int
parseInt Text
m2
Int
d <- Text -> Maybe Int
parseInt Text
m1
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int -> TimeData
yearMonthDay Int
y Int
m Int
d
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTwoTimeTokensInARow :: Rule
ruleTwoTimeTokensInARow :: Rule
ruleTwoTimeTokensInARow = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"two time tokens in a row"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isNotLatent
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleIleNCyclePassatipassate :: Rule
ruleIleNCyclePassatipassate :: Rule
ruleIleNCyclePassatipassate = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"i|le n <cycle> passati|passate"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"([nd]e)?i|([nd]el)?le"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
2 Int
9999
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"(scors|passat)[ie]"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token Dimension a
TimeGrain a
grain:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData
cycleN Bool
True a
Grain
grain (- Int
v)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleEoyendOfYear :: Rule
ruleEoyendOfYear :: Rule
ruleEoyendOfYear = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"EOY|End of year"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"fine dell' ?anno"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth Grain
TG.Year Int
1
}
ruleTomorrow :: Rule
ruleTomorrow :: Rule
ruleTomorrow = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"tomorrow"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"domani"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Grain -> Int -> TimeData
cycleNth Grain
TG.Day Int
1
}
ruleNextNCycle2 :: Rule
ruleNextNCycle2 :: Rule
ruleNextNCycle2 = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"next n <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"([nd]e)?i|([nd]el)?le"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
2 Int
9999
, String -> PatternItem
regex String
"prossim[ei]"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token
token:Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) -> do
Int
v <- Token -> Maybe Int
getIntValue Token
token
TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Bool -> Grain -> Int -> TimeData
cycleN Bool
True a
Grain
grain Int
v
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleProssimiUnitofduration :: Rule
ruleProssimiUnitofduration :: Rule
ruleProssimiUnitofduration = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"prossimi <unit-of-duration>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"((([nd]e)?i|([nd]el)?le) )?prossim[ie]"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
_:Token Dimension a
TimeGrain a
grain:[Token]
_) ->
let from :: TimeData
from = Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
1
to :: TimeData
to = Grain -> Int -> TimeData
cycleNth a
Grain
grain Int
3
in Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeIntervalType -> TimeData -> TimeData -> Maybe TimeData
interval TimeIntervalType
TTime.Closed TimeData
from TimeData
to
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleMothersDay :: Rule
ruleMothersDay :: Rule
ruleMothersDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"Mother's Day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"festa della mamma"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int -> TimeData
nthDOWOfMonth Int
2 Int
7 Int
5
}
ruleFestaDelLavoro :: Rule
ruleFestaDelLavoro :: Rule
ruleFestaDelLavoro = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"festa del lavoro"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"festa del lavoro|(festa|giorno) dei lavoratori"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt (TimeData -> Maybe Token) -> TimeData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> Int -> TimeData
monthDay Int
5 Int
1
}
ruleIntersectByDiDellaDel :: Rule
ruleIntersectByDiDellaDel :: Rule
ruleIntersectByDiDellaDel = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"intersect by \"di\", \"della\", \"del\""
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isNotLatent
, String -> PatternItem
regex String
"di|del(la)?"
, Predicate -> PatternItem
Predicate Predicate
isNotLatent
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td1:Token
_:Token Dimension a
Time a
td2:[Token]
_) ->
Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TimeData -> TimeData -> Maybe TimeData
intersect a
TimeData
td1 a
TimeData
td2
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimezone :: Rule
ruleTimezone :: Rule
ruleTimezone = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> timezone"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> (Token -> [Bool]) -> Predicate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Predicate] -> Token -> [Bool]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Predicate
isNotLatent, Predicate
isATimeOfDay]
, String -> PatternItem
regex String
"\\b(YEKT|YEKST|YAKT|YAKST|WITA|WIT|WIB|WGT|WGST|WFT|WET|WEST|WAT|WAST|VUT|VLAT|VLAST|VET|UZT|UYT|UYST|UTC|ULAT|TVT|TMT|TLT|TKT|TJT|TFT|TAHT|SST|SRT|SGT|SCT|SBT|SAST|SAMT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PHT|PHOT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|NCT|MYT|MVT|MUT|MST|MSK|MSD|MMT|MHT|MDT|MAWT|MART|MAGT|MAGST|LINT|LHST|LHDT|KUYT|KST|KRAT|KRAST|KGT|JST|IST|IRST|IRKT|IRKST|IRDT|IOT|IDT|ICT|HOVT|HKT|GYT|GST|GMT|GILT|GFT|GET|GAMT|GALT|FNT|FKT|FKST|FJT|FJST|EST|EGT|EGST|EET|EEST|EDT|ECT|EAT|EAST|EASST|DAVT|ChST|CXT|CVT|CST|COT|CLT|CLST|CKT|CHAST|CHADT|CET|CEST|CDT|CCT|CAT|CAST|BTT|BST|BRT|BRST|BOT|BNT|AZT|AZST|AZOT|AZOST|AWST|AWDT|AST|ART|AQTT|ANAT|ANAST|AMT|AMST|ALMT|AKST|AKDT|AFT|AEST|AEDT|ADT|ACST|ACDT)\\b"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Time a
td:
Token Dimension a
RegexMatch (GroupMatch (tz:_)):
[Token]
_) -> Dimension TimeData -> TimeData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TimeData
Time (TimeData -> Token) -> Maybe TimeData -> Maybe Token
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> TimeData -> Maybe TimeData
inTimezone (Text -> Text
Text.toUpper Text
tz) a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
rules :: [Rule]
rules :: [Rule]
rules =
[ Rule
ruleAfternoon
, Rule
ruleAtTimeofday
, Rule
ruleChristmas
, Rule
ruleChristmasEve
, Rule
ruleCircaPerLeTimeofday
, Rule
ruleCommemorazioneDeiDefunti
, Rule
ruleDalDatetimeAlDatetimeInterval
, Rule
ruleDalleTimeofdayAlleTimeofdayInterval
, Rule
ruleDatetimeDatetimeInterval
, Rule
ruleDayOfMonthSt
, Rule
ruleDayofmonthNamedmonth
, Rule
ruleDdddMonthInterval
, Rule
ruleDdmm
, Rule
ruleDdmmyyyy
, Rule
ruleDimTimeAlPartofday
, Rule
ruleDimTimeDelMattino
, Rule
ruleDimTimePartofday
, Rule
ruleDopoLeTimeofday
, Rule
ruleDurationAgo
, Rule
ruleEntroIlDuration
, Rule
ruleEntroLeTimeofday
, Rule
ruleEomendOfMonth
, Rule
ruleEoyendOfYear
, Rule
ruleEpifania
, Rule
ruleEvening
, Rule
ruleFerragosto
, Rule
ruleFestaDelLavoro
, Rule
ruleFestaDelPap
, Rule
ruleFestaDellaLiberazione
, Rule
ruleFestaDellaRepubblica
, Rule
ruleFinoAlDatetimeInterval
, Rule
ruleGliNUltimiCycle
, Rule
ruleGliUltimiNCycle
, Rule
ruleHalloweenDay
, Rule
ruleHhRelativeminutesDelPomeriggiotimeofday
, Rule
ruleHhRelativeminutesDelPomeriggiotimeofday2
, Rule
ruleHhhmmTimeofday
, Rule
ruleHhhmmTimeofday2
, Rule
ruleHhmmMilitaryTimeofday
, Rule
ruleHourofdayAndRelativeMinutes
, Rule
ruleHourofdayIntegerAsRelativeMinutes
, Rule
ruleHourofdayMinusIntegerAsRelativeMinutes
, Rule
ruleIlCycleDopoTime
, Rule
ruleIlDayofmonthDeNamedmonth
, Rule
ruleIlTime
, Rule
ruleIleNCyclePassatipassate
, Rule
ruleInDuration
, Rule
ruleInNamedmonth
, Rule
ruleInThePartofdayOfDimTime
, Rule
ruleInafterDuration
, Rule
ruleIntegerDelPartOfDay
, Rule
ruleIntegerLatentTimeofday
, Rule
ruleIntersectByDiDellaDel
, Rule
ruleLastCycleOfTime
, Rule
ruleLastDayofweekOfTime
, Rule
ruleLastDayofweekOfTime2
, Rule
ruleLastTime
, Rule
ruleLeIdiDiNamedmonth
, Rule
ruleLunch
, Rule
ruleMidnight
, Rule
ruleMorning
, Rule
ruleMothersDay
, Rule
ruleNameddayDayofmonth
, Rule
ruleNewYearsDay
, Rule
ruleNewYearsEve
, Rule
ruleNextCycle
, Rule
ruleNextNCycle
, Rule
ruleNextNCycle2
, Rule
ruleNextTime
, Rule
ruleNextTime2
, Rule
ruleNight
, Rule
ruleNoon
, Rule
ruleNthTimeAfterTime
, Rule
ruleNthTimeAfterTime2
, Rule
ruleNthTimeOfTime
, Rule
ruleNthTimeOfTime2
, Rule
ruleNthTimeOfTime3
, Rule
ruleOgnissanti
, Rule
ruleOrdinalCycleOfTime
, Rule
rulePartofdayOfDimTime
, Rule
ruleProssimiUnitofduration
, Rule
ruleRelativeMinutesToIntegerAsHourofday
, Rule
ruleRightNow
, Rule
ruleSantoStefano
, Rule
ruleSeason
, Rule
ruleSeason2
, Rule
ruleSeason3
, Rule
ruleSeason4
, Rule
ruleStamattina
, Rule
ruleStanotte
, Rule
ruleStasera
, Rule
ruleTheCycleLast
, Rule
ruleTheCycleNext
, Rule
ruleTheCycleOfTime
, Rule
ruleTheDayAfterTomorrow
, Rule
ruleTheDayBeforeYesterday
, Rule
ruleTheDayofmonth
, Rule
ruleTheLastCycle
, Rule
ruleTheNthTimeOfTime
, Rule
ruleTheOrdinalCycleOfTime
, Rule
ruleThisCycle
, Rule
ruleThisDayofweek
, Rule
ruleThisPartofday
, Rule
ruleThisTime
, Rule
ruleTimeLast
, Rule
ruleTimeNotte
, Rule
ruleTimeNotte2
, Rule
ruleTimeofdayCirca
, Rule
ruleTimeofdayOra
, Rule
ruleTimeofdayPrecise
, Rule
ruleTimeofdayTimeofdayDayofmonthInterval
, Rule
ruleTomorrow
, Rule
ruleTraIlDatetimeEIlDatetimeInterval
, Rule
ruleTwoTimeTokensInARow
, Rule
ruleTwoTimeTokensSeparatedByDi
, Rule
ruleUna
, Rule
ruleValentinesDay
, Rule
ruleWeekend
, Rule
ruleYearLatent
, Rule
ruleYearLatent2
, Rule
ruleYearNotLatent
, Rule
ruleYesterday
, Rule
ruleYyyymmdd
, Rule
ruleHhThreeQuarterDelPomeriggiotimeofday
, Rule
ruleHhThreeQuarterDelPomeriggiotimeofday2
, Rule
ruleHourofdayMinusThreeQuarter
, Rule
ruleThreeQuarterToIntegerAsHourofday
, Rule
ruleHourofdayAndThreeQuarter
, Rule
ruleHourofdayThreeQuarters
, Rule
ruleHhQuartDelPomeriggiotimeofday
, Rule
ruleHhQuartDelPomeriggiotimeofday2
, Rule
ruleHourofdayMinusQuart
, Rule
ruleQuartAsHourofday
, Rule
ruleHourofdayAndAQuart
, Rule
ruleHourofdayQuart
, Rule
ruleHhHalfDelPomeriggiotimeofday
, Rule
ruleHhHalfDelPomeriggiotimeofday2
, Rule
ruleHourofdayMinusHalf
, Rule
ruleHalfToIntegerAsHourofday
, Rule
ruleHourofdayAndHalf
, Rule
ruleHourofdayHalf
, Rule
ruleHhIntegerminutesDelPomeriggiotimeofday
, Rule
ruleHhIntegerminutesDelPomeriggiotimeofday2
, Rule
ruleHourofdayMinusIntegerMinutes
, Rule
ruleMinutesToIntegerAsHourofday
, Rule
ruleHourofdayAndIntegerMinutes
, Rule
ruleHourofdayIntegerMinutes
, Rule
ruleTimezone
, Rule
ruleTimeEntroLeTime
, Rule
ruleImmacolataConcezione
, Rule
ruleOrdinalQuarter
, Rule
ruleTheOrdinalQuarter
, Rule
ruleCycleOrdinalQuarterYear
, Rule
ruleCycleTheOrdinalTime
, Rule
ruleCycleNext
, Rule
ruleDomattina
, Rule
ruleVersoPartOfDay
, Rule
ruleEntroIlInt
, Rule
ruleEntroTime
, Rule
ruleDalInt
, Rule
ruleDopoTime
, Rule
ruleToday
, Rule
ruleDalIntAlInt
, Rule
ruleTraIlIntEIlInt
, Rule
ruleIlWeekendDelTime
]
[Rule] -> [Rule] -> [Rule]
forall a. [a] -> [a] -> [a]
++ [Rule]
ruleDaysOfWeek
[Rule] -> [Rule] -> [Rule]
forall a. [a] -> [a] -> [a]
++ [Rule]
ruleMonths
[Rule] -> [Rule] -> [Rule]
forall a. [a] -> [a] -> [a]
++ [Rule]
rulePeriodicHolidays