add: support for specific times in HI duration (#424)

Summary: Pull Request resolved: https://github.com/facebook/duckling/pull/424

Reviewed By: girifb

Differential Revision: D26411920

Pulled By: chessai

fbshipit-source-id: 3f0063e4786688579f2f53f46b31bda5d222d402
This commit is contained in:
Amit Manchanda 2021-02-17 14:35:08 -08:00 committed by Facebook GitHub Bot
parent 590651150b
commit 37b671389c
2 changed files with 27 additions and 0 deletions

View File

@ -73,4 +73,10 @@ allExamples = concat
[ "1 साल, 2 दिन, 3 घंटा और 4 सेकंड"
, "1 साल 2 दिन 3 घंटा और 4 सेकंड"
]
, examples (DurationData 30 Month)
[ "ढाई साल"
]
, examples (DurationData 90 Minute)
[ "डेढ़ घंटा"
]
]

View File

@ -153,6 +153,7 @@ ruleSaadeDuration = Rule
_) -> Token Duration <$> nPlusOneHalf grain (floor v)
_ -> Nothing
}
ruleCompositeDuration :: Rule
ruleCompositeDuration = Rule
{ name = "composite <duration>"
@ -187,6 +188,25 @@ ruleCompositeDurationCommasAnd = Rule
_ -> Nothing
}
ruleNAndHalfDuration :: Rule
ruleNAndHalfDuration = Rule
{ name = "डेढ़|ढाई <duration>"
, pattern =
[ regex "(डेढ़|ढाई)"
, dimension TimeGrain
]
, prod = \case
(Token RegexMatch (GroupMatch (match:_)):
Token TimeGrain grain:
_) -> do
h <- case Text.toLower match of
"डेढ़" -> Just 1
"ढाई" -> Just 2
_ -> Nothing
Token Duration <$> nPlusOneHalf grain h
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleDurationPandrahMinat
@ -200,4 +220,5 @@ rules =
, ruleSaadeDuration
, ruleCompositeDuration
, ruleCompositeDurationCommasAnd
, ruleNAndHalfDuration
]