ES/Ordinal: Fixes + tests

Summary:
* fixes '1st' variants (e.g. primeros, primera)
* fixes accents

Reviewed By: JonCoens

Differential Revision: D5772079

fbshipit-source-id: 6a09d79
This commit is contained in:
Julien Odent 2017-09-06 09:54:00 -07:00 committed by Facebook Github Bot
parent 6f774abe38
commit b954380937
6 changed files with 75 additions and 7 deletions

View File

@ -0,0 +1,42 @@
-- 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.Ordinal.ES.Corpus
( corpus ) where
import Data.String
import Prelude
import Duckling.Lang
import Duckling.Ordinal.Types
import Duckling.Resolve
import Duckling.Testing.Types
corpus :: Corpus
corpus = (testContext {lang = ES}, allExamples)
allExamples :: [Example]
allExamples = concat
[ examples (OrdinalData 1)
[ "primer"
, "primero"
, "primeras"
]
, examples (OrdinalData 2)
[ "segundo"
, "segunda"
, "segundos"
]
, examples (OrdinalData 10)
[ "decimo"
, "decimas"
, "décimos"
]
]

View File

@ -66,21 +66,21 @@ ordinalsMap = HashMap.fromList
, ( "novena" , 9 )
, ( "noveno" , 9 )
, ( "novenas" , 9 )
, ( "d\x00e9cimos" , 10 )
, ( "d\233cimos" , 10 )
, ( "decimo" , 10 )
, ( "decimos" , 10 )
, ( "d\x00e9cimo" , 10 )
, ( "d\233cimo" , 10 )
, ( "decimas" , 10 )
, ( "d\x00e9cima" , 10 )
, ( "d\233cima" , 10 )
, ( "decima" , 10 )
, ( "d\x00e9cimas" , 10 )
, ( "d\233cimas" , 10 )
]
ruleOrdinalsPrimero :: Rule
ruleOrdinalsPrimero = Rule
{ name = "ordinals (primero..10)"
, pattern =
[ regex "(primer|tercer(os?|as?)?|(primer|segund|cuart|quint|sext|s[e\x00e9]ptim|octav|noven|d[e\x00e9]cim)(os?|as?))"
[ regex "((primer|segund|cuart|quint|sext|s(e|\x00e9)ptim|octav|noven|d(e|\x00e9)cim)(os?|as?)|(prim|terc)er)"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (match:_)):_) ->

View File

@ -630,8 +630,8 @@ classifiers
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0},
koData =
ClassData{prior = 0.0, unseen = -2.4849066497880004,
likelihoods = HashMap.fromList [("", 0.0)], n = 10}}),
ClassData{prior = 0.0, unseen = -2.639057329615259,
likelihoods = HashMap.fromList [("", 0.0)], n = 12}}),
("this <part-of-day>",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.6094379124341003,

View File

@ -319,6 +319,7 @@ library
, Duckling.Ordinal.DE.Rules
, Duckling.Ordinal.EN.Corpus
, Duckling.Ordinal.EN.Rules
, Duckling.Ordinal.ES.Corpus
, Duckling.Ordinal.ES.Rules
, Duckling.Ordinal.ET.Corpus
, Duckling.Ordinal.ET.Rules

View 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.Ordinal.ES.Tests
( tests ) where
import Data.String
import Prelude
import Test.Tasty
import Duckling.Dimensions.Types
import Duckling.Ordinal.ES.Corpus
import Duckling.Testing.Asserts
tests :: TestTree
tests = testGroup "ES Tests"
[ makeCorpusTest [This Ordinal] corpus
]

View File

@ -16,6 +16,7 @@ import qualified Duckling.Ordinal.AR.Tests as AR
import qualified Duckling.Ordinal.DA.Tests as DA
import qualified Duckling.Ordinal.DE.Tests as DE
import qualified Duckling.Ordinal.EN.Tests as EN
import qualified Duckling.Ordinal.ES.Tests as ES
import qualified Duckling.Ordinal.ET.Tests as ET
import qualified Duckling.Ordinal.FR.Tests as FR
import qualified Duckling.Ordinal.GA.Tests as GA
@ -44,6 +45,7 @@ tests = testGroup "Ordinal Tests"
, DA.tests
, DE.tests
, EN.tests
, ES.tests
, ET.tests
, FR.tests
, GA.tests