mirror of
https://github.com/facebook/duckling.git
synced 2025-01-05 11:55:41 +03:00
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
This commit is contained in:
parent
c133bad24a
commit
1393098bcc
@ -17,4 +17,5 @@ allDimensions =
|
||||
[ This Duration
|
||||
, This Numeral
|
||||
, This Ordinal
|
||||
, This Time
|
||||
]
|
||||
|
@ -88,6 +88,10 @@ allExamples = concat
|
||||
[ "ستة و عشرون"
|
||||
, "26"
|
||||
]
|
||||
, examples (NumeralValue 40)
|
||||
[ "اربعون"
|
||||
, "أربعين"
|
||||
]
|
||||
, examples (NumeralValue 1.1)
|
||||
[ "1.1"
|
||||
, "1.10"
|
||||
|
@ -29,7 +29,7 @@ ruleInteger5 :: Rule
|
||||
ruleInteger5 = Rule
|
||||
{ name = "integer 4"
|
||||
, pattern =
|
||||
[ regex "(أربع(ة)?)"
|
||||
[ regex "([أا]ربع[ةه]?)"
|
||||
]
|
||||
, prod = \_ -> integer 4
|
||||
}
|
||||
@ -54,7 +54,7 @@ ruleInteger18 :: Rule
|
||||
ruleInteger18 = Rule
|
||||
{ name = "integer 12"
|
||||
, pattern =
|
||||
[ regex "(إثن(ت)?ى عشر)"
|
||||
[ regex "(إثن(ت)?[يى] عشر)"
|
||||
]
|
||||
, prod = \_ -> integer 12
|
||||
}
|
||||
@ -63,18 +63,19 @@ ruleInteger19 :: Rule
|
||||
ruleInteger19 = Rule
|
||||
{ name = "integer (20..90)"
|
||||
, pattern =
|
||||
[ regex "(عشرون|ثلاثون|أربعون|خمسون|ستون|سبعون|ثمانون|تسعون)"
|
||||
[ regex "(عشر|ثلاث|[أا]ربع|خمس|ست|سبع|ثمان|تسع)(ون|ين)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
Token RegexMatch (GroupMatch (match:_)):_ -> case match of
|
||||
"عشرون" -> integer 20
|
||||
"ثلاثون" -> integer 30
|
||||
"أربعون" -> integer 40
|
||||
"خمسون" -> integer 50
|
||||
"ستون" -> integer 60
|
||||
"سبعون" -> integer 70
|
||||
"ثمانون" -> integer 80
|
||||
"تسعون" -> integer 90
|
||||
"عشر" -> integer 20
|
||||
"ثلاث" -> integer 30
|
||||
"اربع" -> integer 40
|
||||
"أربع" -> integer 40
|
||||
"خمس" -> integer 50
|
||||
"ست" -> integer 60
|
||||
"سبع" -> integer 70
|
||||
"ثمان" -> integer 80
|
||||
"تسع" -> integer 90
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -135,7 +136,7 @@ ruleInteger15 :: Rule
|
||||
ruleInteger15 = Rule
|
||||
{ name = "integer 11"
|
||||
, pattern =
|
||||
[ regex "(إحدى عشر(ة)?)"
|
||||
[ regex "([إاأ]حدى? عشر[ةه]?)"
|
||||
]
|
||||
, prod = \_ -> integer 11
|
||||
}
|
||||
@ -220,7 +221,7 @@ ruleInteger7 :: Rule
|
||||
ruleInteger7 = Rule
|
||||
{ name = "integer 5"
|
||||
, pattern =
|
||||
[ regex "(خمس)(ة)?"
|
||||
[ regex "خمسة?"
|
||||
]
|
||||
, prod = \_ -> integer 5
|
||||
}
|
||||
@ -229,7 +230,7 @@ ruleInteger14 :: Rule
|
||||
ruleInteger14 = Rule
|
||||
{ name = "integer 10"
|
||||
, pattern =
|
||||
[ regex "(عشرة|عشر)"
|
||||
[ regex "عشرة?"
|
||||
]
|
||||
, prod = \_ -> integer 10
|
||||
}
|
||||
@ -238,7 +239,7 @@ ruleInteger9 :: Rule
|
||||
ruleInteger9 = Rule
|
||||
{ name = "integer 6"
|
||||
, pattern =
|
||||
[ regex "(ست(ة)?)"
|
||||
[ regex "ستة?"
|
||||
]
|
||||
, prod = \_ -> integer 6
|
||||
}
|
||||
@ -256,7 +257,7 @@ ruleInteger4 :: Rule
|
||||
ruleInteger4 = Rule
|
||||
{ name = "integer 3"
|
||||
, pattern =
|
||||
[ regex "(ثلاث|ثلاثة)"
|
||||
[ regex "(ثلاث[ةه]?)"
|
||||
]
|
||||
, prod = \_ -> integer 3
|
||||
}
|
||||
|
@ -28,19 +28,24 @@ allExamples = concat
|
||||
[ examples (OrdinalData 1)
|
||||
[ "الاول"
|
||||
, "الأول"
|
||||
, "اول"
|
||||
]
|
||||
, examples (OrdinalData 2)
|
||||
[ "الثاني"
|
||||
, "الثان"
|
||||
, "ثاني"
|
||||
]
|
||||
, examples (OrdinalData 3)
|
||||
[ "الثالث"
|
||||
, "ثالث"
|
||||
]
|
||||
, examples (OrdinalData 4)
|
||||
[ "الرابع"
|
||||
, "رابع"
|
||||
]
|
||||
, examples (OrdinalData 8)
|
||||
[ "الثامن"
|
||||
, "ثامن"
|
||||
]
|
||||
, examples (OrdinalData 11)
|
||||
[ "الأحد عشر"
|
||||
@ -52,6 +57,14 @@ allExamples = concat
|
||||
, "الثان عشر"
|
||||
, "الاثنى عشر"
|
||||
]
|
||||
, examples (OrdinalData 13)
|
||||
[ "الثالث عشر"
|
||||
, "الثالثة عشرة"
|
||||
]
|
||||
, examples (OrdinalData 21)
|
||||
[ "الحادي والعشرين"
|
||||
, "الواحد و العشرون"
|
||||
]
|
||||
, examples (OrdinalData 25)
|
||||
[ "الخامس والعشرين"
|
||||
, "الخامس و العشرون"
|
||||
|
@ -29,39 +29,41 @@ import Duckling.Types
|
||||
|
||||
ordinalsMap :: HashMap Text Int
|
||||
ordinalsMap = HashMap.fromList
|
||||
[ ( "اول" , 1 )
|
||||
, ( "أول" , 1 )
|
||||
, ( "واحد", 1 )
|
||||
, ( "ثان" , 2 )
|
||||
, ( "ثاني", 2 )
|
||||
, ( "ثالث", 3 )
|
||||
, ( "رابع", 4 )
|
||||
, ( "خامس", 5 )
|
||||
, ( "سادس", 6 )
|
||||
, ( "سابع", 7 )
|
||||
, ( "ثامن", 8 )
|
||||
, ( "تاسع", 9 )
|
||||
[ ( "اول", 1 )
|
||||
, ( "أول", 1 )
|
||||
, ( "حاد", 1 )
|
||||
, ( "حادي", 1 )
|
||||
, ( "واحد", 1 )
|
||||
, ( "ثان", 2 )
|
||||
, ( "ثاني", 2 )
|
||||
, ( "ثالث", 3 )
|
||||
, ( "رابع", 4 )
|
||||
, ( "خامس", 5 )
|
||||
, ( "سادس", 6 )
|
||||
, ( "سابع", 7 )
|
||||
, ( "ثامن", 8 )
|
||||
, ( "تاسع", 9 )
|
||||
, ( "عاشر", 10 )
|
||||
]
|
||||
|
||||
-- حذفنا ون،ين للتوحيد بين المذكر والمؤنث
|
||||
cardinalsMap :: HashMap Text Int
|
||||
cardinalsMap = HashMap.fromList
|
||||
[ ( "عشر" , 20 )
|
||||
, ( "ثلاث" , 30 )
|
||||
[ ( "عشر", 20 )
|
||||
, ( "ثلاث", 30 )
|
||||
, ( "اربع", 40 )
|
||||
, ( "خمس" , 50 )
|
||||
, ( "ست" , 60 )
|
||||
, ( "سبع" , 70 )
|
||||
, ( "خمس", 50 )
|
||||
, ( "ست", 60 )
|
||||
, ( "سبع", 70 )
|
||||
, ( "ثمان", 80 )
|
||||
, ( "تسع" , 90 )
|
||||
, ( "تسع", 90 )
|
||||
]
|
||||
|
||||
ruleCompositeOrdinals :: Rule
|
||||
ruleCompositeOrdinals = Rule
|
||||
{ name = "ordinals (composite, e.g., eighty-seven)"
|
||||
, pattern =
|
||||
[ regex "ال(واحد|ثاني?|ثالث|رابع|خامس|ثامن|تاسع|عاشر) و ?ال(عشر|ثلاث|اربع|خمس|ست|سبع|ثمان|تسع)(ون|ين)"
|
||||
[ regex "ال(واحد|حادي?|ثاني?|ثالث|رابع|خامس|سادس|سابع|ثامن|تاسع|عاشر) و ?ال(عشر|ثلاث|اربع|خمس|ست|سبع|ثمان|تسع)(ون|ين)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (tens:units:_)):_) -> do
|
||||
@ -75,7 +77,7 @@ ruleOrdinals1To10 :: Rule
|
||||
ruleOrdinals1To10 = Rule
|
||||
{ name = "ordinals (first..tenth)"
|
||||
, pattern =
|
||||
[ regex "ال([أا]ول|ثاني?|ثالث|رابع|خامس|ثامن|تاسع|عاشر)[ةهى]?"
|
||||
[ regex "(?:ال)?([أا]ول|ثاني?|ثالث|رابع|خامس|سادس|سابع|ثامن|تاسع|عاشر)[ةهى]?"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) ->
|
||||
@ -87,7 +89,7 @@ ruleOrdinals11 :: Rule
|
||||
ruleOrdinals11 = Rule
|
||||
{ name = "ordinals (eleventh)"
|
||||
, pattern =
|
||||
[ regex "ال([اأإ]حد[يى]?|حادي?) ?عشرة?"
|
||||
[ regex "ال([اأإ]حد[يى]?|حاد(ي[ةه]?)?) ?عشر[ةه]?"
|
||||
]
|
||||
, prod = \_ -> Just $ ordinal 11
|
||||
}
|
||||
@ -96,7 +98,7 @@ ruleOrdinals12 :: Rule
|
||||
ruleOrdinals12 = Rule
|
||||
{ name = "ordinals (twelveth)"
|
||||
, pattern =
|
||||
[ regex "ال([اأإ]ثن[يى]?|ثاني?) ?عشرة?"
|
||||
[ regex "ال([اأإ]ثن[يى]?|ثان(ي[ةه]?)?) ?عشر[ةه]?"
|
||||
]
|
||||
, prod = \_ -> Just $ ordinal 12
|
||||
}
|
||||
@ -105,7 +107,7 @@ ruleOrdinals13To19 :: Rule
|
||||
ruleOrdinals13To19 = Rule
|
||||
{ name = "ordinals (thirtieth..nineteenth)"
|
||||
, pattern =
|
||||
[ regex "ال(ثالث|رابع|خامس|ثامن|تاسع) ?عشرة?"
|
||||
[ regex "ال(ثالث|رابع|خامس|سادس|سابع|ثامن|تاسع)[ةه]? ?عشرة?"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2632,4 +2632,4 @@ classifiers
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 9},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}})]
|
||||
likelihoods = HashMap.fromList [], n = 0}})]
|
||||
|
@ -21,6 +21,7 @@ import Duckling.Types
|
||||
import qualified Duckling.Duration.AR.Rules as Duration
|
||||
import qualified Duckling.Numeral.AR.Rules as Numeral
|
||||
import qualified Duckling.Ordinal.AR.Rules as Ordinal
|
||||
import qualified Duckling.Time.AR.Rules as Time
|
||||
import qualified Duckling.TimeGrain.AR.Rules as TimeGrain
|
||||
|
||||
defaultRules :: Some Dimension -> [Rule]
|
||||
@ -40,7 +41,7 @@ langRules (This PhoneNumber) = []
|
||||
langRules (This Quantity) = []
|
||||
langRules (This RegexMatch) = []
|
||||
langRules (This Temperature) = []
|
||||
langRules (This Time) = []
|
||||
langRules (This Time) = Time.rules
|
||||
langRules (This TimeGrain) = TimeGrain.rules
|
||||
langRules (This Url) = []
|
||||
langRules (This Volume) = []
|
||||
|
320
Duckling/Time/AR/Corpus.hs
Normal file
320
Duckling/Time/AR/Corpus.hs
Normal file
@ -0,0 +1,320 @@
|
||||
-- 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.Time.AR.Corpus
|
||||
( corpus
|
||||
) where
|
||||
|
||||
import Data.String
|
||||
import Prelude
|
||||
|
||||
import Duckling.Locale
|
||||
import Duckling.Resolve
|
||||
import Duckling.Time.Corpus
|
||||
import Duckling.Time.Types hiding (Month)
|
||||
import Duckling.TimeGrain.Types hiding (add)
|
||||
import Duckling.Testing.Types hiding (examples)
|
||||
|
||||
corpus :: Corpus
|
||||
corpus = (testContext {locale = makeLocale AR Nothing}, allExamples)
|
||||
|
||||
allExamples :: [Example]
|
||||
allExamples = concat
|
||||
[ examples (datetime (2013, 2, 12, 4, 30, 0) Second)
|
||||
[ "حالا"
|
||||
, "الان"
|
||||
, "في هذه اللحظة"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 0, 0, 0) Day)
|
||||
[ "اليوم"
|
||||
, "في هذا اليوم"
|
||||
]
|
||||
, examples (datetime (2013, 2, 1, 0, 0, 0) Day)
|
||||
[ "2/2013"
|
||||
, "الاول من شهر شباط"
|
||||
, "الاول من شباط"
|
||||
, "في اول شباط"
|
||||
]
|
||||
, examples (datetime (2013, 2, 11, 0, 0, 0) Day)
|
||||
[ "امس"
|
||||
, "البارحة"
|
||||
, "اليوم الماضي"
|
||||
, "اليوم السابق"
|
||||
, "اليوم المنصرم"
|
||||
]
|
||||
, examples (datetime (2013, 2, 13, 0, 0, 0) Day)
|
||||
[ "غدا"
|
||||
, "بكرة"
|
||||
, "يوم غد"
|
||||
, "بكرا"
|
||||
]
|
||||
, examples (datetime (2013, 2, 18, 0, 0, 0) Day)
|
||||
[ "الاثنين"
|
||||
, "هذا الاثنين"
|
||||
, "يوم الاثنين في 18 شباط"
|
||||
, "الاثنين 18 شباط"
|
||||
]
|
||||
, examples (datetime (2013, 2, 19, 0, 0, 0) Day)
|
||||
[ "الثلاثاء"
|
||||
, "الثلاثاء التاسع عشر من هذا الشهر"
|
||||
]
|
||||
, examples (datetime (2013, 2, 15, 0, 0, 0) Day)
|
||||
[ "الجمعة"
|
||||
, "الجمعه"
|
||||
, "يوم الجمعة 15 شباط"
|
||||
]
|
||||
, examples (datetime (2013, 8, 15, 0, 0, 0) Day)
|
||||
[ "الخميس 15 اغسطس"
|
||||
]
|
||||
, examples (datetime (2013, 2, 14, 0, 0, 0) Day)
|
||||
[ "الخميس"
|
||||
, "الخميس الموافق 14 شهر شباط"
|
||||
]
|
||||
, examples (datetime (2013, 2, 16, 0, 0, 0) Day)
|
||||
[ "السبت"
|
||||
, "السبت السادس عشر"
|
||||
]
|
||||
, examples (datetime (2013, 2, 17, 0, 0, 0) Day)
|
||||
[ "الاحد"
|
||||
, "الأحد السابع عشرة"
|
||||
]
|
||||
, examples (datetime (2013, 3, 15, 0, 0, 0) Day)
|
||||
[ "نص شهر ثلاث"
|
||||
, "منتصف اذار"
|
||||
, "في نصف شهر مارس"
|
||||
]
|
||||
, examples (datetime (2013, 3, 1, 0, 0, 0) Day)
|
||||
[ "الاول من اذار"
|
||||
, "1 مارس"
|
||||
, "في الاول من مارس"
|
||||
, "اليوم الاول من شهر ثلاثة"
|
||||
, "بداية شهر 3"
|
||||
]
|
||||
, examples (datetime (2013, 4, 4, 0, 0, 0) Day)
|
||||
[ "الرابع من ابريل"
|
||||
, "الرابع من نيسان"
|
||||
, "4 ابريل"
|
||||
]
|
||||
, examples (datetime (2013, 2, 19, 0, 0, 0) Day)
|
||||
[ "الثلاثاء القادم"
|
||||
, "قرابة الثلاثاء القادم"
|
||||
]
|
||||
, examples (datetime (2013, 2, 13, 0, 0, 0) Day)
|
||||
[ "الاربعاء، 13 شباط"
|
||||
, "الثالث عشرة من شباط"
|
||||
, "الاربعاء الموافق الثالث عشر من شباط 2013"
|
||||
]
|
||||
, examples (datetime (2013, 2, 4, 0, 0, 0) Week)
|
||||
[ "الاسبوع الماضي"
|
||||
, "الاسبوع السابق"
|
||||
, "الاسبوع المنصرم"
|
||||
]
|
||||
, examples (datetime (2013, 2, 11, 0, 0, 0) Week)
|
||||
[ "هذا الاسبوع"
|
||||
, "الاسبوع الحالي"
|
||||
]
|
||||
, examples (datetime (2013, 2, 18, 0, 0, 0) Week)
|
||||
[ "الاسبوع القادم"
|
||||
, "الاسبوع التالي"
|
||||
, "الاسبوع المقبل"
|
||||
, "الاسبوع الجاي"
|
||||
]
|
||||
, examples (datetime (2013, 1, 1, 0, 0, 0) Month)
|
||||
[ "الشهر الماض" ]
|
||||
, examples (datetime (2013, 3, 1, 0, 0, 0) Month)
|
||||
[ "الشهر التالي" ]
|
||||
, examples (datetime (2012, 1, 1, 0, 0, 0) Year)
|
||||
[ "السنة السابقة" ]
|
||||
, examples (datetime (2014, 1, 1, 0, 0, 0) Year)
|
||||
[ "السنة القادمة" ]
|
||||
, examples (datetime (2013, 1, 1, 0, 0, 0) Year)
|
||||
[ "السنة الحالية"
|
||||
, "هذه السنة"
|
||||
]
|
||||
, examples (datetime (2013, 2, 10, 0, 0, 0) Day)
|
||||
[ "الاحد الماضي"
|
||||
, "احد الاسبوع الماضي"
|
||||
, "الاحد من الاسبوع الماضي"
|
||||
]
|
||||
, examples (datetime (2013, 2, 11, 0, 0, 0) Day)
|
||||
[ "اثنين الاسبوع الحالي"
|
||||
, "الاثنين من هذا الاسبوع"
|
||||
]
|
||||
, examples (datetime (2013, 2, 5, 0, 0, 0) Day)
|
||||
[ "الثلاثاء الماضي"
|
||||
, "يوم الثلاثاء السابق"
|
||||
, "ثلاثاء الاسبوع الفائت"
|
||||
]
|
||||
, examples (datetime (2013, 2, 14, 0, 0, 0) Day)
|
||||
[ "يوم بعد غد"
|
||||
, "اليوم الذي بعد الغد"
|
||||
, "اليوم الي بعد بكرة"
|
||||
]
|
||||
, examples (datetime (2013, 2, 10, 0, 0, 0) Day)
|
||||
[ "يوم قبل امس"
|
||||
, "اليوم القبل البارحة"
|
||||
, "اليوم الي قبل امبارح"
|
||||
]
|
||||
, examples (datetime (2013, 3, 25, 0, 0, 0) Day)
|
||||
[ "اخر اثنين من شهر اذار"
|
||||
, "الاثنين الاخير من شهر ثلاثة"
|
||||
, "اخر اثنين من الشهر القادم"
|
||||
]
|
||||
, examples (datetime (2014, 3, 25, 0, 0, 0) Day)
|
||||
[ "الثلاثاء الاخير من شهر مارس السنة القادمة" ]
|
||||
, examples (datetime (2013, 10, 3, 0, 0, 0) Day)
|
||||
[ "اليوم الثالث من اكتوبر"
|
||||
, "اليوم الثالث من شهر عشرة"
|
||||
, "ثالث يوم من شهر عشرة"
|
||||
]
|
||||
, examples (datetime (2014, 10, 6, 0, 0, 0) Week)
|
||||
[ "اول اسبوع بشهر اكتوبر 2014"
|
||||
, "الاسبوع الاول من شهر عشرة 2014"
|
||||
]
|
||||
, examples (datetime (2015, 10, 31, 0, 0, 0) Day)
|
||||
[ "اخر يوم بشهر عشرة سنة 2015"
|
||||
, "اليوم الاخير من شهر عشرة سنة 2015"
|
||||
]
|
||||
, examples (datetime (2014, 9, 22, 0, 0, 0) Week)
|
||||
[ "اخر اسبوع في سبتمبر لعام 2014"
|
||||
, "الاسبوع الاخير في الشهر التاسع سنة 2014"
|
||||
]
|
||||
, examples (datetime (2013, 10, 1, 0, 0, 0) Day)
|
||||
[ "اول ثلاثاء من شهر عشرة"
|
||||
, "الثلاثاء الأولى من اكتوبر"
|
||||
, "الثلاثا الاول من شهر تشرين الاول"
|
||||
]
|
||||
, examples (datetime (2014, 9, 16, 0, 0, 0) Day)
|
||||
[ "الثلاثاء الثالث من شهر ايلول من عام 2014"
|
||||
, "ثالث يوم ثلاثاء بايلول بعام 2014"
|
||||
, "ثالث ثلاثاء في ايلول في سنة 2014"
|
||||
]
|
||||
, examples (datetime (2014, 10, 8, 0, 0, 0) Day)
|
||||
[ "ثاني اربعاء من شهر اكتوبر من عام 2014"
|
||||
, "ثان اربعا في اكتوبر لعام 2014"
|
||||
, "الاربعاء الثانية من شهر اكتوبر في سنة 2014"
|
||||
]
|
||||
, examples (datetime (2015, 1, 13, 0, 0, 0) Day)
|
||||
[ "ثالث ثلاثاء بعد كريسماس 2014"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 3, 0, 0) Hour)
|
||||
[ "الساعة 3 صباحا"
|
||||
, "الساعة ثلاثة الصبح"
|
||||
, "عند الساعة الثالثة صباحا"
|
||||
, "الساعة 3 الفجر"
|
||||
, "الثالثة فجرا"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 3, 18, 0) Minute)
|
||||
[ "3:18 صباحا"
|
||||
, "الساعة ثلاثة وثمانية عشرة دقيقة صباحا"
|
||||
, "الساعة الثالثة و18 دقيقة الصبح"
|
||||
, "الساعة 3 و 18 دقيقة صباحا"
|
||||
, "عند الثالثة وثمانية عشر دقيقة صباحا"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 15, 0, 0) Hour)
|
||||
[ "الساعة الثالثة عصرا"
|
||||
, "بحدود الساعة الثالثة"
|
||||
, "حوالي الساعة 3"
|
||||
, "الساعة 3 بعد الظهر"
|
||||
, "الساعة 3 عصرا"
|
||||
, "الساعة 3 العصر"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 15, 15, 0) Minute)
|
||||
[ "الساعة 3 و15 دقيقة عصرا"
|
||||
, "الساعة الثالثة وربع العصر"
|
||||
, "الثالثة وربع بعد الظهر"
|
||||
, "15:15"
|
||||
, "الساعة الثالثة وخمسة عشر دقيقة عصرا"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 15, 20, 0) Minute)
|
||||
[ "الساعة ثلاثة وثلث مساءا"
|
||||
, "3:20 عصرا"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 12, 30, 0) Minute)
|
||||
[ "الساعة الثانية عشرة ونصف ظهرا"
|
||||
, "12:30"
|
||||
, "12:30 ظهرا"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 15, 23, 24) Second)
|
||||
[ "15:23:24"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 11, 45, 0) Minute)
|
||||
[ "الساعة 11:45 قبل الظهر"
|
||||
, "الساعة 12 الا ربع قبل الظهر"
|
||||
, "الساعة الحادية عشر وخمس واربعون دقيقة صباحا"
|
||||
, "الساعة الثانية عشر إلا ربعا هذا الصباح"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 16, 40, 0) Minute)
|
||||
[ "الساعة الخامسة الا ثلث بعد العصر"
|
||||
, "الساعة خمسة إلا ثلث قبل المغرب"
|
||||
, "الساعة الرابعة واربعون دقيقة بعد العصر"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 20, 0, 0) Hour)
|
||||
[ "الساعة 8 بعد المغرب"
|
||||
, "الساعة 8 العشاء"
|
||||
, "الثامنة هذه الليلة"
|
||||
]
|
||||
, examples (datetime (2013, 2, 14, 6, 0, 0) Minute)
|
||||
[ "الخميس الساعة 8 بتوقيت GMT"
|
||||
]
|
||||
, examples (datetime (2013, 9, 21, 13, 30, 0) Minute)
|
||||
[ "يوم السبت 21/09 الساعة 1:30 بعد الظهر"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 4, 23, 0) Minute)
|
||||
[ "الساعة الرابعة وثلاث وعشرون دقيقة فجرا"
|
||||
, "الساعة 4:23 الصبح"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 3, 1, 0, 0, 0), (2013, 3, 11, 0, 0, 0)) Day)
|
||||
[ "في اوائل اذار"
|
||||
, "في أوائل شهر مارس"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 3, 21, 0, 0, 0), (2013, 4, 1, 0, 0, 0)) Day)
|
||||
[ "في اواخر اذار"
|
||||
, "في أواخر شهر مارس"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 2, 18, 0, 0, 0), (2013, 3, 11, 0, 0, 0)) Week)
|
||||
[ "الاسابيع الثلاثة القادمة"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 2, 12, 15, 0, 0), (2013, 2, 12, 17, 0, 0)) Hour)
|
||||
[ "من الساعة 3 الى الساعة 4 بعد العصر"
|
||||
, "من الساعة الثالثة الى الساعة الرابعة مساءا"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 2, 14, 9, 0, 0), (2013, 2, 14, 12, 0, 0)) Hour)
|
||||
[ "الخميس من الساعة التاسعة وحتى الساعة الحادية عشرة صباحا"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 7, 13, 0, 0, 0), (2013, 7, 16, 0, 0, 0)) Day)
|
||||
[ "يوليو 13-15"
|
||||
, "تموز 13 الى 15"
|
||||
, "13 الى 15 تموز"
|
||||
, "من 13 تموز الى 15 تموز"
|
||||
, "من 13 الى 15 يوليو"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 2, 12, 4, 30, 0), (2013, 2, 12, 14, 0, 0)) Second)
|
||||
[ "حتى الساعة 2:00"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 2, 12, 18, 0, 0), (2013, 2, 13, 0, 0, 0)) Hour)
|
||||
[ "هذه الليلة"
|
||||
, "الليلة"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 2, 12, 4, 30, 0), (2013, 2, 26, 0, 0, 0)) Second)
|
||||
[ "خلال اسبوعين"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 9, 1, 0, 0, 0), (2013, 9, 9, 0, 0, 0)) Day)
|
||||
[ "من 1-8 شهر ايلول"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 10, 23, 0, 0, 0), (2013, 10, 27, 0, 0, 0)) Day)
|
||||
[ "من الثالث والعشرون وحتى السادس والعشرين من شهر اكتوبر"
|
||||
]
|
||||
, examples (datetimeInterval ((2013, 8, 27, 0, 0, 0), (2013, 8, 30, 0, 0, 0)) Day)
|
||||
[ "اغسطس 27 الى 29"
|
||||
, "من 27-29 من الشهر الثامن"
|
||||
]
|
||||
|
||||
]
|
1836
Duckling/Time/AR/Rules.hs
Normal file
1836
Duckling/Time/AR/Rules.hs
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,13 +21,14 @@ 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)
|
||||
, ("year (grain)" , "سن(ة|ين)|عام" , TG.Year)
|
||||
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]
|
||||
|
@ -456,6 +456,8 @@ library
|
||||
, Duckling.Temperature.Types
|
||||
|
||||
-- Time
|
||||
, Duckling.Time.AR.Corpus
|
||||
, Duckling.Time.AR.Rules
|
||||
, Duckling.Time.DA.Corpus
|
||||
, Duckling.Time.DA.Rules
|
||||
, Duckling.Time.DE.Corpus
|
||||
@ -790,6 +792,7 @@ test-suite duckling-test
|
||||
, Duckling.Temperature.Tests
|
||||
|
||||
-- Time
|
||||
, Duckling.Time.AR.Tests
|
||||
, Duckling.Time.DA.Tests
|
||||
, Duckling.Time.DE.Tests
|
||||
, Duckling.Time.EL.Tests
|
||||
|
@ -27,6 +27,7 @@ import Duckling.Ranking.Train
|
||||
import Duckling.Ranking.Types
|
||||
import Duckling.Rules
|
||||
import Duckling.Testing.Types
|
||||
import qualified Duckling.Time.AR.Corpus as ARTime
|
||||
import qualified Duckling.Time.DA.Corpus as DATime
|
||||
import qualified Duckling.Time.DE.Corpus as DETime
|
||||
import qualified Duckling.Time.EL.Corpus as ELTime
|
||||
@ -159,7 +160,7 @@ getDefaultCorpusForLang EN = ENTime.defaultCorpus
|
||||
getDefaultCorpusForLang lang = getCorpusForLang lang
|
||||
|
||||
getCorpusForLang :: Lang -> Corpus
|
||||
getCorpusForLang AR = (testContext, [])
|
||||
getCorpusForLang AR = ARTime.corpus
|
||||
getCorpusForLang BG = (testContext, [])
|
||||
getCorpusForLang CS = (testContext, [])
|
||||
getCorpusForLang DA = DATime.corpus
|
||||
|
@ -122,7 +122,7 @@ supportedDimensionsTest = testCase "Supported Dimensions Test" $ do
|
||||
mapM_ check
|
||||
[ ( AR
|
||||
, [ This Email, This AmountOfMoney, This PhoneNumber, This Url
|
||||
, This Duration, This Numeral, This Ordinal
|
||||
, This Duration, This Numeral, This Ordinal, This Time
|
||||
]
|
||||
)
|
||||
, ( PL
|
||||
|
23
tests/Duckling/Time/AR/Tests.hs
Normal file
23
tests/Duckling/Time/AR/Tests.hs
Normal file
@ -0,0 +1,23 @@
|
||||
-- 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.
|
||||
|
||||
|
||||
module Duckling.Time.AR.Tests
|
||||
( tests ) where
|
||||
|
||||
import Data.String
|
||||
import Prelude
|
||||
import Test.Tasty
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Testing.Asserts
|
||||
import Duckling.Time.AR.Corpus
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "AR Tests"
|
||||
[ makeCorpusTest [This Time] corpus
|
||||
]
|
@ -24,6 +24,7 @@ import Duckling.Testing.Asserts
|
||||
import Duckling.Testing.Types
|
||||
import Duckling.Time.Types
|
||||
import Duckling.TimeGrain.Types
|
||||
import qualified Duckling.Time.AR.Tests as AR
|
||||
import qualified Duckling.Time.DA.Tests as DA
|
||||
import qualified Duckling.Time.DE.Tests as DE
|
||||
import qualified Duckling.Time.EN.Tests as EN
|
||||
@ -47,7 +48,8 @@ import qualified Duckling.Time.ZH.Tests as ZH
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "Time Tests"
|
||||
[ DA.tests
|
||||
[ AR.tests
|
||||
, DA.tests
|
||||
, DE.tests
|
||||
, EL.tests
|
||||
, EN.tests
|
||||
|
Loading…
Reference in New Issue
Block a user