Skip to content

Commit

Permalink
Temperature/RO: Fix for values above 20
Browse files Browse the repository at this point in the history
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
  • Loading branch information
patapizza authored and facebook-github-bot committed Jun 8, 2018
1 parent 11316b3 commit f705206
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Duckling/Temperature/RO/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -41,5 +44,6 @@ allExamples = concat
, examples (simple Degree 45)
[ "45°"
, "45 grade"
, "45 de grade"
]
]
20 changes: 11 additions & 9 deletions Duckling/Temperature/RO/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f705206

Please sign in to comment.