Fixed the rule for parsing "coming <time cycle>"

Summary: Currently the term "coming" is being treated the same way as "this" or "current". The expected treatment should be the same as the term "next".

Reviewed By: chinmay87

Differential Revision: D22435156

fbshipit-source-id: b0b20d8a38014267fb7d037b685ce126f602bda7
This commit is contained in:
Bing Yuan 2020-07-17 13:13:04 -07:00 committed by Facebook GitHub Bot
parent 5af4d617ba
commit a88e0669f7
2 changed files with 26 additions and 17 deletions

View File

@ -317,7 +317,9 @@ allExamples = concat
, examples (datetime (2013, 2, 11, 0, 0, 0) Week)
[ "this week"
, "current week"
, "coming week"
]
, examples (datetime (2013, 2, 18, 0, 0, 0) Week)
[ "coming week"
]
, examples (datetime (2013, 2, 4, 0, 0, 0) Week)
[ "last week"
@ -1446,9 +1448,11 @@ allExamples = concat
, examples (datetimeInterval ((2013, 2, 11, 0, 0, 0), (2013, 2, 14, 0, 0, 0)) Day)
[ "beginning of this week"
, "beginning of current week"
, "beginning of coming week"
, "at the beginning of this week"
, "at the beginning of current week"
]
, examples (datetimeInterval ((2013, 2, 18, 0, 0, 0), (2013, 2, 21, 0, 0, 0)) Day)
[ "beginning of coming week"
, "at the beginning of coming week"
]
, examples (datetimeInterval ((2013, 2, 4, 0, 0, 0), (2013, 2, 7, 0, 0, 0)) Day)
@ -1470,9 +1474,11 @@ allExamples = concat
, examples (datetimeInterval ((2013, 2, 15, 0, 0, 0), (2013, 2, 18, 0, 0, 0)) Day)
[ "end of this week"
, "end of current week"
, "end of coming week"
, "at the end of this week"
, "at the end of current week"
]
, examples (datetimeInterval ((2013, 2, 22, 0, 0, 0), (2013, 2, 25, 0, 0, 0)) Day)
[ "end of coming week"
, "at the end of coming week"
]
, examples (datetimeInterval ((2013, 2, 8, 0, 0, 0), (2013, 2, 11, 0, 0, 0)) Day)

View File

@ -2060,20 +2060,23 @@ ruleCycleThisLastNext = Rule
[ regex "(this|current|coming|next|(the( following)?)|last|past|previous|upcoming)"
, dimension TimeGrain
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (match:_)):Token TimeGrain grain:_) ->
case Text.toLower match of
"this" -> tt $ cycleNth grain 0
"coming" -> tt $ cycleNth grain 0
"current" -> tt $ cycleNth grain 0
"last" -> tt . cycleNth grain $ - 1
"past" -> tt . cycleNth grain $ - 1
"previous" -> tt . cycleNth grain $ - 1
"next" -> tt $ cycleNth grain 1
"upcoming" -> tt $ cycleNth grain 1
"the following" -> tt $ cycleNth grain 1
"the" -> tt $ cycleNth grain 0
_ -> Nothing
, prod = \case
(
Token RegexMatch (GroupMatch (match:_)):
Token TimeGrain grain:
_) ->
case Text.toLower match of
"this" -> tt $ cycleNth grain 0
"coming" -> tt $ cycleNth grain 1
"current" -> tt $ cycleNth grain 0
"last" -> tt $ cycleNth grain $ - 1
"past" -> tt $ cycleNth grain $ - 1
"previous" -> tt $ cycleNth grain $ - 1
"next" -> tt $ cycleNth grain 1
"upcoming" -> tt $ cycleNth grain 1
"the following" -> tt $ cycleNth grain 1
"the" -> tt $ cycleNth grain 0
_ -> Nothing
_ -> Nothing
}