Temperature/RO: Fix for values above 20

Summary:
In Romanian, for numerals above 20, we say "20 de grade", not "20 grade".
Here we optimize for recall and allow "20 de grade de celsius", "20 de grade
celsius", "20 grade de celsius", "20 grade celsius".
This would actually allow things like "4 de grade", though it's fine as it
doesn't alter meaning.

Differential Revision: D8332923

fbshipit-source-id: e6ae0ecc902ac5db9be504b5ff6a14b1ec996413
This commit is contained in:
Julien Odent 2018-06-08 09:38:05 -07:00 committed by Facebook Github Bot
parent 11316b34af
commit f705206fb2
2 changed files with 17 additions and 11 deletions

View File

@ -9,10 +9,11 @@
{-# LANGUAGE OverloadedStrings #-}
module Duckling.Temperature.RO.Corpus
( corpus ) where
( corpus
) where
import Prelude
import Data.String
import Prelude
import Duckling.Locale
import Duckling.Resolve
@ -30,7 +31,9 @@ allExamples = concat
, "37 grade Celsius"
, "treizeci si sapte celsius"
, "37 grade Celsius"
, "37 de grade de Celsius"
, "treizeci si sapte celsius"
, "treizeci si sapte de celsius"
]
, examples (simple Fahrenheit 70)
[ "70°F"
@ -41,5 +44,6 @@ allExamples = concat
, examples (simple Degree 45)
[ "45°"
, "45 grade"
, "45 de grade"
]
]

View File

@ -7,27 +7,29 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.Temperature.RO.Rules
( rules ) where
( rules
) where
import Prelude
import Data.String
import Prelude
import Duckling.Dimensions.Types
import Duckling.Temperature.Helpers
import qualified Duckling.Temperature.Types as TTemperature
import Duckling.Types
import qualified Duckling.Temperature.Types as TTemperature
ruleLatentTempGrade :: Rule
ruleLatentTempGrade = Rule
{ name = "<latent temp> grade"
, pattern =
[ Predicate $ isValueOnly False
, regex "(grade)|°"
, regex "(de )?(grade)|°"
]
, prod = \tokens -> case tokens of
, prod = \case
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Degree td
_ -> Nothing
@ -38,9 +40,9 @@ ruleTempCelcius = Rule
{ name = "<temp> Celcius"
, pattern =
[ Predicate $ isValueOnly True
, regex "c(el[cs]?(ius)?)?\\.?"
, regex "(de )?c(el[cs]?(ius)?)?\\.?"
]
, prod = \tokens -> case tokens of
, prod = \case
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Celsius td
_ -> Nothing
@ -51,9 +53,9 @@ ruleTempFahrenheit = Rule
{ name = "<temp> Fahrenheit"
, pattern =
[ Predicate $ isValueOnly True
, regex "f(ah?rh?eh?n(h?eit)?)?\\.?"
, regex "(de )?f(ah?rh?eh?n(h?eit)?)?\\.?"
]
, prod = \tokens -> case tokens of
, prod = \case
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Fahrenheit td
_ -> Nothing