mirror of
https://github.com/facebook/duckling.git
synced 2024-11-29 01:03:44 +03:00
Add MM/YYYY and MM/YY
Summary: MM/YY is a common format for dates in India,UK and other parts of the world.Have added testcases in `Time/EN/corpus.hs` ,however it conflicts with one of the original(2/15 is output now as Feb. 2015 and not the 15th of February). Closes https://github.com/facebookincubator/duckling/pull/59 Reviewed By: niteria Differential Revision: D5455881 Pulled By: patapizza fbshipit-source-id: 23b73a5
This commit is contained in:
parent
a55629d541
commit
ce0e9e4f50
@ -59,12 +59,12 @@ classifiers
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("integer (numeric)",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.8594418676420025,
|
||||
ClassData{prior = -0.8649974374866046,
|
||||
unseen = -5.0369526024136295,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 152},
|
||||
koData =
|
||||
ClassData{prior = -0.5506035952229099, unseen = -5.342334251964811,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 207}}),
|
||||
ClassData{prior = -0.5465437063680699, unseen = -5.351858133476067,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 209}}),
|
||||
("<duration> hence|ago",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -3.784189633918261,
|
||||
@ -137,6 +137,15 @@ classifiers
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("mm/yyyy",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.6931471805599453,
|
||||
unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 1},
|
||||
koData =
|
||||
ClassData{prior = -0.6931471805599453,
|
||||
unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 1}}),
|
||||
("integer after|past <hour-of-day>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -2.3025850929940455,
|
||||
@ -1245,8 +1254,8 @@ classifiers
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0},
|
||||
koData =
|
||||
ClassData{prior = 0.0, unseen = -2.890371757896165,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 16}}),
|
||||
ClassData{prior = 0.0, unseen = -2.9444389791664407,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 17}}),
|
||||
("Sunday",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -2.3025850929940455,
|
||||
@ -1300,15 +1309,15 @@ classifiers
|
||||
n = 40}}),
|
||||
("year",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.21622310846963594,
|
||||
ClassData{prior = -0.24362208265775043,
|
||||
unseen = -3.4339872044851463,
|
||||
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
|
||||
n = 29},
|
||||
koData =
|
||||
ClassData{prior = -1.6376087894007967,
|
||||
unseen = -2.1972245773362196,
|
||||
ClassData{prior = -1.5314763709643884,
|
||||
unseen = -2.3025850929940455,
|
||||
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
|
||||
n = 7}}),
|
||||
n = 8}}),
|
||||
("last <day-of-week> of <time>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -2.3978952727983707,
|
||||
|
@ -56,6 +56,9 @@ allExamples = concat
|
||||
[ "today"
|
||||
, "at this time"
|
||||
]
|
||||
, examples (datetime (2013, 2, 1, 0, 0, 0) Day)
|
||||
[ "2/2013"
|
||||
]
|
||||
, examples (datetime (2013, 2, 11, 0, 0, 0) Day)
|
||||
["yesterday"]
|
||||
, examples (datetime (2013, 2, 13, 0, 0, 0) Day)
|
||||
|
@ -683,6 +683,20 @@ ruleHalfHOD = Rule
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleMMYYYY :: Rule
|
||||
ruleMMYYYY = Rule
|
||||
{ name = "mm/yyyy"
|
||||
, pattern =
|
||||
[ regex "(0?[1-9]|1[0-2])[/-](\\d{4})"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (mm:yy:_)):_) -> do
|
||||
y <- parseInt yy
|
||||
m <- parseInt mm
|
||||
tt $ yearMonthDay y m 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleMMDDYYYY :: Rule
|
||||
ruleMMDDYYYY = Rule
|
||||
{ name = "mm/dd/yyyy"
|
||||
@ -1608,6 +1622,7 @@ rules =
|
||||
, ruleMMDDYYYY
|
||||
, ruleYYYYMMDD
|
||||
, ruleMMDD
|
||||
, ruleMMYYYY
|
||||
, ruleNoonMidnightEOD
|
||||
, rulePartOfDays
|
||||
, ruleEarlyMorning
|
||||
|
Loading…
Reference in New Issue
Block a user