module Duckling.Quantity.RO.Rules
( rules ) where
import Prelude
import Data.String
import Duckling.Dimensions.Types
import Duckling.Numeral.Types (NumeralData (..))
import qualified Duckling.Numeral.Types as TNumeral
import Duckling.Quantity.Helpers
import qualified Duckling.Quantity.Types as TQuantity
import Duckling.Regex.Types
import Duckling.Types
ruleNumeralUnits :: Rule
ruleNumeralUnits = Rule
{ name = "<number> <units>"
, pattern =
[ dimension Numeral
, regex "livr(a|e|ă)"
]
, prod = \tokens -> case tokens of
(Token Numeral NumeralData {TNumeral.value = v}:_) ->
Just . Token Quantity $ quantity TQuantity.Pound v
_ -> Nothing
}
ruleQuantityOfProduct :: Rule
ruleQuantityOfProduct = Rule
{ name = "<quantity> of product"
, pattern =
[ dimension Quantity
, regex "de (carne|can(a|ă)|zah(a|ă)r)"
]
, prod = \tokens -> case tokens of
(Token Quantity qd:
Token RegexMatch (GroupMatch (match:_)):
_) -> Just . Token Quantity $ withProduct match qd
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleNumeralUnits
, ruleQuantityOfProduct
]