mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
added new rule to parse phrase in the pattern "xxx minutes to <hour-of-day>" (#500)
Summary: Current: 20 minutes to 2pm tomorrow -> 20 minutes (dimension: Time) Expected: 20 minutes to 2pm tomorrow -> 1:45pm of next day (dimension: Time) Pull Request resolved: https://github.com/facebook/duckling/pull/500 Reviewed By: chinmay87 Differential Revision: D22200580 Pulled By: yuanbing fbshipit-source-id: e47e5b5aaf4e3644c7032096caa75672a8543087
This commit is contained in:
parent
e570acd2f9
commit
1ad3a8514e
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1895,4 +1895,7 @@ allExamples = concat
|
||||
, "2 upcoming years"
|
||||
, "2 upcoming year"
|
||||
]
|
||||
, examples (datetime (2013, 2, 13, 13, 40, 0) Minute)
|
||||
[ "20 minutes to 2pm tomorrow"
|
||||
]
|
||||
]
|
||||
|
@ -2515,6 +2515,22 @@ ruleUpcomingGrainAlt = Rule
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleMinutesToHOD :: Rule
|
||||
ruleMinutesToHOD = Rule
|
||||
{ name = "<integer> minutes to|till|before <hour-of-day>"
|
||||
, pattern =
|
||||
[ Predicate $ isIntegerBetween 1 59
|
||||
, Predicate $ isGrain TG.Minute
|
||||
, regex "to|till|before|of"
|
||||
, Predicate isAnHourOfDay
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(token:_:_:Token Time td:_) -> do
|
||||
n <- getIntValue token
|
||||
Token Time <$> minutesBefore n td
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
rules :: [Rule]
|
||||
rules =
|
||||
[ ruleIntersect
|
||||
@ -2651,6 +2667,7 @@ rules =
|
||||
, ruleMidDay
|
||||
, ruleUpcomingGrain
|
||||
, ruleUpcomingGrainAlt
|
||||
, ruleMinutesToHOD
|
||||
]
|
||||
++ ruleInstants
|
||||
++ ruleDaysOfWeek
|
||||
|
Loading…
Reference in New Issue
Block a user