{-# LANGUAGE GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.Time.GA.Rules
( rules
) where
import Data.Text (Text)
import Prelude
import Duckling.Dimensions.Types
import Duckling.Duration.Helpers (isGrain)
import Duckling.Numeral.Helpers (parseInt)
import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Types
import qualified Duckling.Ordinal.Types as TOrdinal
import qualified Duckling.TimeGrain.Types as TG
ruleArInn :: Rule
ruleArInn :: Rule
ruleArInn = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"arú inné"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ar(ú|u) inn(é|e)"
]
, 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
}
ruleNollaigNaMban :: Rule
ruleNollaigNaMban :: Rule
ruleNollaigNaMban = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"Nollaig na mBan"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l(á|a) |an )?nollaig (bheag|na mban)"
]
, 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
}
ruleInniu :: Rule
ruleInniu :: Rule
ruleInniu = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"inniu"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"inniu"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt TimeData
today
}
ruleAnOrdinalCycleINdiaidhTime :: Rule
ruleAnOrdinalCycleINdiaidhTime :: Rule
ruleAnOrdinalCycleINdiaidhTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <ordinal> <cycle> i ndiaidh <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an"
, 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
"(i ndiaidh|tar (é|e)is)"
, 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
}
ruleInn :: Rule
ruleInn :: Rule
ruleInn = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"inné"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"inn(é|e)"
]
, 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
}
ruleLFhileBrde :: Rule
ruleLFhileBrde :: Rule
ruleLFhileBrde = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"Lá Fhéile Bríde"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l(á|a) )?(fh(e|é)ile|'?le) bh?r(í|i)de"
]
, 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
1
}
ruleLFhileVailintn :: Rule
ruleLFhileVailintn :: Rule
ruleLFhileVailintn = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"Lá Fhéile Vailintín"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l(á|a) )?(fh(e|é)ile|'?le) vailint(í|i)n"
]
, 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
}
ruleTimeSeo :: Rule
ruleTimeSeo :: Rule
ruleTimeSeo = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> seo"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"seo"
]
, 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
0 Bool
False a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTimeSeoChaite :: Rule
ruleTimeSeoChaite :: Rule
ruleTimeSeoChaite = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> seo chaite"
, pattern :: Pattern
pattern =
[ Dimension TimeData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension TimeData
Time
, String -> PatternItem
regex String
"seo ch?aite"
]
, 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
}
ruleTimeSeoChugainn :: Rule
ruleTimeSeoChugainn :: Rule
ruleTimeSeoChugainn = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<time> seo chugainn"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isNotLatent
, String -> PatternItem
regex String
"seo (chugainn|at(a|á) ag teacht)"
]
, 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
0 Bool
True a
TimeData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleAmrach :: Rule
ruleAmrach :: Rule
ruleAmrach = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"amárach"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"am(á|a)rach"
]
, 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
}
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
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
}
ruleOrdinalRithe :: Rule
ruleOrdinalRithe :: Rule
ruleOrdinalRithe = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> ráithe"
, 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
}
ruleAnnaCycleRoimhTime :: Rule
ruleAnnaCycleRoimhTime :: Rule
ruleAnnaCycleRoimhTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"(an|na) <cycle> roimh <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"the"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"roimh"
, 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
}
ruleCycleShin :: Rule
ruleCycleShin :: Rule
ruleCycleShin = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<cycle> ó shin"
, pattern :: Pattern
pattern =
[ Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"(ó|o) shin"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(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
}
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
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 -> TimeData
monthDay Int
m Int
d
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleIGceannCycle :: Rule
ruleIGceannCycle :: Rule
ruleIGceannCycle = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"i gceann <cycle>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(i|faoi) g?ch?eann"
, Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 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 Dimension a
Ordinal a
od:Token Dimension a
TimeGrain a
grain:[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 (OrdinalData -> Int
TOrdinal.value a
OrdinalData
od)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleAnCycleDeTime :: Rule
ruleAnCycleDeTime :: Rule
ruleAnCycleDeTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <cycle> de <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"d[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
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
}
ruleDayofmonthordinalNamedmonth :: Rule
ruleDayofmonthordinalNamedmonth :: Rule
ruleDayofmonthordinalNamedmonth = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<day-of-month>(ordinal) <named-month>"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isDOMOrdinal
, 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
}
ruleIntersectBy :: Rule
ruleIntersectBy :: Rule
ruleIntersectBy = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"intersect by \",\""
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isNotLatent
, String -> PatternItem
regex String
","
, 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
}
ruleOrdinalRitheYear :: Rule
ruleOrdinalRitheYear :: Rule
ruleOrdinalRitheYear = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> ráithe <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 Dimension a
Ordinal a
od: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 Grain
TG.Quarter (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
}
ruleCycleInniu :: Rule
ruleCycleInniu :: Rule
ruleCycleInniu = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<cycle> ó inniu"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Predicate
isIntegerBetween Int
1 Int
9999
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"(ó|o)(n l(á|a) (at(á|a) )?)?inniu"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(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
}
ruleOrdinalCycleINdiaidhTime :: Rule
ruleOrdinalCycleINdiaidhTime :: Rule
ruleOrdinalCycleINdiaidhTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> <cycle> i ndiaidh <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
"(i ndiaidh|tar (é|e)is)"
, 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
}
ruleAnDayofmonthOrdinal :: Rule
ruleAnDayofmonthOrdinal :: Rule
ruleAnDayofmonthOrdinal = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <day-of-month> (ordinal)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an|na"
, Predicate -> PatternItem
Predicate Predicate
isDOMOrdinal
]
, 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 -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Int -> TimeData
dayOfMonth Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleIntersect :: Rule
ruleIntersect :: Rule
ruleIntersect = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"intersect"
, 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
}
ruleAnOrdinalCycleDeTime :: Rule
ruleAnOrdinalCycleDeTime :: Rule
ruleAnOrdinalCycleDeTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <ordinal> <cycle> de <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an"
, 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
"d[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
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
}
ruleLNaNaithreacha :: Rule
ruleLNaNaithreacha :: Rule
ruleLNaNaithreacha = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"Lá na nAithreacha"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"l(á|a) na naithreacha"
]
, 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
6
}
ruleArAmrach :: Rule
ruleArAmrach :: Rule
ruleArAmrach = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"arú amárach"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ar(ú|u) am(á|a)rach"
]
, 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
}
ruleOrdinalCycleDeTime :: Rule
ruleOrdinalCycleDeTime :: Rule
ruleOrdinalCycleDeTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<ordinal> <cycle> de <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
"d[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 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
}
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 (m1:m2:m3:_)):[Token]
_) -> do
Int
y <- Text -> Maybe Int
parseInt Text
m1
Int
m <- Text -> Maybe Int
parseInt Text
m2
Int
d <- Text -> Maybe Int
parseInt Text
m3
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
}
ruleArDate :: Rule
ruleArDate :: Rule
ruleArDate = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"ar <date>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ar"
, 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
x:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just Token
x
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleAnNollaig :: Rule
ruleAnNollaig :: Rule
ruleAnNollaig = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"An Nollaig"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l(á|a) |an )?(nollai?g)"
]
, 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
}
ruleOnANamedday :: Rule
ruleOnANamedday :: Rule
ruleOnANamedday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"on a named-day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"ar an"
, Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
]
, 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
}
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
999
]
, 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
}
ruleAnois :: Rule
ruleAnois :: Rule
ruleAnois = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"anois"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"anois|(ag an (t-?)?am seo)"
]
, prod :: Production
prod = \[Token]
_ -> TimeData -> Maybe Token
tt TimeData
now
}
ruleLFhilePdraig :: Rule
ruleLFhilePdraig :: Rule
ruleLFhilePdraig = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"Lá Fhéile Pádraig"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"(l(á|a) )?(fh(e|é)ile|'?le) ph?(á|a)draig"
]
, 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
17
}
ruleAnCycleINdiaidhTime :: Rule
ruleAnCycleINdiaidhTime :: Rule
ruleAnCycleINdiaidhTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <cycle> i ndiaidh <time>"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"the"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"(i ndiaidh|tar (é|e)is)"
, 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
}
ruleDayofmonthOrdinal :: Rule
ruleDayofmonthOrdinal :: Rule
ruleDayofmonthOrdinal = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<day-of-month> (ordinal)"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isDOMOrdinal
]
, 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
dayOfMonth Int
n
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleAnCycleSeo :: Rule
ruleAnCycleSeo :: Rule
ruleAnCycleSeo = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <cycle> seo"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an"
, Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"seo"
]
, 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
}
ruleAnDayofmonthNonOrdinal :: Rule
ruleAnDayofmonthNonOrdinal :: Rule
ruleAnDayofmonthNonOrdinal = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an <day-of-month> (non ordinal)"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an|na"
, 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
. TimeData -> TimeData
mkLatent (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
}
ruleDNamedday :: Rule
ruleDNamedday :: Rule
ruleDNamedday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"dé named-day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"d(é|e)"
, Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
]
, 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
}
ruleYear :: Rule
ruleYear :: Rule
ruleYear = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"year"
, 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
}
ruleCycleRoimhTime :: Rule
ruleCycleRoimhTime :: Rule
ruleCycleRoimhTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<cycle> roimh <time>"
, pattern :: Pattern
pattern =
[ Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"roimhe?"
, 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
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
}
ruleAbsorptionOfAfterNamedDay :: Rule
ruleAbsorptionOfAfterNamedDay :: Rule
ruleAbsorptionOfAfterNamedDay = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"absorption of , after named day"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
, String -> PatternItem
regex String
","
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
x:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just Token
x
[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
}
ruleAnNamedday :: Rule
ruleAnNamedday :: Rule
ruleAnNamedday = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"an named-day"
, pattern :: Pattern
pattern =
[ String -> PatternItem
regex String
"an"
, Predicate -> PatternItem
Predicate Predicate
isADayOfWeek
]
, 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
}
ruleDaysOfWeek :: [Rule]
ruleDaysOfWeek :: [Rule]
ruleDaysOfWeek = [(Text, String)] -> [Rule]
mkRuleDaysOfWeek
[ ( Text
"Monday" , String
"luai?n|lu\\.?" )
, ( Text
"Tuesday" , String
"mh?(á|a)irt|m(á|a)?\\.?" )
, ( Text
"Wednesday", String
"ch?(é|e)adaoin|c(é|e)\\.?" )
, ( Text
"Thursday" , String
"d(é|e)ardaoin|d(é|e)?\\.?" )
, ( Text
"Friday" , String
"h?aoine|ao\\.?" )
, ( Text
"Saturday" , String
"sathai?rn|sa\\.?" )
, ( Text
"Sunday" , String
"domhnai?[cg]h|do\\.?" )
]
ruleMonths :: [Rule]
ruleMonths :: [Rule]
ruleMonths = [(Text, String)] -> [Rule]
mkRuleMonths
[ ( Text
"January" , String
"(mh?(í|i) )?(an )?t?ean(á|a)ir|ean\\.?" )
, ( Text
"February" , String
"(mh?(í|i) )?(na )?feabhra|fea\\.?" )
, ( Text
"March" , String
"(mh?(í|i) )?(an )?mh?(á|a)rta|m(á|a)r\\.?" )
, ( Text
"April" , String
"(mh?(í|i) )?(an )?t?aibre(á|a)i?n|abr\\.?" )
, ( Text
"May" , String
"(mh?(í|i) )?(na )?bh?ealtaine|bea\\.?" )
, ( Text
"June" , String
"(mh?(í|i) )?(an )?mh?eith(ea|i)mh|mei\\.?" )
, ( Text
"July" , String
"(mh?(í|i) )?i(ú|u)il|i(ú|u)i\\.?" )
, ( Text
"August" , String
"(mh?(í|i) )?(na )?l(ú|u)nasa|l(ú|u)n\\.?" )
, ( Text
"September", String
"(mh?(í|i) )?mh?e(á|a)n f(ó|o)mhair|mef?\\.?")
, ( Text
"October" , String
"(mh?(í|i) )?(na )?nollai?g|nol\\.?" )
, ( Text
"November" , String
"(mh?(í|i) )?(na )?samh(ain|na)|sam\\.?" )
, ( Text
"December" , String
"(mh?(í|i) )?(na )?nollai?g|nol\\.?" )
]
ruleCycleINdiaidhTime :: Rule
ruleCycleINdiaidhTime :: Rule
ruleCycleINdiaidhTime = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<cycle> i ndiaidh <time>"
, pattern :: Pattern
pattern =
[ Dimension Grain -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension Grain
TimeGrain
, String -> PatternItem
regex String
"(i ndiaidh|tar (é|e)is)"
, 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
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
}
ruleDayofmonthordinalNamedmonthYear :: Rule
ruleDayofmonthordinalNamedmonthYear :: Rule
ruleDayofmonthordinalNamedmonthYear = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<day-of-month>(ordinal) <named-month> year"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate Predicate
isDOMOrdinal
, Predicate -> PatternItem
Predicate Predicate
isAMonth
, String -> PatternItem
regex String
"(\\d{2,4})"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token
token:Token Dimension a
Time a
td:Token Dimension a
RegexMatch (GroupMatch (match:_)):[Token]
_) -> do
Int
intVal <- Text -> Maybe Int
parseInt Text
match
TimeData
dom <- TimeData -> Token -> Maybe TimeData
intersectDOM a
TimeData
td 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 -> TimeData -> Maybe TimeData
intersect TimeData
dom (Int -> TimeData
year Int
intVal)
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
rules :: [Rule]
rules :: [Rule]
rules =
[ Rule
ruleAbsorptionOfAfterNamedDay
, Rule
ruleAmrach
, Rule
ruleAnCycleDeTime
, Rule
ruleAnCycleINdiaidhTime
, Rule
ruleAnCycleSeo
, Rule
ruleAnDayofmonthNonOrdinal
, Rule
ruleAnDayofmonthOrdinal
, Rule
ruleAnNamedday
, Rule
ruleAnNollaig
, Rule
ruleAnOrdinalCycleDeTime
, Rule
ruleAnOrdinalCycleINdiaidhTime
, Rule
ruleAnnaCycleRoimhTime
, Rule
ruleAnois
, Rule
ruleArAmrach
, Rule
ruleArDate
, Rule
ruleArInn
, Rule
ruleCycleINdiaidhTime
, Rule
ruleCycleInniu
, Rule
ruleCycleRoimhTime
, Rule
ruleCycleShin
, Rule
ruleDNamedday
, Rule
ruleDayofmonthOrdinal
, Rule
ruleDayofmonthordinalNamedmonth
, Rule
ruleDayofmonthordinalNamedmonthYear
, Rule
ruleDdmm
, Rule
ruleDdmmyyyy
, Rule
ruleIGceannCycle
, Rule
ruleInn
, Rule
ruleInniu
, Rule
ruleIntersect
, Rule
ruleIntersectBy
, Rule
ruleLFhileBrde
, Rule
ruleLFhilePdraig
, Rule
ruleLFhileVailintn
, Rule
ruleLNaNaithreacha
, Rule
ruleNollaigNaMban
, Rule
ruleOnANamedday
, Rule
ruleOrdinalCycleDeTime
, Rule
ruleOrdinalCycleINdiaidhTime
, Rule
ruleOrdinalRithe
, Rule
ruleOrdinalRitheYear
, Rule
ruleTimeSeo
, Rule
ruleTimeSeoChaite
, Rule
ruleTimeSeoChugainn
, Rule
ruleYear
, Rule
ruleYearLatent
, Rule
ruleYearLatent2
, Rule
ruleYyyymmdd
]
[Rule] -> [Rule] -> [Rule]
forall a. [a] -> [a] -> [a]
++ [Rule]
ruleDaysOfWeek
[Rule] -> [Rule] -> [Rule]
forall a. [a] -> [a] -> [a]
++ [Rule]
ruleMonths