{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.TimeGrain.HR.Rules
( rules ) where
import Data.String
import Data.Text (Text)
import Prelude
import Duckling.Dimensions.Types
import Duckling.Types
import qualified Duckling.TimeGrain.Types as TG
grains :: [(Text, String, TG.Grain)]
grains :: [(Text, String, Grain)]
grains = [ (Text
"second (grain)", String
"sek(und)?(a|e|u)?", Grain
TG.Second)
, (Text
"minute (grain)", String
"min(ut)?(a|e|u)?", Grain
TG.Minute)
, (Text
"hour (grain)", String
"h|sat(i|a|e)?", Grain
TG.Hour)
, (Text
"day (grain)", String
"dan(i|a|e)?", Grain
TG.Day)
, (Text
"week (grain)", String
"tjeda?n(a|e|u|i)?", Grain
TG.Week)
, (Text
"month (grain)", String
"mjesec(a|e|u|i)?", Grain
TG.Month)
, (Text
"quarter (grain)", String
"kvartalu?|tromjese(c|č)j(e|u)", Grain
TG.Quarter)
, (Text
"year (grain)", String
"godin(a|e|u)", Grain
TG.Year)
]
rules :: [Rule]
rules :: [Rule]
rules = ((Text, String, Grain) -> Rule)
-> [(Text, String, Grain)] -> [Rule]
forall a b. (a -> b) -> [a] -> [b]
map (Text, String, Grain) -> Rule
go [(Text, String, Grain)]
grains
where
go :: (Text, String, Grain) -> Rule
go (Text
name, String
regexPattern, Grain
grain) = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
name
, pattern :: Pattern
pattern = [String -> PatternItem
regex String
regexPattern]
, prod :: Production
prod = \[Token]
_ -> Token -> Maybe Token
forall a. a -> Maybe a
Just (Token -> Maybe Token) -> Token -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Dimension Grain -> Grain -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension Grain
TimeGrain Grain
grain
}