Time/EN_US: Modify this|last|next <cycle>

Summary: We weren't capturing cases like "the first Saturday of the month", due to "the month" not being properly parsed.

Reviewed By: haoxuany

Differential Revision: D18193355

fbshipit-source-id: 2c4e83a3f22b0fe306ce7662ade85434a0016784
This commit is contained in:
Franz-Julius Chen 2019-10-29 11:11:41 -07:00 committed by Facebook Github Bot
parent 8dc4ca9289
commit ba092881c5
16 changed files with 7326 additions and 6939 deletions

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

View File

@ -744,6 +744,12 @@ allExamples = concat
, examples (datetime (2012, 11, 12, 0, 0, 0) Day)
[ "three months ago"
]
, examples (datetime (2013, 02, 04, 0, 0, 0) Day)
[ "the first Monday of this month"
, "the first Monday of the month"
, "the first Monday in this month"
, "first Monday in the month"
]
, examples (datetime (2011, 2, 1, 0, 0, 0) Month)
[ "two years ago"
]

View File

@ -1961,7 +1961,7 @@ ruleCycleThisLastNext :: Rule
ruleCycleThisLastNext = Rule
{ name = "this|last|next <cycle>"
, pattern =
[ regex "(this|current|coming|next|the following|last|past|previous)"
[ regex "(this|current|coming|next|(the( following)?)|last|past|previous)"
, dimension TimeGrain
]
, prod = \tokens -> case tokens of
@ -1975,6 +1975,7 @@ ruleCycleThisLastNext = Rule
"previous" -> tt . cycleNth grain $ - 1
"next" -> tt $ cycleNth grain 1
"the following" -> tt $ cycleNth grain 1
"the" -> tt $ cycleNth grain 0
_ -> Nothing
_ -> Nothing
}

View File

@ -25,7 +25,7 @@ module Duckling.Time.Helpers
, predNth, predNthAfter, predNthClosest, season, second, timeOfDayAMPM
, weekday, weekend, workweek, withDirection, year, yearMonthDay, tt, durationIntervalAgo
, inDurationInterval, intersectWithReplacement, yearADBC, yearMonth
, predEveryNDaysFrom
, predEveryNDaysFrom, timeCycle
-- Other
, getIntValue, timeComputed, toTimeObjectM
-- Rule constructors