mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
add: support for composite duration in hindi (#425)
Summary: Pull Request resolved: https://github.com/facebook/duckling/pull/425 Reviewed By: girifb Differential Revision: D26263097 Pulled By: chessai fbshipit-source-id: 29605023746a30dc286ffb246eb30fdc4067cbd8
This commit is contained in:
parent
9a6aeb9b51
commit
c2b280c9ef
@ -56,6 +56,9 @@ allExamples = concat
|
||||
]
|
||||
, examples (DurationData 27 Month)
|
||||
[ "सवा 2 साल"
|
||||
, "2 साल और 3 महीना"
|
||||
, "2 साल, 3 महीना"
|
||||
, "2 साल 3 महीना"
|
||||
]
|
||||
, examples (DurationData 135 Minute)
|
||||
[ "सवा 2 घंटा"
|
||||
@ -66,4 +69,8 @@ allExamples = concat
|
||||
, examples (DurationData 210 Minute)
|
||||
[ "साड़े 3 घंटा"
|
||||
]
|
||||
, examples (DurationData 31719604 Second)
|
||||
[ "1 साल, 2 दिन, 3 घंटा और 4 सेकंड"
|
||||
, "1 साल 2 दिन 3 घंटा और 4 सेकंड"
|
||||
]
|
||||
]
|
||||
|
@ -22,9 +22,11 @@ import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers
|
||||
import Duckling.Duration.Types (DurationData(..))
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Duration.Types as TDuration
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
|
||||
@ -151,6 +153,39 @@ ruleSaadeDuration = Rule
|
||||
_) -> Token Duration <$> nPlusOneHalf grain (floor v)
|
||||
_ -> Nothing
|
||||
}
|
||||
ruleCompositeDuration :: Rule
|
||||
ruleCompositeDuration = Rule
|
||||
{ name = "composite <duration>"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, dimension TimeGrain
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \case
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:
|
||||
Token TimeGrain g:
|
||||
Token Duration dd@DurationData{TDuration.grain = dg}:
|
||||
_) | g > dg -> Just $ Token Duration $ duration g (floor v) <> dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleCompositeDurationCommasAnd :: Rule
|
||||
ruleCompositeDurationCommasAnd = Rule
|
||||
{ name = "composite <duration> (with ,/और)"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, dimension TimeGrain
|
||||
, regex ",|और"
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \case
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:
|
||||
Token TimeGrain g:
|
||||
_:
|
||||
Token Duration dd@DurationData{TDuration.grain = dg}:
|
||||
_) | g > dg -> Just $ Token Duration $ duration g (floor v) <> dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
rules :: [Rule]
|
||||
rules =
|
||||
@ -163,4 +198,6 @@ rules =
|
||||
, rulePauneDuration
|
||||
, ruleSavaDuration
|
||||
, ruleSaadeDuration
|
||||
, ruleCompositeDuration
|
||||
, ruleCompositeDurationCommasAnd
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user