2017-04-28 17:47:03 +03:00
|
|
|
-- Copyright (c) 2016-present, Facebook, Inc.
|
|
|
|
-- All rights reserved.
|
|
|
|
--
|
|
|
|
-- This source code is licensed under the BSD-style license found in the
|
|
|
|
-- LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
-- of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
|
|
|
{-# LANGUAGE GADTs #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module Duckling.TimeGrain.VI.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)]
|
2017-09-07 22:33:31 +03:00
|
|
|
grains = [ ("second (grain)", "(giây|s|sec)", TG.Second)
|
|
|
|
, ("minute (grain)", "(phút|m|min)", TG.Minute)
|
|
|
|
, ("hour (grain)", "(giờ|h|tiếng)", TG.Hour)
|
|
|
|
, ("day (grain)", "ngày", TG.Day)
|
|
|
|
, ("week (grain)", "tuần", TG.Week)
|
|
|
|
, ("month (grain)", "tháng", TG.Month)
|
|
|
|
, ("quarter (grain)", "quý", TG.Quarter)
|
|
|
|
, ("year (grain)", "năm", TG.Year)
|
2017-04-28 17:47:03 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
rules :: [Rule]
|
|
|
|
rules = map go grains
|
|
|
|
where
|
|
|
|
go (name, regexPattern, grain) = Rule
|
|
|
|
{ name = name
|
|
|
|
, pattern = [regex regexPattern]
|
|
|
|
, prod = \_ -> Just $ Token TimeGrain grain
|
|
|
|
}
|