Summary: Closes https://github.com/facebookincubator/duckling/pull/52

Reviewed By: blandinw

Differential Revision: D5296543

Pulled By: patapizza

fbshipit-source-id: 041844a
This commit is contained in:
chao pan 2017-06-23 06:50:04 -07:00 committed by Facebook Github Bot
parent 291bd28873
commit efc1f36494
3 changed files with 331 additions and 274 deletions

View File

@ -59,10 +59,11 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("integer (numeric)",
Classifier{okData =
ClassData{prior = -0.8576508940371061, unseen = -5.030437921392435,
likelihoods = HashMap.fromList [("", 0.0)], n = 151},
ClassData{prior = -0.8538552609333627,
unseen = -5.0369526024136295,
likelihoods = HashMap.fromList [("", 0.0)], n = 152},
koData =
ClassData{prior = -0.5519207517136222, unseen = -5.332718793265369,
ClassData{prior = -0.554725802641231, unseen = -5.332718793265369,
likelihoods = HashMap.fromList [("", 0.0)], n = 205}}),
("<duration> hence|ago",
Classifier{okData =
@ -353,8 +354,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("October",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.5649493574615367,
likelihoods = HashMap.fromList [("", 0.0)], n = 11},
ClassData{prior = 0.0, unseen = -2.833213344056216,
likelihoods = HashMap.fromList [("", 0.0)], n = 15},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -462,8 +463,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("July",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.5649493574615367,
likelihoods = HashMap.fromList [("", 0.0)], n = 11},
ClassData{prior = 0.0, unseen = -2.639057329615259,
likelihoods = HashMap.fromList [("", 0.0)], n = 12},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -504,210 +505,219 @@ classifiers
n = 3}}),
("intersect",
Classifier{okData =
ClassData{prior = -0.4470141110210368, unseen = -6.111467339502679,
ClassData{prior = -0.4563567154045537, unseen = -6.124683390894205,
likelihoods =
HashMap.fromList
[("<datetime> - <datetime> (interval)on <date>",
-4.499809670330265),
-4.513054897080286),
("<time-of-day> - <time-of-day> (interval)on <date>",
-4.499809670330265),
("hourday", -3.711352309965995),
("dayhour", -3.164808603597925),
("daymonth", -5.41610040220442),
("monthday", -5.0106352940962555),
("monthyear", -3.8066624897703196),
("Tuesdaythe <day-of-month> (ordinal)", -5.41610040220442),
("Christmasyear", -5.41610040220442),
-4.513054897080286),
("hourday", -3.724597536716016),
("dayhour", -3.1780538303479458),
("daymonth", -5.429345628954441),
("monthday", -5.0238805208462765),
("monthyear", -3.8199077165203406),
("Tuesdaythe <day-of-month> (ordinal)", -5.429345628954441),
("Christmasyear", -5.429345628954441),
("houryear", -5.429345628954441),
("this|next <day-of-week>hh(:mm) - <time-of-day> am|pm",
-5.41610040220442),
-5.429345628954441),
("<time-of-day> am|pmintersect by \",\", \"of\", \"from\", \"'s\"",
-4.722953221644475),
("<time-of-day> am|pmintersect", -4.163337433709052),
-4.736198448394496),
("<time-of-day> am|pmintersect", -4.176582660459073),
("intersect by \",\", \"of\", \"from\", \"'s\"year",
-5.41610040220442),
("Marchyear", -5.41610040220442),
-5.429345628954441),
("Marchyear", -5.429345628954441),
("<named-month>|<named-day> <day-of-month> (ordinal)year",
-5.0106352940962555),
("intersect<time-of-day> am|pm", -5.41610040220442),
("Thursdayhh(:mm) - <time-of-day> am|pm", -5.41610040220442),
("monthhour", -5.0106352940962555),
("last <day-of-week> of <time>year", -5.41610040220442),
("todayat <time-of-day>", -5.41610040220442),
("Thursday<time> timezone", -5.0106352940962555),
("this <time>hh(:mm) - <time-of-day> am|pm", -5.41610040220442),
("dayday", -3.4011973816621555),
("Thanksgiving Dayyear", -5.0106352940962555),
("<time> <part-of-day>at <time-of-day>", -5.41610040220442),
("Tuesdayin <named-month>", -5.41610040220442),
("mm/ddat <time-of-day>", -5.41610040220442),
("tonightat <time-of-day>", -5.41610040220442),
-5.0238805208462765),
("intersect<time-of-day> am|pm", -5.429345628954441),
("Thursdayhh(:mm) - <time-of-day> am|pm", -5.429345628954441),
("monthhour", -5.0238805208462765),
("last <day-of-week> of <time>year", -5.429345628954441),
("todayat <time-of-day>", -5.429345628954441),
("Thursday<time> timezone", -5.0238805208462765),
("this <time>hh(:mm) - <time-of-day> am|pm",
-5.429345628954441),
("dayday", -3.414442608412176),
("Thanksgiving Dayyear", -5.0238805208462765),
("<time> <part-of-day>at <time-of-day>", -5.429345628954441),
("Tuesdayin <named-month>", -5.429345628954441),
("mm/ddat <time-of-day>", -5.429345628954441),
("tonightat <time-of-day>", -5.429345628954441),
("<time-of-day> am|pmabsorption of , after named day",
-4.722953221644475),
("today<time-of-day> am|pm", -5.41610040220442),
("Februarythe <day-of-month> (ordinal)", -5.0106352940962555),
("at <time-of-day><time> <part-of-day>", -5.41610040220442),
("mm/dd<time-of-day> am|pm", -5.41610040220442),
("hourhour", -4.163337433709052),
("<time-of-day> am|pmon <date>", -3.4011973816621555),
("Wednesdaythis|last|next <cycle>", -5.41610040220442),
-4.736198448394496),
("today<time-of-day> am|pm", -5.429345628954441),
("Februarythe <day-of-month> (ordinal)", -5.0238805208462765),
("at <time-of-day><time> <part-of-day>", -5.429345628954441),
("mm/dd<time-of-day> am|pm", -5.429345628954441),
("hourhour", -4.176582660459073),
("<time-of-day> am|pmon <date>", -3.414442608412176),
("Wednesdaythis|last|next <cycle>", -5.429345628954441),
("intersect<named-month> <day-of-month> (non ordinal)",
-3.912023005428146),
("dayyear", -3.2188758248682006),
-3.925268232178167),
("dayyear", -3.2321210516182215),
("last weekend of <named-month>year", -5.429345628954441),
("<time-of-day> o'clockin|during the <part-of-day>",
-5.41610040220442),
("<time-of-day> am|pmtomorrow", -4.722953221644475),
("minutehour", -4.499809670330265),
("Mother's Dayyear", -5.41610040220442),
-5.429345628954441),
("<time-of-day> am|pmtomorrow", -4.736198448394496),
("minutehour", -4.513054897080286),
("Mother's Dayyear", -5.429345628954441),
("at <time-of-day>in|during the <part-of-day>",
-5.0106352940962555),
-5.0238805208462765),
("absorption of , after named day<named-month> <day-of-month> (non ordinal)",
-3.711352309965995),
("tomorrow<time-of-day> sharp|exactly", -5.41610040220442),
-3.724597536716016),
("tomorrow<time-of-day> sharp|exactly", -5.429345628954441),
("Thursdayfrom <datetime> - <datetime> (interval)",
-4.499809670330265),
-4.513054897080286),
("on <date><named-month> <day-of-month> (non ordinal)",
-5.0106352940962555),
-5.0238805208462765),
("Thursdayfrom <time-of-day> - <time-of-day> (interval)",
-4.499809670330265),
("Mondayin|during the <part-of-day>", -5.41610040220442),
-4.513054897080286),
("Mondayin|during the <part-of-day>", -5.429345628954441),
("tomorrowfrom <time-of-day> - <time-of-day> (interval)",
-5.0106352940962555),
("intersectin|during the <part-of-day>", -5.41610040220442),
-5.0238805208462765),
("intersectin|during the <part-of-day>", -5.429345628954441),
("<day-of-month> (ordinal or number) of <named-month>in|during the <part-of-day>",
-5.41610040220442),
-5.429345628954441),
("from <time-of-day> - <time-of-day> (interval)on <date>",
-4.722953221644475),
-4.736198448394496),
("intersect by \",\", \"of\", \"from\", \"'s\"<time-of-day> am|pm",
-4.499809670330265),
("at <time-of-day>intersect", -5.0106352940962555),
-4.513054897080286),
("at <time-of-day>intersect", -5.0238805208462765),
("<time-of-day> - <time-of-day> (interval)tomorrow",
-5.41610040220442),
-5.429345628954441),
("at <time-of-day>intersect by \",\", \"of\", \"from\", \"'s\"",
-5.41610040220442),
("dayminute", -3.1135153092103742),
-5.429345628954441),
("dayminute", -3.126760535960395),
("from <datetime> - <datetime> (interval)on <date>",
-5.0106352940962555),
-5.0238805208462765),
("<datetime> - <datetime> (interval)tomorrow",
-5.41610040220442),
-5.429345628954441),
("absorption of , after named dayintersect by \",\", \"of\", \"from\", \"'s\"",
-5.0106352940962555),
("<ordinal> <cycle> of <time>year", -5.41610040220442),
("minuteday", -2.0149030205422647),
("absorption of , after named dayintersect", -5.41610040220442),
("Octoberyear", -4.163337433709052),
-5.0238805208462765),
("<ordinal> <cycle> of <time>year", -5.429345628954441),
("minuteday", -2.0281482472922856),
("absorption of , after named dayintersect",
-5.429345628954441),
("Octoberyear", -4.176582660459073),
("the <day-of-month> (ordinal)in|during the <part-of-day>",
-5.41610040220442),
-5.429345628954441),
("at <time-of-day>absorption of , after named day",
-5.41610040220442),
-5.429345628954441),
("<day-of-month> (ordinal or number) <named-month>year",
-5.41610040220442),
("year<time-of-day> am|pm", -5.41610040220442),
("Septemberyear", -5.0106352940962555),
("at <time-of-day>on <date>", -4.31748811353631),
-5.429345628954441),
("year<time-of-day> am|pm", -5.429345628954441),
("Septemberyear", -5.0238805208462765),
("at <time-of-day>on <date>", -4.330733340286331),
("between <time-of-day> and <time-of-day> (interval)on <date>",
-4.722953221644475),
("Halloweenyear", -5.41610040220442),
("dayweek", -5.41610040220442),
("weekyear", -5.0106352940962555),
("hh:mmin|during the <part-of-day>", -4.722953221644475),
("Father's Dayyear", -5.41610040220442),
-4.736198448394496),
("Halloweenyear", -5.429345628954441),
("dayweek", -5.429345628954441),
("weekyear", -5.0238805208462765),
("hh:mmin|during the <part-of-day>", -4.736198448394496),
("Father's Dayyear", -5.429345628954441),
("<cycle> after|before <time><time-of-day> am|pm",
-5.0106352940962555),
("February<time> <part-of-day>", -5.41610040220442),
("Martin Luther King's Dayyear", -5.0106352940962555),
("tomorrowat <time-of-day>", -4.722953221644475),
("between <time> and <time>on <date>", -4.722953221644475),
("at <time-of-day>tomorrow", -5.0106352940962555),
("tomorrow<time-of-day> am|pm", -5.41610040220442),
-5.0238805208462765),
("February<time> <part-of-day>", -5.429345628954441),
("Martin Luther King's Dayyear", -5.0238805208462765),
("tomorrowat <time-of-day>", -4.736198448394496),
("between <time> and <time>on <date>", -4.736198448394496),
("at <time-of-day>tomorrow", -5.0238805208462765),
("tomorrow<time-of-day> am|pm", -5.429345628954441),
("in|during the <part-of-day>at <time-of-day>",
-5.41610040220442),
("Labor Dayyear", -5.41610040220442),
("Februaryintersect", -5.41610040220442),
("last <cycle> of <time>year", -4.722953221644475),
-5.429345628954441),
("Labor Dayyear", -5.429345628954441),
("Februaryintersect", -5.429345628954441),
("last <cycle> of <time>year", -4.736198448394496),
("<named-month> <day-of-month> (non ordinal)year",
-5.41610040220442),
("yearminute", -5.41610040220442)],
n = 165},
-5.429345628954441),
("yearminute", -5.429345628954441)],
n = 166},
koData =
ClassData{prior = -1.0203600917683615, unseen = -5.726847747587197,
ClassData{prior = -1.0039963122932607, unseen = -5.75890177387728,
likelihoods =
HashMap.fromList
[("in <named-month>year", -5.030437921392435),
[("in <named-month>year", -5.062595033026967),
("<time-of-day> - <time-of-day> (interval)on <date>",
-5.030437921392435),
("hourday", -5.030437921392435),
-5.062595033026967),
("hourday", -5.062595033026967),
("<named-month> <day-of-month> (non ordinal)July",
-5.030437921392435),
("dayhour", -3.2386784521643803),
("daymonth", -3.0155349008501706),
("monthday", -4.624972813284271),
("monthyear", -4.624972813284271),
("intersecthh:mm", -5.030437921392435),
("until <time-of-day><time-of-day> am|pm", -5.030437921392435),
-5.062595033026967),
("dayhour", -3.270835563798912),
("daymonth", -3.047692012484702),
("monthday", -4.657129924918802),
("monthyear", -4.3694478524670215),
("intersecthh:mm", -5.062595033026967),
("houryear", -5.062595033026967),
("until <time-of-day><time-of-day> am|pm", -5.062595033026967),
("<time-of-day> am|pmintersect by \",\", \"of\", \"from\", \"'s\"",
-4.33729074083249),
("<time-of-day> am|pmintersect", -3.7776749528970677),
-4.3694478524670215),
("<time-of-day> am|pmintersect", -3.809832064531599),
("intersect by \",\", \"of\", \"from\", \"'s\"year",
-4.33729074083249),
("Tuesdayafter <time-of-day>", -5.030437921392435),
-4.146304301152812),
("Tuesdayafter <time-of-day>", -5.062595033026967),
("July<day-of-month> (ordinal or number) <named-month>",
-5.030437921392435),
("absorption of , after named dayJuly", -4.624972813284271),
("monthhour", -4.624972813284271),
("todayat <time-of-day>", -5.030437921392435),
("dayday", -4.624972813284271),
("mm/ddat <time-of-day>", -4.624972813284271),
("<time-of-day> am|pmon <date>", -3.7776749528970677),
("dayyear", -4.11414718951828),
("Thursdaymm/dd", -5.030437921392435),
("Thursdayat <time-of-day>", -5.030437921392435),
("August<time-of-day> am|pm", -5.030437921392435),
("monthminute", -5.030437921392435),
("<time-of-day> am|pmtomorrow", -5.030437921392435),
("Thursdayhh:mm", -5.030437921392435),
-5.062595033026967),
("absorption of , after named dayJuly", -4.657129924918802),
("monthhour", -4.657129924918802),
("hourmonth", -5.062595033026967),
("todayat <time-of-day>", -5.062595033026967),
("dayday", -4.657129924918802),
("mm/ddat <time-of-day>", -4.657129924918802),
("<time-of-day> am|pmon <date>", -3.809832064531599),
("dayyear", -4.146304301152812),
("Thursdaymm/dd", -5.062595033026967),
("Thursdayat <time-of-day>", -5.062595033026967),
("August<time-of-day> am|pm", -5.062595033026967),
("monthminute", -5.062595033026967),
("<time-of-day> am|pmtomorrow", -5.062595033026967),
("Thursdayhh:mm", -5.062595033026967),
("August<day-of-month> (ordinal or number) <named-month>",
-5.030437921392435),
("minutemonth", -3.5263605246161616),
-5.062595033026967),
("minutemonth", -3.5585176362506927),
("Thursdayfrom <datetime> - <datetime> (interval)",
-4.624972813284271),
-4.657129924918802),
("Thursdayfrom <time-of-day> - <time-of-day> (interval)",
-4.624972813284271),
("Aprilyear", -5.030437921392435),
-4.657129924918802),
("Aprilyear", -5.062595033026967),
("mm/dd<time-of-day> - <time-of-day> (interval)",
-4.624972813284271),
-4.657129924918802),
("tomorrowfrom <time-of-day> - <time-of-day> (interval)",
-5.030437921392435),
("yesterday<time-of-day> am|pm", -5.030437921392435),
-5.062595033026967),
("yesterday<time-of-day> am|pm", -5.062595033026967),
("intersect by \",\", \"of\", \"from\", \"'s\"hh:mm",
-4.11414718951828),
-4.146304301152812),
("<named-month> <day-of-month> (non ordinal)August",
-5.030437921392435),
("until <time-of-day>on <date>", -4.33729074083249),
("at <time-of-day>intersect", -4.624972813284271),
-5.062595033026967),
("until <time-of-day>on <date>", -4.3694478524670215),
("at <time-of-day>intersect", -4.657129924918802),
("at <time-of-day>intersect by \",\", \"of\", \"from\", \"'s\"",
-5.030437921392435),
("dayminute", -3.0845277723371223),
("intersectSeptember", -3.5263605246161616),
-5.062595033026967),
("dayminute", -3.1166848839716534),
("intersectSeptember", -3.5585176362506927),
("absorption of , after named dayintersect by \",\", \"of\", \"from\", \"'s\"",
-5.030437921392435),
("minuteday", -2.2270775404859005),
-5.062595033026967),
("minuteday", -2.259234652120432),
("absorption of , after named dayintersect",
-5.030437921392435),
("Februaryin|during the <part-of-day>", -5.030437921392435),
("yearhh:mm", -5.030437921392435),
("hh:mmon <date>", -3.5263605246161616),
("absorption of , after named daySeptember", -4.11414718951828),
("on <date>September", -4.624972813284271),
("at <time-of-day>on <date>", -4.624972813284271),
("absorption of , after named dayFebruary", -4.11414718951828),
-5.062595033026967),
("Februaryin|during the <part-of-day>", -5.062595033026967),
("week-endin <named-month>", -5.062595033026967),
("Octoberyear", -5.062595033026967),
("yearhh:mm", -5.062595033026967),
("hh:mmon <date>", -3.5585176362506927),
("absorption of , after named daySeptember",
-4.146304301152812),
("on <date>September", -4.657129924918802),
("at <time-of-day>on <date>", -4.657129924918802),
("absorption of , after named dayFebruary", -4.146304301152812),
("July<integer> to|till|before <hour-of-day>",
-5.030437921392435),
("tomorrowat <time-of-day>", -5.030437921392435),
("tomorrow<time-of-day> am|pm", -5.030437921392435),
("after <time-of-day><time-of-day> am|pm", -5.030437921392435),
("after <time-of-day>year", -5.030437921392435),
("yearminute", -5.030437921392435)],
n = 93}}),
-5.062595033026967),
("tomorrowat <time-of-day>", -5.062595033026967),
("tomorrow<time-of-day> am|pm", -5.062595033026967),
("after <time-of-day><time-of-day> am|pm", -5.062595033026967),
("after <time-of-day>year", -5.062595033026967),
("yearminute", -5.062595033026967)],
n = 96}}),
("after lunch/work/school",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
@ -1001,13 +1011,13 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("week (grain)",
Classifier{okData =
ClassData{prior = -2.7398974188114388e-2,
ClassData{prior = -8.004270767353637e-2,
unseen = -3.6375861597263857,
likelihoods = HashMap.fromList [("", 0.0)], n = 36},
koData =
ClassData{prior = -3.6109179126442243,
unseen = -1.0986122886681098,
likelihoods = HashMap.fromList [("", 0.0)], n = 1}}),
ClassData{prior = -2.5649493574615367,
unseen = -1.6094379124341003,
likelihoods = HashMap.fromList [("", 0.0)], n = 3}}),
("<part-of-day> of <time>",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.3978952727983707,
@ -1117,7 +1127,7 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("this|last|next <cycle>",
Classifier{okData =
ClassData{prior = -0.11122563511022437,
ClassData{prior = -0.16251892949777494,
unseen = -4.3694478524670215,
likelihoods =
HashMap.fromList
@ -1130,15 +1140,15 @@ classifiers
("quarter (grain)", -2.7472709142554916)],
n = 34},
koData =
ClassData{prior = -2.2512917986064953,
unseen = -2.9444389791664407,
ClassData{prior = -1.8971199848858813,
unseen = -3.1354942159291497,
likelihoods =
HashMap.fromList
[("week", -1.791759469228055),
("week (grain)", -1.791759469228055),
("day", -1.791759469228055),
("day (grain)", -1.791759469228055)],
n = 4}}),
[("week", -1.4816045409242156),
("week (grain)", -1.4816045409242156),
("day", -1.9924301646902063),
("day (grain)", -1.9924301646902063)],
n = 6}}),
("Mother's Day",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.791759469228055,
@ -1202,6 +1212,17 @@ classifiers
likelihoods =
HashMap.fromList [("ordinal (digits)", -0.2876820724517809)],
n = 2}}),
("last weekend of <named-month>",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.639057329615259,
likelihoods =
HashMap.fromList
[("October", -0.9555114450274363), ("July", -1.8718021769015913),
("month", -0.7731898882334817)],
n = 5},
koData =
ClassData{prior = -infinity, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [], n = 0}}),
("the <day-of-month> (number)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.0986122886681098,
@ -1271,12 +1292,12 @@ classifiers
n = 39}}),
("year",
Classifier{okData =
ClassData{prior = -0.2231435513142097,
unseen = -3.4011973816621555,
ClassData{prior = -0.21622310846963594,
unseen = -3.4339872044851463,
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
n = 28},
n = 29},
koData =
ClassData{prior = -1.6094379124341003,
ClassData{prior = -1.6376087894007967,
unseen = -2.1972245773362196,
likelihoods = HashMap.fromList [("integer (numeric)", 0.0)],
n = 7}}),
@ -1502,129 +1523,135 @@ classifiers
n = 2}}),
("intersect by \",\", \"of\", \"from\", \"'s\"",
Classifier{okData =
ClassData{prior = -0.41773520069997866,
unseen = -5.1298987149230735,
ClassData{prior = -0.4769240720903093, unseen = -5.147494476813453,
likelihoods =
HashMap.fromList
[("Wednesday<named-month> <day-of-month> (non ordinal)",
-4.430816798843313),
("dayhour", -3.1780538303479458),
("daymonth", -3.1780538303479458),
-4.448516375942715),
("dayhour", -3.1957534074473464),
("daymonth", -3.1957534074473464),
("<named-month> <day-of-month> (non ordinal)Friday",
-4.430816798843313),
-4.448516375942715),
("Friday<named-month> <day-of-month> (non ordinal)",
-3.7376696182833684),
("Wednesdayintersect", -4.430816798843313),
("Labor Daythis|last|next <cycle>", -4.430816798843313),
-3.7553691953827695),
("Wednesdayintersect", -4.448516375942715),
("Labor Daythis|last|next <cycle>", -4.448516375942715),
("intersect by \",\", \"of\", \"from\", \"'s\"year",
-4.430816798843313),
("<part-of-day> of <time>February", -4.430816798843313),
("Saturday<time-of-day> am|pm", -4.430816798843313),
-4.448516375942715),
("<part-of-day> of <time>February", -4.448516375942715),
("Saturday<time-of-day> am|pm", -4.448516375942715),
("Martin Luther King's Daythis|last|next <cycle>",
-4.430816798843313),
("on <date><time-of-day> am|pm", -4.430816798843313),
("hourmonth", -4.430816798843313),
-4.448516375942715),
("on <date><time-of-day> am|pm", -4.448516375942715),
("hourmonth", -4.448516375942715),
("intersect by \",\", \"of\", \"from\", \"'s\"intersect",
-4.430816798843313),
("dayday", -2.559014621941722),
("the <day-of-month> (ordinal)February", -4.02535169073515),
("WednesdayOctober", -4.430816798843313),
("Wednesdaythis|last|next <cycle>", -4.02535169073515),
-4.448516375942715),
("dayday", -2.576714199041123),
("the <day-of-month> (ordinal)February", -4.04305126783455),
("WednesdayOctober", -4.448516375942715),
("Wednesdaythis|last|next <cycle>", -4.04305126783455),
("intersect<named-month> <day-of-month> (non ordinal)",
-3.5145260669691587),
("dayyear", -2.9267394020670396),
-3.5322256440685593),
("dayyear", -2.9444389791664407),
("Saturday<named-month> <day-of-month> (non ordinal)",
-4.430816798843313),
-4.448516375942715),
("<named-month> <day-of-month> (non ordinal)intersect",
-4.430816798843313),
("Thursdayhh:mm", -4.02535169073515),
("Thanksgiving Daythis|last|next <cycle>", -4.430816798843313),
("Memorial Daythis|last|next <cycle>", -4.430816798843313),
-4.448516375942715),
("Thursdayhh:mm", -4.04305126783455),
("Thanksgiving Daythis|last|next <cycle>", -4.448516375942715),
("Memorial Daythis|last|next <cycle>", -4.448516375942715),
("on <date><named-month> <day-of-month> (non ordinal)",
-4.02535169073515),
("TuesdayOctober", -4.430816798843313),
("the <day-of-month> (ordinal)March", -4.430816798843313),
("Mondaythis|last|next <cycle>", -4.430816798843313),
-4.04305126783455),
("TuesdayOctober", -4.448516375942715),
("the <day-of-month> (ordinal)March", -4.448516375942715),
("Mondaythis|last|next <cycle>", -4.448516375942715),
("Fridayintersect by \",\", \"of\", \"from\", \"'s\"",
-4.02535169073515),
("Fridayintersect", -4.430816798843313),
-4.04305126783455),
("Fridayintersect", -4.448516375942715),
("Thursday<datetime> - <datetime> (interval)",
-3.7376696182833684),
-3.7553691953827695),
("Thursday<time-of-day> - <time-of-day> (interval)",
-3.5145260669691587),
("Tuesdaythis|last|next <cycle>", -4.430816798843313),
-3.5322256440685593),
("Tuesdaythis|last|next <cycle>", -4.448516375942715),
("Sunday<named-month> <day-of-month> (non ordinal)",
-4.430816798843313),
("dayminute", -2.639057329615259),
("intersectyear", -4.430816798843313),
("minuteday", -3.5145260669691587),
("this|last|next <cycle>Sunday", -4.430816798843313),
("Sundaythis|last|next <cycle>", -4.430816798843313),
("intersectintersect", -4.430816798843313),
("weekday", -4.430816798843313),
("dayweek", -3.332204510175204),
("Thursday<time-of-day> am|pm", -4.430816798843313),
-4.448516375942715),
("dayminute", -2.6567569067146595),
("intersectyear", -4.448516375942715),
("minuteday", -3.5322256440685593),
("this|last|next <cycle>Sunday", -4.448516375942715),
("Sundaythis|last|next <cycle>", -4.448516375942715),
("intersectintersect", -4.448516375942715),
("weekday", -4.448516375942715),
("dayweek", -3.349904087274605),
("Thursday<time-of-day> am|pm", -4.448516375942715),
("Monday<named-month> <day-of-month> (non ordinal)",
-4.02535169073515),
-4.04305126783455),
("<named-month> <day-of-month> (non ordinal)year",
-4.02535169073515)],
-4.04305126783455)],
n = 54},
koData =
ClassData{prior = -1.074514737089049, unseen = -4.762173934797756,
ClassData{prior = -0.9694005571881036, unseen = -4.867534450455582,
likelihoods =
HashMap.fromList
[("daymonth", -1.8632184332102),
("TuesdaySeptember", -4.060443010546419),
("Wednesdayintersect", -4.060443010546419),
[("week-endJuly", -4.1666652238017265),
("week-endOctober", -3.4735180432417816),
("daymonth", -1.9694406464655074),
("TuesdaySeptember", -4.1666652238017265),
("Wednesdayintersect", -4.1666652238017265),
("hourmonth", -3.068052935133617),
("intersect by \",\", \"of\", \"from\", \"'s\"intersect",
-4.060443010546419),
("SundayFebruary", -4.060443010546419),
("WednesdayOctober", -4.060443010546419),
("FridayJuly", -3.654977902438255),
-4.1666652238017265),
("SundayFebruary", -4.1666652238017265),
("WednesdayOctober", -4.1666652238017265),
("week-endintersect", -4.1666652238017265),
("FridayJuly", -3.7612001156935624),
("<named-month> <day-of-month> (non ordinal)intersect",
-4.060443010546419),
("FridaySeptember", -4.060443010546419),
("WednesdayFebruary", -4.060443010546419),
("minutemonth", -3.144152278672264),
("SundayMarch", -4.060443010546419),
-4.1666652238017265),
("FridaySeptember", -4.1666652238017265),
("WednesdayFebruary", -4.1666652238017265),
("minutemonth", -3.250374491927572),
("SundayMarch", -4.1666652238017265),
("Fridayintersect by \",\", \"of\", \"from\", \"'s\"",
-4.060443010546419),
("MondayFebruary", -3.654977902438255),
("Fridayintersect", -4.060443010546419),
-4.1666652238017265),
("MondayFebruary", -3.7612001156935624),
("Fridayintersect", -4.1666652238017265),
("Thursday<time-of-day> - <time-of-day> (interval)",
-3.654977902438255),
("dayminute", -2.6741486494265287),
("SaturdaySeptember", -4.060443010546419),
("intersectSeptember", -3.144152278672264),
("MondayMarch", -4.060443010546419),
("on <date>September", -3.654977902438255),
("intersectintersect", -4.060443010546419),
("Tuesdayintersect", -4.060443010546419),
("Sundayintersect", -4.060443010546419)],
n = 28}}),
-3.7612001156935624),
("dayminute", -2.780370862681836),
("SaturdaySeptember", -4.1666652238017265),
("intersectSeptember", -3.250374491927572),
("MondayMarch", -4.1666652238017265),
("on <date>September", -3.7612001156935624),
("intersectintersect", -4.1666652238017265),
("Tuesdayintersect", -4.1666652238017265),
("Sundayintersect", -4.1666652238017265)],
n = 33}}),
("last <time>",
Classifier{okData =
ClassData{prior = -0.45198512374305727,
unseen = -3.258096538021482,
ClassData{prior = -1.0986122886681098, unseen = -3.295836866004329,
likelihoods =
HashMap.fromList
[("Father's Day", -2.5257286443082556),
("Martin Luther King's Day", -2.5257286443082556),
("Memorial Day", -2.5257286443082556),
("Mother's Day", -2.5257286443082556),
("day", -1.2729656758128873), ("Sunday", -2.5257286443082556),
("hour", -2.5257286443082556), ("Tuesday", -2.5257286443082556),
("week-end", -2.5257286443082556)],
[("Father's Day", -2.5649493574615367),
("Martin Luther King's Day", -2.5649493574615367),
("Memorial Day", -2.5649493574615367),
("Mother's Day", -2.5649493574615367),
("day", -1.3121863889661687), ("Sunday", -2.5649493574615367),
("hour", -2.5649493574615367), ("Tuesday", -2.5649493574615367),
("week-end", -2.5649493574615367)],
n = 7},
koData =
ClassData{prior = -1.0116009116784799, unseen = -2.995732273553991,
ClassData{prior = -0.40546510810816444,
unseen = -3.713572066704308,
likelihoods =
HashMap.fromList
[("Monday", -2.2512917986064953), ("day", -1.3350010667323402),
("Sunday", -2.2512917986064953),
[("intersect", -2.995732273553991),
("Monday", -2.995732273553991), ("day", -2.0794415416798357),
("Sunday", -2.995732273553991),
("intersect by \",\", \"of\", \"from\", \"'s\"",
-1.845826690498331)],
n = 4}}),
-1.742969305058623),
("hour", -1.2909841813155656),
("week-end", -1.8971199848858813)],
n = 14}}),
("March",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.9444389791664407,
@ -1882,7 +1909,7 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("in <named-month>",
Classifier{okData =
ClassData{prior = -0.40546510810816444,
ClassData{prior = -0.6931471805599453,
unseen = -2.0794415416798357,
likelihoods =
HashMap.fromList
@ -1890,11 +1917,13 @@ classifiers
("month", -0.8472978603872037)],
n = 2},
koData =
ClassData{prior = -1.0986122886681098, unseen = -1.791759469228055,
ClassData{prior = -0.6931471805599453,
unseen = -2.0794415416798357,
likelihoods =
HashMap.fromList
[("October", -0.916290731874155), ("month", -0.916290731874155)],
n = 1}}),
[("October", -0.8472978603872037),
("month", -0.8472978603872037)],
n = 2}}),
("<time-of-day> - <time-of-day> (interval)",
Classifier{okData =
ClassData{prior = -0.8873031950009028,
@ -2039,13 +2068,13 @@ classifiers
likelihoods = HashMap.fromList [("", 0.0)], n = 1}}),
("week-end",
Classifier{okData =
ClassData{prior = -0.6931471805599453,
ClassData{prior = -1.5040773967762742,
unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -0.6931471805599453,
unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2}}),
ClassData{prior = -0.25131442828090605,
unseen = -2.1972245773362196,
likelihoods = HashMap.fromList [("", 0.0)], n = 7}}),
("after <time-of-day>",
Classifier{okData =
ClassData{prior = -1.6094379124341003,

View File

@ -13,13 +13,13 @@ module Duckling.Time.EN.Corpus
, negativeCorpus
) where
import Prelude
import Data.String
import Prelude
import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.Time.Types hiding (Month)
import Duckling.TimeGrain.Types hiding (add)
import Duckling.Testing.Types hiding (examples)
corpus :: Corpus
corpus = (testContext, allExamples)
@ -798,4 +798,15 @@ allExamples = concat
, examples (datetimeInterval ((2013, 3, 21, 0, 0, 0), (2013, 4, 1, 0, 0, 0)) Day)
[ "late March"
]
, examples (datetimeInterval ((2013, 10, 25, 18, 0, 0), (2013, 10, 28, 0, 0, 0)) Hour)
[ "last weekend of October"
, "last week-end in October"
, "last week end of October"
]
, examples (datetimeInterval ((2013, 7, 26, 18, 0, 0), (2013, 7, 29, 0, 0, 0)) Hour)
[ "last wkend of July"
]
, examples (datetimeInterval ((2017, 10, 27, 18, 0, 0), (2017, 10, 30, 0, 0, 0)) Hour)
[ "last weekend of October 2017"
]
]

View File

@ -173,6 +173,22 @@ ruleLastTime = Rule
_ -> Nothing
}
ruleLastWeekendOfMonth :: Rule
ruleLastWeekendOfMonth = Rule
{ name = "last weekend of <named-month>"
, pattern =
[ regex "last\\s(week(\\s|-)?end|wkend)\\s(of|in)"
, Predicate isAMonth
]
, prod = \tokens -> case tokens of
(_:Token Time td2:_) -> do
fri <- intersect (dayOfWeek 5) (hour False 18)
mon <- intersect (dayOfWeek 1) (hour False 0)
td1 <- interval TTime.Open fri mon
tt $ predLastOf td1 td2
_ -> Nothing
}
ruleTimeBeforeLastAfterNext :: Rule
ruleTimeBeforeLastAfterNext = Rule
{ name = "<time> before last|after next"
@ -1532,6 +1548,7 @@ rules =
, ruleTimeBeforeLastAfterNext
, ruleLastDOWOfTime
, ruleLastCycleOfTime
, ruleLastWeekendOfMonth
, ruleNthTimeOfTime
, ruleTheNthTimeOfTime
, ruleNthTimeAfterTime