{-# LANGUAGE OverloadedStrings #-}
module Duckling.TimeGrain.BG.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 = \[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
}