mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
Add Ordinal dimension to CA (Catalan) locale
Summary: Adds Ordinal rules to Catalan language Reviewed By: patapizza Differential Revision: D27681617 Pulled By: chessai fbshipit-source-id: 145a1117eeff10839484f34a87e9bd685382d42e
This commit is contained in:
parent
7907812184
commit
f3e128a07b
126
Duckling/Ordinal/CA/Corpus.hs
Normal file
126
Duckling/Ordinal/CA/Corpus.hs
Normal file
@ -0,0 +1,126 @@
|
||||
-- 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.
|
||||
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Ordinal.CA.Corpus
|
||||
( corpus ) where
|
||||
|
||||
import Data.String
|
||||
import Prelude
|
||||
|
||||
import Duckling.Locale
|
||||
import Duckling.Ordinal.Types
|
||||
import Duckling.Resolve
|
||||
import Duckling.Testing.Types
|
||||
|
||||
corpus :: Corpus
|
||||
corpus = (testContext {locale = makeLocale CA Nothing}, testOptions, allExamples)
|
||||
|
||||
allExamples :: [Example]
|
||||
allExamples = concat
|
||||
[ examples (OrdinalData 1)
|
||||
[ "primer"
|
||||
, "primera"
|
||||
, "primers"
|
||||
, "primeres"
|
||||
]
|
||||
, examples (OrdinalData 2)
|
||||
[ "segon"
|
||||
, "segona"
|
||||
, "segons"
|
||||
, "segones"
|
||||
]
|
||||
, examples (OrdinalData 3)
|
||||
[ "tercer"
|
||||
, "tercera"
|
||||
, "tercers"
|
||||
, "terceres"
|
||||
]
|
||||
, examples (OrdinalData 4)
|
||||
[ "quart"
|
||||
, "quarta"
|
||||
, "quarts"
|
||||
, "quartes"
|
||||
]
|
||||
, examples (OrdinalData 5)
|
||||
[ "cinquè"
|
||||
, "cinquena"
|
||||
, "cinquens"
|
||||
, "cinquenes"
|
||||
]
|
||||
, examples (OrdinalData 6)
|
||||
[ "sisè"
|
||||
, "sisena"
|
||||
, "sisens"
|
||||
, "sisenes"
|
||||
]
|
||||
, examples (OrdinalData 7)
|
||||
[ "setè"
|
||||
, "setena"
|
||||
, "setens"
|
||||
, "setenes"
|
||||
]
|
||||
, examples (OrdinalData 8)
|
||||
[ "vuitè"
|
||||
, "vuitena"
|
||||
, "vuitens"
|
||||
, "vuitenes"
|
||||
]
|
||||
, examples (OrdinalData 9)
|
||||
[ "novè"
|
||||
, "novena"
|
||||
, "novens"
|
||||
, "novenes"
|
||||
]
|
||||
, examples (OrdinalData 10)
|
||||
[ "desè"
|
||||
, "desena"
|
||||
, "desens"
|
||||
, "desenes"
|
||||
]
|
||||
, examples (OrdinalData 11)
|
||||
[ "onzè"
|
||||
, "onzena"
|
||||
]
|
||||
, examples (OrdinalData 12)
|
||||
[ "dotzè"
|
||||
, "dotzena"
|
||||
]
|
||||
, examples (OrdinalData 13)
|
||||
[ "tretzè"
|
||||
, "tretzena"
|
||||
]
|
||||
, examples (OrdinalData 14)
|
||||
[ "catorzè"
|
||||
, "catorzena"
|
||||
]
|
||||
, examples (OrdinalData 15)
|
||||
[ "quinzè"
|
||||
, "quinzena"
|
||||
]
|
||||
, examples (OrdinalData 16)
|
||||
[ "setzè"
|
||||
, "setzena"
|
||||
]
|
||||
, examples (OrdinalData 17)
|
||||
[ "dissetè"
|
||||
, "dissetena"
|
||||
]
|
||||
, examples (OrdinalData 18)
|
||||
[ "divuitè"
|
||||
, "divuitena"
|
||||
]
|
||||
, examples (OrdinalData 19)
|
||||
[ "dinovè"
|
||||
, "dinovena"
|
||||
]
|
||||
, examples (OrdinalData 20)
|
||||
[ "vintè"
|
||||
, "vintena"
|
||||
]
|
||||
]
|
104
Duckling/Ordinal/CA/Rules.hs
Normal file
104
Duckling/Ordinal/CA/Rules.hs
Normal file
@ -0,0 +1,104 @@
|
||||
-- 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.
|
||||
|
||||
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Duckling.Ordinal.CA.Rules
|
||||
( rules ) where
|
||||
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
import qualified Data.Text as Text
|
||||
import Prelude
|
||||
import Data.String
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Ordinal.Helpers
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Types
|
||||
|
||||
ordinalsMap :: HashMap.HashMap Text.Text Int
|
||||
ordinalsMap = HashMap.fromList
|
||||
[ ( "primer" , 1 )
|
||||
, ( "primers" , 1 )
|
||||
, ( "primera" , 1 )
|
||||
, ( "primeres" , 1 )
|
||||
, ( "segon" , 2 )
|
||||
, ( "segona" , 2 )
|
||||
, ( "segones" , 2 )
|
||||
, ( "segons" , 2 )
|
||||
, ( "tercer" , 3 )
|
||||
, ( "tercera" , 3 )
|
||||
, ( "tercers" , 3 )
|
||||
, ( "terceres" , 3 )
|
||||
, ( "quart" , 4 )
|
||||
, ( "quarta" , 4 )
|
||||
, ( "quarts" , 4 )
|
||||
, ( "quartes" , 4 )
|
||||
, ( "cinquè" , 5 )
|
||||
, ( "cinquena" , 5 )
|
||||
, ( "cinquens" , 5 )
|
||||
, ( "cinquenes" , 5 )
|
||||
, ( "sisè" , 6 )
|
||||
, ( "sisena" , 6 )
|
||||
, ( "sisens" , 6 )
|
||||
, ( "sisenes" , 6 )
|
||||
, ( "setè" , 7 )
|
||||
, ( "setena" , 7 )
|
||||
, ( "setens" , 7 )
|
||||
, ( "setenes" , 7 )
|
||||
, ( "vuitè" , 8 )
|
||||
, ( "vuitena" , 8 )
|
||||
, ( "vuitens" , 8 )
|
||||
, ( "vuitenes" , 8 )
|
||||
, ( "novè" , 9 )
|
||||
, ( "novena" , 9 )
|
||||
, ( "novens" , 9 )
|
||||
, ( "novenes" , 9 )
|
||||
, ( "desè" , 10 )
|
||||
, ( "desena" , 10 )
|
||||
, ( "desens" , 10 )
|
||||
, ( "desenes" , 10 )
|
||||
, ( "onzè" , 11 )
|
||||
, ( "onzena" , 11 )
|
||||
, ( "dotzè" , 12 )
|
||||
, ( "dotzena" , 12 )
|
||||
, ( "tretzè" , 13 )
|
||||
, ( "tretzena" , 13 )
|
||||
, ( "catorzè" , 14 )
|
||||
, ( "catorzena" , 14 )
|
||||
, ( "quinzè" , 15 )
|
||||
, ( "quinzena" , 15 )
|
||||
, ( "setzè" , 16 )
|
||||
, ( "setzena" , 16 )
|
||||
, ( "dissetè" , 17 )
|
||||
, ( "dissetena" , 17 )
|
||||
, ( "divuitè" , 18 )
|
||||
, ( "divuitena" , 18 )
|
||||
, ( "dinovè" , 19 )
|
||||
, ( "dinovena" , 19 )
|
||||
, ( "vintè" , 20 )
|
||||
, ( "vintena" , 20 )
|
||||
]
|
||||
|
||||
ruleOrdinalsPrimero :: Rule
|
||||
ruleOrdinalsPrimero = Rule
|
||||
{ name = "ordinals (primero..10)"
|
||||
, pattern =
|
||||
[ regex "(primer(a|s|es)?|segon(a|s|es)?|tercer(a|s|es)?|quart(a|s|es)?|cinqu(è|(en(a|s|es)))|sis(è|en(a|s|es))|set(è|en(a|s|es))|vuit(è|en(a|s|es))|nov(è|en(a|s|es))|des(è|en(a|s|es))|onz(è|ena)|dotz(è|ena)|tretz(è|ena)|catorz(è|ena)|quinz(è|ena)|setz(è|ena)|disset(è|ena)|divuit(è|ena)|dinov(è|ena)|vint(è|ena))"
|
||||
]
|
||||
, prod = \case
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) ->
|
||||
ordinal <$> HashMap.lookup (Text.toLower match) ordinalsMap
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
rules :: [Rule]
|
||||
rules =
|
||||
[ ruleOrdinalsPrimero
|
||||
]
|
@ -18,6 +18,7 @@ module Duckling.Rules.CA
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Locale
|
||||
import qualified Duckling.Numeral.CA.Rules as Numeral
|
||||
import qualified Duckling.Ordinal.CA.Rules as Ordinal
|
||||
import Duckling.Types
|
||||
|
||||
defaultRules :: Seal Dimension -> [Rule]
|
||||
@ -34,7 +35,7 @@ langRules (Seal Distance) = []
|
||||
langRules (Seal Duration) = []
|
||||
langRules (Seal Email) = []
|
||||
langRules (Seal Numeral) = Numeral.rules
|
||||
langRules (Seal Ordinal) = []
|
||||
langRules (Seal Ordinal) = Ordinal.rules
|
||||
langRules (Seal PhoneNumber) = []
|
||||
langRules (Seal Quantity) = []
|
||||
langRules (Seal RegexMatch) = []
|
||||
|
@ -530,6 +530,8 @@ library
|
||||
, Duckling.Ordinal.AR.Rules
|
||||
, Duckling.Ordinal.BG.Corpus
|
||||
, Duckling.Ordinal.BG.Rules
|
||||
, Duckling.Ordinal.CA.Corpus
|
||||
, Duckling.Ordinal.CA.Rules
|
||||
, Duckling.Ordinal.DA.Corpus
|
||||
, Duckling.Ordinal.DA.Rules
|
||||
, Duckling.Ordinal.DE.Corpus
|
||||
@ -1037,6 +1039,7 @@ test-suite duckling-test
|
||||
-- Ordinal
|
||||
, Duckling.Ordinal.AR.Tests
|
||||
, Duckling.Ordinal.BG.Tests
|
||||
, Duckling.Ordinal.CA.Tests
|
||||
, Duckling.Ordinal.DA.Tests
|
||||
, Duckling.Ordinal.DE.Tests
|
||||
, Duckling.Ordinal.EL.Tests
|
||||
|
22
tests/Duckling/Ordinal/CA/Tests.hs
Normal file
22
tests/Duckling/Ordinal/CA/Tests.hs
Normal file
@ -0,0 +1,22 @@
|
||||
-- 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.
|
||||
|
||||
|
||||
module Duckling.Ordinal.CA.Tests
|
||||
( tests ) where
|
||||
|
||||
import Data.String
|
||||
import Prelude
|
||||
import Test.Tasty
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Ordinal.CA.Corpus
|
||||
import Duckling.Testing.Asserts
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "CA Tests"
|
||||
[ makeCorpusTest [Seal Ordinal] corpus
|
||||
]
|
@ -8,11 +8,11 @@
|
||||
module Duckling.Ordinal.Tests (tests) where
|
||||
|
||||
import Data.String
|
||||
import Prelude
|
||||
import Test.Tasty
|
||||
|
||||
import qualified Duckling.Ordinal.AR.Tests as AR
|
||||
import qualified Duckling.Ordinal.BG.Tests as BG
|
||||
import qualified Duckling.Ordinal.CA.Tests as CA
|
||||
import qualified Duckling.Ordinal.DA.Tests as DA
|
||||
import qualified Duckling.Ordinal.DE.Tests as DE
|
||||
import qualified Duckling.Ordinal.EL.Tests as EL
|
||||
@ -50,6 +50,7 @@ tests :: TestTree
|
||||
tests = testGroup "Ordinal Tests"
|
||||
[ AR.tests
|
||||
, BG.tests
|
||||
, CA.tests
|
||||
, DA.tests
|
||||
, DE.tests
|
||||
, EL.tests
|
||||
|
Loading…
Reference in New Issue
Block a user