mirror of
https://github.com/facebook/duckling.git
synced 2024-12-01 08:19:36 +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}}),
|
likelihoods = HashMap.fromList [], n = 0}}),
|
||||||
("integer (numeric)",
|
("integer (numeric)",
|
||||||
Classifier{okData =
|
Classifier{okData =
|
||||||
ClassData{prior = -0.8594418676420025,
|
ClassData{prior = -0.8649974374866046,
|
||||||
unseen = -5.0369526024136295,
|
unseen = -5.0369526024136295,
|
||||||
likelihoods = HashMap.fromList [("", 0.0)], n = 152},
|
likelihoods = HashMap.fromList [("", 0.0)], n = 152},
|
||||||
koData =
|
koData =
|
||||||
ClassData{prior = -0.5506035952229099, unseen = -5.342334251964811,
|
ClassData{prior = -0.5465437063680699, unseen = -5.351858133476067,
|
||||||
likelihoods = HashMap.fromList [("", 0.0)], n = 207}}),
|
likelihoods = HashMap.fromList [("", 0.0)], n = 209}}),
|
||||||
("<duration> hence|ago",
|
("<duration> hence|ago",
|
||||||
Classifier{okData =
|
Classifier{okData =
|
||||||
ClassData{prior = 0.0, unseen = -3.784189633918261,
|
ClassData{prior = 0.0, unseen = -3.784189633918261,
|
||||||
@ -137,6 +137,15 @@ classifiers
|
|||||||
koData =
|
koData =
|
||||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||||
likelihoods = HashMap.fromList [], n = 0}}),
|
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>",
|
("integer after|past <hour-of-day>",
|
||||||
Classifier{okData =
|
Classifier{okData =
|
||||||
ClassData{prior = 0.0, unseen = -2.3025850929940455,
|
ClassData{prior = 0.0, unseen = -2.3025850929940455,
|
||||||
@ -1245,8 +1254,8 @@ classifiers
|
|||||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||||
likelihoods = HashMap.fromList [], n = 0},
|
likelihoods = HashMap.fromList [], n = 0},
|
||||||
koData =
|
koData =
|
||||||
ClassData{prior = 0.0, unseen = -2.890371757896165,
|
ClassData{prior = 0.0, unseen = -2.9444389791664407,
|
||||||
likelihoods = HashMap.fromList [("", 0.0)], n = 16}}),
|
likelihoods = HashMap.fromList [("", 0.0)], n = 17}}),
|
||||||
("Sunday",
|
("Sunday",
|
||||||
Classifier{okData =
|
Classifier{okData =
|
||||||
ClassData{prior = 0.0, unseen = -2.3025850929940455,
|
ClassData{prior = 0.0, unseen = -2.3025850929940455,
|
||||||
@ -1300,15 +1309,15 @@ classifiers
|
|||||||
n = 40}}),
|
n = 40}}),
|
||||||
("year",
|
("year",
|
||||||
Classifier{okData =
|
Classifier{okData =
|
||||||
ClassData{prior = -0.21622310846963594,
|
ClassData{prior = -0.24362208265775043,
|
||||||
unseen = -3.4339872044851463,
|
unseen = -3.4339872044851463,
|
||||||
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
|
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
|
||||||
n = 29},
|
n = 29},
|
||||||
koData =
|
koData =
|
||||||
ClassData{prior = -1.6376087894007967,
|
ClassData{prior = -1.5314763709643884,
|
||||||
unseen = -2.1972245773362196,
|
unseen = -2.3025850929940455,
|
||||||
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
|
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
|
||||||
n = 7}}),
|
n = 8}}),
|
||||||
("last <day-of-week> of <time>",
|
("last <day-of-week> of <time>",
|
||||||
Classifier{okData =
|
Classifier{okData =
|
||||||
ClassData{prior = 0.0, unseen = -2.3978952727983707,
|
ClassData{prior = 0.0, unseen = -2.3978952727983707,
|
||||||
|
@ -56,6 +56,9 @@ allExamples = concat
|
|||||||
[ "today"
|
[ "today"
|
||||||
, "at this time"
|
, "at this time"
|
||||||
]
|
]
|
||||||
|
, examples (datetime (2013, 2, 1, 0, 0, 0) Day)
|
||||||
|
[ "2/2013"
|
||||||
|
]
|
||||||
, examples (datetime (2013, 2, 11, 0, 0, 0) Day)
|
, examples (datetime (2013, 2, 11, 0, 0, 0) Day)
|
||||||
["yesterday"]
|
["yesterday"]
|
||||||
, examples (datetime (2013, 2, 13, 0, 0, 0) Day)
|
, examples (datetime (2013, 2, 13, 0, 0, 0) Day)
|
||||||
|
@ -683,6 +683,20 @@ ruleHalfHOD = Rule
|
|||||||
_ -> Nothing
|
_ -> 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
|
||||||
ruleMMDDYYYY = Rule
|
ruleMMDDYYYY = Rule
|
||||||
{ name = "mm/dd/yyyy"
|
{ name = "mm/dd/yyyy"
|
||||||
@ -1608,6 +1622,7 @@ rules =
|
|||||||
, ruleMMDDYYYY
|
, ruleMMDDYYYY
|
||||||
, ruleYYYYMMDD
|
, ruleYYYYMMDD
|
||||||
, ruleMMDD
|
, ruleMMDD
|
||||||
|
, ruleMMYYYY
|
||||||
, ruleNoonMidnightEOD
|
, ruleNoonMidnightEOD
|
||||||
, rulePartOfDays
|
, rulePartOfDays
|
||||||
, ruleEarlyMorning
|
, ruleEarlyMorning
|
||||||
|
Loading…
Reference in New Issue
Block a user