mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
Numeral/EN: Fixes ambiguous parses when both ruleNegative and ruleMultiply apply (#406)
Summary: I noticed two ambiguous parses would occur when both ruleNegative and ruleMultiply would apply. For example: "minus three million two hundred thousand" ``` *Duckling.Debug> debug (makeLocale EN Nothing) "minus three million two hundred thousand" [This Numeral] compose by multiplication (minus three million two hundred thousand) -- negative numbers (minus three million two hundred) -- -- regex (minus) -- -- intersect 2 numbers (three million two hundred) -- -- -- compose by multiplication (three million) -- -- -- -- integer (0..19) (three) -- -- -- -- -- regex (three) -- -- -- -- powers of tens (million) -- -- -- -- -- regex (million) -- -- -- compose by multiplication (two hundred) -- -- -- -- integer (0..19) (two) -- -- -- -- -- regex (two) -- -- -- -- powers of tens (hundred) -- -- -- -- -- regex (hundred) -- powers of tens (thousand) -- -- regex (thousand) negative numbers (minus three million two hundred thousand) -- regex (minus) -- intersect 2 numbers (three million two hundred thousand) -- -- compose by multiplication (three million) -- -- -- integer (0..19) (three) -- -- -- -- regex (three) -- -- -- powers of tens (million) -- -- -- -- regex (million) -- -- compose by multiplication (two hundred thousand) -- -- -- compose by multiplication (two hundred) -- -- -- -- integer (0..19) (two) -- -- -- -- -- regex (two) -- -- -- -- powers of tens (hundred) -- -- -- -- -- regex (hundred) -- -- -- powers of tens (thousand) -- -- -- -- regex (thousand) ``` This PR fixes this ambiguity and Duckling will only return the second (correct) parse. Pull Request resolved: https://github.com/facebook/duckling/pull/406 Test Plan: regen'd classifiers (no-op) :test Duckling.Tests Imported from GitHub, without a `Test Plan:` line. Reviewed By: chinmay87, girifb Differential Revision: D20303354 Pulled By: patapizza fbshipit-source-id: 280b0e33b7c944f9d87a7c23afda2f6a843e28a4
This commit is contained in:
parent
e3114c08f5
commit
04d0db6efa
@ -141,6 +141,11 @@ allExamples = concat
|
||||
, "-1200K"
|
||||
, "-.0012G"
|
||||
]
|
||||
, examples (NumeralValue (-3200000))
|
||||
[ "-3,200,000"
|
||||
, "-3200000"
|
||||
, "minus three million two hundred thousand"
|
||||
]
|
||||
, examples (NumeralValue 122)
|
||||
[ "one twenty two"
|
||||
, "ONE TwentY tWO"
|
||||
|
@ -314,7 +314,7 @@ ruleMultiply :: Rule
|
||||
ruleMultiply = Rule
|
||||
{ name = "compose by multiplication"
|
||||
, pattern =
|
||||
[ dimension Numeral
|
||||
[ Predicate isPositive
|
||||
, Predicate isMultipliable
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
|
@ -847,7 +847,6 @@ library
|
||||
test-suite duckling-test
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: TestMain.hs
|
||||
ghc-options: -main-is TestMain
|
||||
hs-source-dirs: tests
|
||||
build-depends: duckling
|
||||
, base
|
||||
|
Loading…
Reference in New Issue
Block a user