diff --git a/Duckling/Volume/RO/Corpus.hs b/Duckling/Volume/RO/Corpus.hs index 3e136ddb6..2b0a4f374 100644 --- a/Duckling/Volume/RO/Corpus.hs +++ b/Duckling/Volume/RO/Corpus.hs @@ -9,7 +9,8 @@ {-# LANGUAGE OverloadedStrings #-} module Duckling.Volume.RO.Corpus - ( corpus ) where + ( corpus + ) where import Data.String import Prelude @@ -26,8 +27,10 @@ allExamples :: [Example] allExamples = concat [ examples (VolumeValue Millilitre 250) [ "250 mililitri" + , "250 de mililitri" , "250ml" , "250 ml" + , "250 de ml" ] , examples (VolumeValue Litre 2) [ "2 litri" @@ -45,4 +48,7 @@ allExamples = concat [ "jumatate de litru" , "jumătate de litru" ] + , examples (VolumeValue Gallon 20) + [ "douazeci de galoane" + ] ] diff --git a/Duckling/Volume/RO/Rules.hs b/Duckling/Volume/RO/Rules.hs index 012814a8a..4b63aa3b5 100644 --- a/Duckling/Volume/RO/Rules.hs +++ b/Duckling/Volume/RO/Rules.hs @@ -7,13 +7,15 @@ {-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Duckling.Volume.RO.Rules - ( rules ) where + ( rules + ) where -import Prelude import Data.String +import Prelude import Duckling.Dimensions.Types import Duckling.Types @@ -25,9 +27,9 @@ ruleLatentVolMl = Rule { name = " ml" , pattern = [ dimension Volume - , regex "m(ililitr[ui]|l)" + , regex "(de )?m(ililitr[ui]|l)" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Volume vd:_) -> Just . Token Volume $ withUnit TVolume.Millilitre vd _ -> Nothing @@ -38,9 +40,9 @@ ruleVolHectoliters = Rule { name = " hectoliters" , pattern = [ dimension Volume - , regex "hectolitr[ui]" + , regex "(de )?hectolitr[ui]" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Volume vd:_) -> Just . Token Volume $ withUnit TVolume.Hectolitre vd _ -> Nothing @@ -51,9 +53,9 @@ ruleVolLiters = Rule { name = " liters" , pattern = [ dimension Volume - , regex "l(itr[ui])?" + , regex "(de )?l(itr[ui])?" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Volume vd:_) -> Just . Token Volume $ withUnit TVolume.Litre vd _ -> Nothing @@ -65,7 +67,7 @@ ruleHalfLiter = Rule , pattern = [ regex "jum(a|ă)tate de litr[ui]" ] - , prod = \_ -> Just . Token Volume . withUnit TVolume.Litre $ volume 0.5 + , prod = const . Just . Token Volume . withUnit TVolume.Litre $ volume 0.5 } ruleLatentVolGalon :: Rule @@ -73,9 +75,9 @@ ruleLatentVolGalon = Rule { name = " galon" , pattern = [ dimension Volume - , regex "gal(oane|on)?" + , regex "(de )?gal(oane|on)?" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Volume vd:_) -> Just . Token Volume $ withUnit TVolume.Gallon vd _ -> Nothing