{-# LANGUAGE OverloadedStrings #-}
module Duckling.TimeGrain.KA.Rules
( rules
) where
import Data.String
import Data.Text (Text)
import Prelude
import Duckling.Dimensions.Types
import Duckling.TimeGrain.Types
import Duckling.Types
grains :: [(Text, String, Grain)]
grains :: [(Text, String, Grain)]
grains = [ (Text
"second (grain)" , String
"წამ(ით|ი|ში|ს)?", Grain
Second)
, (Text
"minute (grain)" , String
"წუთ(ით|ი|ში|ს)?", Grain
Minute)
, (Text
"hour (grain)" , String
"საათ(ით|ი|ში|ს)?", Grain
Hour)
, (Text
"day (grain)" , String
"დღით|დღის|დღე?(ში)?ს?", Grain
Day)
, (Text
"week (grain)" , String
"კვირ(აში)?(ას|ით|ის|ა)?", Grain
Week)
, (Text
"month (grain)" , String
"თვ(ეში|ით|ის|ეს|ს|ე)?", Grain
Month)
, (Text
"quarter (grain)" , String
"კვარტა?ლ(ით|ი|ში|ს)?", Grain
Quarter)
, (Text
"year (grain)" , String
"წლით|წელიწადი?(ით|ი|ში|ის|ს)?|წე?ლი?(ით|ის|ში|ს|იდან)?", Grain
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 = Maybe Token -> Production
forall a b. a -> b -> a
const (Maybe Token -> Production) -> Maybe Token -> Production
forall a b. (a -> b) -> a -> b
$ 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
}