Skip to content

Commit 3d23372

Browse files
patapizzafacebook-github-bot
authored andcommitted
Volume/RO: Fix for values above 20
Summary: In Romanian, for numerals above 20, we say "20 de litri", not "20 litri". This would actually allow things like "4 de litri", though it's fine as it doesn't alter meaning. Differential Revision: D8332996 fbshipit-source-id: 709a97cec3c09513281be19e1a9b20895874b9c4
1 parent f705206 commit 3d23372

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

Duckling/Volume/RO/Corpus.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{-# LANGUAGE OverloadedStrings #-}
1010

1111
module Duckling.Volume.RO.Corpus
12-
( corpus ) where
12+
( corpus
13+
) where
1314

1415
import Data.String
1516
import Prelude
@@ -26,8 +27,10 @@ allExamples :: [Example]
2627
allExamples = concat
2728
[ examples (VolumeValue Millilitre 250)
2829
[ "250 mililitri"
30+
, "250 de mililitri"
2931
, "250ml"
3032
, "250 ml"
33+
, "250 de ml"
3134
]
3235
, examples (VolumeValue Litre 2)
3336
[ "2 litri"
@@ -45,4 +48,7 @@ allExamples = concat
4548
[ "jumatate de litru"
4649
, "jumătate de litru"
4750
]
51+
, examples (VolumeValue Gallon 20)
52+
[ "douazeci de galoane"
53+
]
4854
]

Duckling/Volume/RO/Rules.hs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88

99
{-# LANGUAGE GADTs #-}
10+
{-# LANGUAGE LambdaCase #-}
1011
{-# LANGUAGE OverloadedStrings #-}
1112

1213
module Duckling.Volume.RO.Rules
13-
( rules ) where
14+
( rules
15+
) where
1416

15-
import Prelude
1617
import Data.String
18+
import Prelude
1719

1820
import Duckling.Dimensions.Types
1921
import Duckling.Types
@@ -25,9 +27,9 @@ ruleLatentVolMl = Rule
2527
{ name = "<latent vol> ml"
2628
, pattern =
2729
[ dimension Volume
28-
, regex "m(ililitr[ui]|l)"
30+
, regex "(de )?m(ililitr[ui]|l)"
2931
]
30-
, prod = \tokens -> case tokens of
32+
, prod = \case
3133
(Token Volume vd:_) ->
3234
Just . Token Volume $ withUnit TVolume.Millilitre vd
3335
_ -> Nothing
@@ -38,9 +40,9 @@ ruleVolHectoliters = Rule
3840
{ name = "<vol> hectoliters"
3941
, pattern =
4042
[ dimension Volume
41-
, regex "hectolitr[ui]"
43+
, regex "(de )?hectolitr[ui]"
4244
]
43-
, prod = \tokens -> case tokens of
45+
, prod = \case
4446
(Token Volume vd:_) ->
4547
Just . Token Volume $ withUnit TVolume.Hectolitre vd
4648
_ -> Nothing
@@ -51,9 +53,9 @@ ruleVolLiters = Rule
5153
{ name = "<vol> liters"
5254
, pattern =
5355
[ dimension Volume
54-
, regex "l(itr[ui])?"
56+
, regex "(de )?l(itr[ui])?"
5557
]
56-
, prod = \tokens -> case tokens of
58+
, prod = \case
5759
(Token Volume vd:_) ->
5860
Just . Token Volume $ withUnit TVolume.Litre vd
5961
_ -> Nothing
@@ -65,17 +67,17 @@ ruleHalfLiter = Rule
6567
, pattern =
6668
[ regex "jum(a|ă)tate de litr[ui]"
6769
]
68-
, prod = \_ -> Just . Token Volume . withUnit TVolume.Litre $ volume 0.5
70+
, prod = const . Just . Token Volume . withUnit TVolume.Litre $ volume 0.5
6971
}
7072

7173
ruleLatentVolGalon :: Rule
7274
ruleLatentVolGalon = Rule
7375
{ name = "<latent vol> galon"
7476
, pattern =
7577
[ dimension Volume
76-
, regex "gal(oane|on)?"
78+
, regex "(de )?gal(oane|on)?"
7779
]
78-
, prod = \tokens -> case tokens of
80+
, prod = \case
7981
(Token Volume vd:_) ->
8082
Just . Token Volume $ withUnit TVolume.Gallon vd
8183
_ -> Nothing

0 commit comments

Comments
 (0)