{-# LANGUAGE OverloadedStrings #-}
module Duckling.TimeGrain.TR.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
"saniye (grain)", String
"sa?n(iye)?(nin)?", Grain
TG.Second)
, (Text
"dakika (grain)", String
"da?k(ika)?(nın)?", Grain
TG.Minute)
, (Text
"saat (grain)", String
"sa(at)?(in)?", Grain
TG.Hour)
, (Text
"gün (grain)", String
"gün(ün)?", Grain
TG.Day)
, (Text
"hafta (grain)", String
"hafta(nın)?", Grain
TG.Week)
, (Text
"ay (grain)", String
"ay(ın)?", Grain
TG.Month)
, (Text
"çeyrek yıl (grain)", String
"\231eyrek y\305l(ın)?", Grain
TG.Quarter)
, (Text
"yıl (grain)", String
"y\305l(ın)?", 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
}