duckling/Duckling/TimeGrain/AR/Rules.hs
Abdallatif Sulaiman 1393098bcc Added Time Dimension to Arabic
Summary:
Hi, in this pr:
* Added time dimension to Arabic language, thanks to Hussein-Dahir & Yazeed-Obaid for writing time corpus.
* Fixed some bugs in numeral & ordinals and added more test cases for them.

Also, I don't really understand why do we use classifiers in time dimension?
Closes https://github.com/facebook/duckling/pull/123

Reviewed By: blandinw

Differential Revision: D6583313

Pulled By: patapizza

fbshipit-source-id: f7acdef0c032d7b7fd7d224832fdaf484d2df825
2017-12-19 14:30:42 -08:00

42 lines
1.5 KiB
Haskell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 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 OverloadedStrings #-}
module Duckling.TimeGrain.AR.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 = [ ("second (grain) ", "(ثاني(ة|ه)?|ثواني|لحظ(ة|ه|ات))" , TG.Second)
, ("minute (grain)" , "دق(يق(ة|ه)|ائق)" , TG.Minute)
, ("hour (grain)" , "ساع(ة|ه|ات)" , TG.Hour)
, ("day (grain)" , "يوم|(ا|أ)يام" , TG.Day)
, ("week (grain)" , "(ا|أ|إ)س(بوع|ابيع)" , TG.Week)
, ("month (grain)" , "شهر|(ا|أ|إ)شهر" , TG.Month)
, ("quarter (grain)", "(ربع(ين|ان)|[أا]رباع)(سنة|عام)?" , TG.Quarter)
, ("year (grain)" , "سن(ة|ين)|عام" , TG.Year)
]
rules :: [Rule]
rules = map go grains
where
go (name, regexPattern, grain) = Rule
{ name = name
, pattern = [regex regexPattern]
, prod = \_ -> Just $ Token TimeGrain grain
}