Time/EN: All week, Rest of the week

Summary:
Task also says to add "this week", but this is already covered
by the "this <time>" rule.

Reviewed By: chinmay87

Differential Revision: D9018849

fbshipit-source-id: 210daf87ad4221cf734f260932f7c95c8a3e417a
This commit is contained in:
Ben Powell 2018-08-01 09:23:42 -07:00 committed by Facebook Github Bot
parent 42ab956c3f
commit 984769244f
15 changed files with 114 additions and 1 deletions

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -52,6 +52,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -45,6 +45,13 @@ classifiers
[("hour", -0.7537718023763802),
("integer (numeric)time-of-day (latent)", -0.7537718023763802)],
n = 7}}),
("week",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("<time> timezone",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.6888794541139363,

View File

@ -1170,6 +1170,12 @@ allExamples = concat
, "last week-end in October"
, "last week end of October"
]
, examples (datetimeInterval ((2013, 2, 11, 0, 0, 0), (2013, 2, 17, 0, 0, 0)) Day)
[ "all week"
]
, examples (datetimeInterval ((2013, 2, 12, 0, 0, 0), (2013, 2, 17, 0, 0, 0)) Day)
[ "rest of the week"
]
, examples (datetimeInterval ((2013, 7, 26, 18, 0, 0), (2013, 7, 29, 0, 0, 0)) Hour)
[ "last wkend of July"
]

View File

@ -30,7 +30,7 @@ import Duckling.Ordinal.Types (OrdinalData (..))
import Duckling.Regex.Types
import Duckling.Time.Computed
import Duckling.Time.Helpers
import Duckling.Time.Types (TimeData (..))
import Duckling.Time.Types (TimeData (..), TimeIntervalType (..))
import Duckling.Types
import qualified Duckling.Duration.Types as TDuration
import qualified Duckling.Numeral.Types as TNumeral
@ -967,6 +967,21 @@ ruleWeekend = Rule
, prod = \_ -> tt $ mkOkForThisNext weekend
}
ruleWeek :: Rule
ruleWeek = Rule
{ name = "week"
, pattern = [regex "(all|rest of the) week"]
, prod = \case
(Token RegexMatch (GroupMatch (match:_)):_) ->
let end = cycleNthAfter True TG.Day (-2) (cycleNth TG.Week 1)
period = case Text.toLower match of
"all" -> interval Closed (cycleNth TG.Week 0) end
"rest of the" -> interval Open (cycleNth TG.Day 0) end
_ -> Nothing
in Token Time <$> period
_ -> Nothing
}
ruleSeason :: Rule
ruleSeason = Rule
{ name = "last|this|next <season>"
@ -2328,6 +2343,7 @@ rules =
, ruleTimePOD
, rulePODofTime
, ruleWeekend
, ruleWeek
, ruleTODPrecision
, rulePrecisionTOD
, ruleIntervalFromMonthDDDD