{-# LANGUAGE OverloadedStrings #-}
module Duckling.TimeGrain.EL.Rules
( rules ) where
import Data.Text (Text)
import Data.String
import Prelude
import Duckling.Dimensions.Types
import qualified Duckling.TimeGrain.Types as TG
import Duckling.Types
grains :: [(Text, String, TG.Grain)]
grains :: [(Text, String, Grain)]
grains =
[ (Text
"second (grain) ", String
"δε[υύ]τερ([οό]λ[εέ]πτ)?(ου?|α|ων)", Grain
TG.Second)
, (Text
"minute (grain)" , String
"λεπτ(o|όν?|ού|ά|ών)" , Grain
TG.Minute)
, (Text
"hour (grain)" , String
"[ωώ](ρ(ας?|ες|ών))?" , Grain
TG.Hour)
, (Text
"day (grain)" , String
"η?μέρ(ας?|ες|ών)" , Grain
TG.Day)
, (Text
"week (grain)" , String
"ε?βδομάδ(ας?ν?|ες|ων)" , Grain
TG.Week)
, (Text
"month (grain)" , String
"μήν(ας?|ες|ών)" , Grain
TG.Month)
, (Text
"quarter (grain)", String
"τρ[ιί]μ[ηή]ν(ου?|α|ων)" , Grain
TG.Quarter)
, (Text
"year (grain)" , String
"έτ(ου?ς|η|ών)|χρ[οό]ν(ο[ιςυ]?|ι([αά]|ές)|ι?ών)"
, 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
}