Time.FR > add rule for years in twentieth centry (#357)

Summary:
In Time.FR, add support for birthdates like "15 juin 72"

Pull Request resolved: https://github.com/facebook/duckling/pull/357

Reviewed By: patapizza

Differential Revision: D26193322

Pulled By: chessai

fbshipit-source-id: d22efea81aad31af8baa2f7f9afdaf1a75c0dc10
This commit is contained in:
Damien Gallet 2021-06-04 12:57:55 -07:00 committed by Facebook GitHub Bot
parent 8cb77a43c7
commit 28e38679a7
3 changed files with 39 additions and 16 deletions

View File

@ -153,13 +153,12 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}), likelihoods = HashMap.fromList [], n = 0}}),
("integer (numeric)", ("integer (numeric)",
Classifier{okData = Classifier{okData =
ClassData{prior = -0.4740936144972606, ClassData{prior = -0.479182684004732, unseen = -5.5053315359323625,
unseen = -5.5053315359323625,
likelihoods = HashMap.fromList [("", 0.0)], n = 244}, likelihoods = HashMap.fromList [("", 0.0)], n = 244},
koData = koData =
ClassData{prior = -0.9740495660263475, ClassData{prior = -0.9657156152016781,
unseen = -5.0106352940962555, unseen = -5.0238805208462765,
likelihoods = HashMap.fromList [("", 0.0)], n = 148}}), likelihoods = HashMap.fromList [("", 0.0)], n = 150}}),
("the nth <day-of-week> of <month-or-greater>", ("the nth <day-of-week> of <month-or-greater>",
Classifier{okData = Classifier{okData =
ClassData{prior = 0.0, unseen = -1.6094379124341003, ClassData{prior = 0.0, unseen = -1.6094379124341003,
@ -1850,11 +1849,13 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}), likelihoods = HashMap.fromList [], n = 0}}),
("Octobre", ("Octobre",
Classifier{okData = Classifier{okData =
ClassData{prior = 0.0, unseen = -2.4849066497880004, ClassData{prior = -9.53101798043249e-2,
unseen = -2.4849066497880004,
likelihoods = HashMap.fromList [("", 0.0)], n = 10}, likelihoods = HashMap.fromList [("", 0.0)], n = 10},
koData = koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453, ClassData{prior = -2.3978952727983707,
likelihoods = HashMap.fromList [], n = 0}}), unseen = -1.0986122886681098,
likelihoods = HashMap.fromList [("", 0.0)], n = 1}}),
("au d\233jeuner", ("au d\233jeuner",
Classifier{okData = Classifier{okData =
ClassData{prior = -0.40546510810816444, ClassData{prior = -0.40546510810816444,
@ -2206,7 +2207,7 @@ classifiers
n = 42}}), n = 42}}),
("<day-of-month> <named-month>", ("<day-of-month> <named-month>",
Classifier{okData = Classifier{okData =
ClassData{prior = -0.2876820724517809, unseen = -4.718498871295094, ClassData{prior = -0.3022808718729337, unseen = -4.718498871295094,
likelihoods = likelihoods =
HashMap.fromList HashMap.fromList
[("integer (numeric)Juin", -3.3232358401924436), [("integer (numeric)Juin", -3.3232358401924436),
@ -2219,15 +2220,16 @@ classifiers
("integer (numeric)Mars", -1.936941479072553)], ("integer (numeric)Mars", -1.936941479072553)],
n = 51}, n = 51},
koData = koData =
ClassData{prior = -1.3862943611198906, unseen = -3.784189633918261, ClassData{prior = -1.3437347467010947, unseen = -3.828641396489095,
likelihoods = likelihoods =
HashMap.fromList HashMap.fromList
[("number (0..16)Juillet", -2.374905754573672), [("number (0..16)Juillet", -2.4203681286504293),
("integer (numeric)Juillet", -1.1962507582320256), ("integer (numeric)Juillet", -1.241713132308783),
("month", -0.8708283577973976), ("integer (numeric)Octobre", -3.1135153092103742),
("integer (numeric)Septembre", -3.068052935133617), ("month", -0.8622235106038793),
("integer (numeric)Mars", -3.068052935133617)], ("integer (numeric)Septembre", -3.1135153092103742),
n = 17}}), ("integer (numeric)Mars", -3.1135153092103742)],
n = 18}}),
("du dd/nth au dd/nth month (interval)", ("du dd/nth au dd/nth month (interval)",
Classifier{okData = Classifier{okData =
ClassData{prior = 0.0, unseen = -2.3978952727983707, ClassData{prior = 0.0, unseen = -2.3978952727983707,

View File

@ -32,6 +32,7 @@ negativeCorpus = (testContext {locale = makeLocale FR Nothing}, testOptions, exa
[ "Ana a un court de tennis" [ "Ana a un court de tennis"
, "deux trois" , "deux trois"
, "deux trois minutes" , "deux trois minutes"
, "74"
] ]
allExamples :: [Example] allExamples :: [Example]
@ -215,6 +216,7 @@ allExamples = concat
, examples (datetime (1974, 10, 31, 0, 0, 0) Day) , examples (datetime (1974, 10, 31, 0, 0, 0) Day)
[ "31/10/1974" [ "31/10/1974"
, "31/10/74" , "31/10/74"
, "31 octobre 74"
] ]
, examples (datetime (2013, 2, 18, 0, 0, 0) Day) , examples (datetime (2013, 2, 18, 0, 0, 0) Day)
[ "lundi prochain" [ "lundi prochain"

View File

@ -1914,6 +1914,24 @@ rulePlusTardPartofday = Rule
_ -> Nothing _ -> Nothing
} }
ruleDDMonthYY :: Rule
ruleDDMonthYY = Rule
{ name = "DD month YY"
, pattern =
[ Predicate $ isIntegerBetween 0 31
, Predicate isAMonth
, Predicate $ isIntegerBetween 32 99
]
, prod = \case
(dayd:Token Time monthd:yeard:_) -> do
d <- getIntValue dayd
y <- getIntValue yeard
dayMonth <- intersect monthd (dayOfMonth d)
ymd <- intersect dayMonth (year y)
tt ymd
_ -> Nothing
}
ruleTimezone :: Rule ruleTimezone :: Rule
ruleTimezone = Rule ruleTimezone = Rule
{ name = "<time> timezone" { name = "<time> timezone"
@ -2103,6 +2121,7 @@ rules =
, rulePlusTardPartofday , rulePlusTardPartofday
, ruleNthTimeOfTime , ruleNthTimeOfTime
, ruleTheNthTimeOfTime , ruleTheNthTimeOfTime
, ruleDDMonthYY
] ]
++ ruleMonths ++ ruleMonths
++ ruleDaysOfWeek ++ ruleDaysOfWeek