Added new rule to support ES phrase for "next week". (#493)

Summary:
Please note that the major diff with the
existing rule for next week is that the new
phrase doesn't have the leading "la" or anything with
similar meaning.
Pull Request resolved: https://github.com/facebook/duckling/pull/493

Test Plan: Imported from GitHub, without a Test Plan: line.

Reviewed By: patapizza

Differential Revision: D21981169

Pulled By: yuanbing

fbshipit-source-id: 7478d1262c3a4599d359b485b28a547ad5f44b76
This commit is contained in:
Bing Yuan 2020-06-24 10:58:37 -07:00 committed by Facebook GitHub Bot
parent 8cf3fdb581
commit 195a9d7aa1
10 changed files with 165 additions and 16 deletions

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -204,8 +204,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("semana (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
ClassData{prior = 0.0, unseen = -2.890371757896165,
likelihoods = HashMap.fromList [("", 0.0)], n = 16},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1140,6 +1140,23 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("next week",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
unseen = -1.9459101490553135,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098,
unseen = -1.6094379124341003,
likelihoods =
HashMap.fromList
[("week", -0.6931471805599453),
("semana (grain)", -0.6931471805599453)],
n = 1}}),
("<datetime> - <datetime> (interval)",
Classifier{okData =
ClassData{prior = -0.916290731874155, unseen = -2.5649493574615367,

View File

@ -174,6 +174,7 @@ allExamples = concat
, examples (datetime (2013, 2, 18, 0, 0, 0) Week)
[ "la semana que viene"
, "la proxima semana"
, "semana que viene"
]
, examples (datetime (2013, 1, 1, 0, 0, 0) Month)
[ "el pasado mes"

View File

@ -1266,6 +1266,17 @@ ruleTimezone = Rule
_ -> Nothing
}
ruleNextWeek :: Rule
ruleNextWeek = Rule
{
name = "next week"
, pattern =
[ Predicate $ isGrain TG.Week
, regex "que viene"
]
, prod = \_ -> tt $ cycleNth TG.Week 1
}
rulePeriodicHolidays :: [Rule]
rulePeriodicHolidays = mkRuleHolidays
-- Fixed dates, year over year
@ -1576,6 +1587,7 @@ rules =
, ruleHourofdayMinusIntegerAsRelativeMinutes2
, ruleTimezone
, ruleElDayofmonthNonOrdinalWithDia
, ruleNextWeek
]
++ ruleDaysOfWeek
++ ruleMonths