reuse helpers in HR rules

Summary: [Duckling][Time][HR] Reuse helpers: cleanup code by reusing helper functions in HR rules

Reviewed By: chinmay87

Differential Revision: D18310913

fbshipit-source-id: 0efd69121d25f6a0967b104bfaf97a2b3096ed30
This commit is contained in:
Eric Pinkham 2019-11-07 09:58:09 -08:00 committed by Facebook Github Bot
parent fa5d74ed34
commit a204954397
3 changed files with 247 additions and 362 deletions

View File

@ -157,12 +157,12 @@ classifiers
n = 22}}),
("today",
Classifier{okData =
ClassData{prior = -1.1526795099383855,
unseen = -2.0794415416798357,
likelihoods = HashMap.fromList [("", 0.0)], n = 6},
ClassData{prior = -1.3350010667323402,
unseen = -1.9459101490553135,
likelihoods = HashMap.fromList [("", 0.0)], n = 5},
koData =
ClassData{prior = -0.3794896217049037, unseen = -2.70805020110221,
likelihoods = HashMap.fromList [("", 0.0)], n = 13}}),
ClassData{prior = -0.3053816495511819, unseen = -2.772588722239781,
likelihoods = HashMap.fromList [("", 0.0)], n = 14}}),
("at <time-of-day>",
Classifier{okData =
ClassData{prior = -0.1670540846631662, unseen = -3.912023005428146,
@ -354,202 +354,197 @@ classifiers
n = 2}}),
("intersect",
Classifier{okData =
ClassData{prior = -0.4569616338753394, unseen = -6.102558594613569,
ClassData{prior = -0.44531101665536404,
unseen = -6.100318952020064,
likelihoods =
HashMap.fromList
[("u <named-day><day-of-month>(ordinal) <named-month>",
-5.407171771460119),
("hourday", -5.001706663351954),
("dd.mm<time-of-day> o'clock", -5.407171771460119),
("dayhour", -2.73302312203359),
("daymonth", -3.615412302232064),
-5.404927101606295),
("hourday", -4.99946199349813),
("dd.mm<time-of-day> o'clock", -5.404927101606295),
("dayhour", -2.730778452179766),
("daymonth", -3.61316763237824),
("u <named-day><named-month> <day-of-month> (ordinal)",
-5.407171771460119),
("monthyear", -3.7024236792216936),
("Wednesdayintersect", -5.407171771460119),
("christmasyear", -5.407171771460119),
("Wednesdaynext <cycle>", -5.407171771460119),
("u <named-day><time-of-day> o'clock", -5.407171771460119),
("<time> <part-of-day>u <named-day>", -4.020877410340228),
("intersectat <time-of-day>", -5.407171771460119),
("Saturday<time> <part-of-day>", -5.001706663351954),
("day before yesterdayat <time-of-day>", -4.7140245909001735),
("Marchyear", -5.407171771460119),
-5.404927101606295),
("monthyear", -3.7001790093678695),
("Wednesdayintersect", -5.404927101606295),
("christmasyear", -5.404927101606295),
("Wednesdaynext <cycle>", -5.404927101606295),
("u <named-day><time-of-day> o'clock", -5.404927101606295),
("<time> <part-of-day>u <named-day>", -4.018632740486404),
("intersectat <time-of-day>", -5.404927101606295),
("Saturday<time> <part-of-day>", -4.99946199349813),
("day before yesterdayat <time-of-day>", -4.711779921046349),
("Marchyear", -5.404927101606295),
("<named-day> <day-of-month> (ordinal)September",
-5.001706663351954),
("Saturdayat <time-of-day>", -5.001706663351954),
-4.99946199349813),
("Saturdayat <time-of-day>", -4.99946199349813),
("between <time-of-day> and <time-of-day> (interval)u <named-day>",
-4.7140245909001735),
-4.711779921046349),
("between <datetime> and <datetime> (interval)u <named-day>",
-4.7140245909001735),
("last <cycle>u <named-day>", -5.407171771460119),
("<time-of-day> o'clocktonight", -5.407171771460119),
-4.711779921046349),
("last <cycle>u <named-day>", -5.404927101606295),
("<time-of-day> o'clocktonight", -5.404927101606295),
("from <datetime> - <datetime> (interval)u <named-day>",
-5.407171771460119),
("today<time> <part-of-day>", -5.001706663351954),
("todayat <time-of-day>", -5.407171771460119),
("Thursday<time> timezone", -5.001706663351954),
-5.404927101606295),
("today<time> <part-of-day>", -4.99946199349813),
("todayat <time-of-day>", -5.404927101606295),
("Thursday<time> timezone", -4.99946199349813),
("from <time-of-day> - <time-of-day> (interval)u <named-day>",
-5.407171771460119),
("next <cycle>u <named-day>", -5.407171771460119),
("dayday", -3.1558799728536235),
("hourhour", -5.407171771460119),
-5.404927101606295),
("next <cycle>u <named-day>", -5.404927101606295),
("dayday", -3.1536353029998), ("hourhour", -5.404927101606295),
("intersect<named-month> <day-of-month> (non ordinal)",
-5.001706663351954),
-4.99946199349813),
("Thursdaybetween <time-of-day> and <time-of-day> (interval)",
-4.308559482792009),
("dayyear", -3.9030943746838447),
-4.306314812938186),
("dayyear", -3.900849704830021),
("Thursdaybetween <datetime> and <datetime> (interval)",
-4.308559482792009),
("<time-of-day> o'clocktomorrow", -5.407171771460119),
("Thursday<time> <part-of-day>", -5.001706663351954),
-4.306314812938186),
("<time-of-day> o'clocktomorrow", -5.404927101606295),
("Thursday<time> <part-of-day>", -4.99946199349813),
("<time-of-day> - <time-of-day> (interval)u <named-day>",
-4.490881039585964),
-4.48863636973214),
("<day-of-month>(ordinal) <named-month>year",
-5.001706663351954),
-4.99946199349813),
("<datetime> - <datetime> (interval)u <named-day>",
-4.490881039585964),
-4.48863636973214),
("absorption of , after named day<day-of-month>(ordinal) <named-month>",
-4.020877410340228),
("day after tomorrow<time> <part-of-day>", -5.407171771460119),
("Thursdayhh:mm", -5.001706663351954),
("minutemonth", -4.490881039585964),
("day after tomorrowat <time-of-day>", -5.001706663351954),
-4.018632740486404),
("day after tomorrow<time> <part-of-day>", -5.404927101606295),
("Thursdayhh:mm", -4.99946199349813),
("minutemonth", -4.48863636973214),
("day after tomorrowat <time-of-day>", -4.99946199349813),
("absorption of , after named day<named-month> <day-of-month> (ordinal)",
-4.490881039585964),
-4.48863636973214),
("absorption of , after named day<named-month> <day-of-month> (non ordinal)",
-5.001706663351954),
-4.99946199349813),
("<named-day> <day-of-month> (ordinal)February",
-4.154408802964751),
("this <cycle>u <named-day>", -5.001706663351954),
("last <day-of-week> <time>year", -5.001706663351954),
("dd.mmat <time-of-day>", -5.001706663351954),
-4.152164133110927),
("this <cycle>u <named-day>", -4.99946199349813),
("last <day-of-week> <time>year", -4.99946199349813),
("dd.mmat <time-of-day>", -4.99946199349813),
("intersect<day-of-month>(ordinal) <named-month>",
-4.490881039585964),
-4.48863636973214),
("intersect<named-month> <day-of-month> (ordinal)",
-5.001706663351954),
("Saturday<time-of-day> o'clock", -5.407171771460119),
-4.99946199349813),
("Saturday<time-of-day> o'clock", -5.404927101606295),
("day before yesterday<time-of-day> o'clock",
-5.407171771460119),
-5.404927101606295),
("<time> <part-of-day><named-day> <day-of-month> (ordinal)",
-4.490881039585964),
("dayminute", -3.009276498661748),
("u <named-day>at <time-of-day>", -5.001706663351954),
("<time> <part-of-day>intersect", -3.5353695945585275),
("u <named-day><time> <part-of-day>", -5.001706663351954),
("Tuesdayu <named-month>", -5.407171771460119),
("intersectyear", -5.407171771460119),
("intersectSeptember", -4.490881039585964),
("<ordinal> <cycle> of <time>year", -5.407171771460119),
("minuteday", -2.1113349054557897),
-4.48863636973214),
("dayminute", -3.0070318288079245),
("u <named-day>at <time-of-day>", -4.99946199349813),
("<time> <part-of-day>intersect", -3.5331249247047034),
("u <named-day><time> <part-of-day>", -4.99946199349813),
("Tuesdayu <named-month>", -5.404927101606295),
("intersectyear", -5.404927101606295),
("intersectSeptember", -4.48863636973214),
("<ordinal> <cycle> of <time>year", -5.404927101606295),
("minuteday", -2.1090902356019656),
("absorption of , after named dayintersect",
-5.407171771460119),
("<time> <part-of-day>intersect by \",\"", -4.490881039585964),
("Octoberyear", -4.308559482792009),
("intersect by \",\"at <time-of-day>", -4.490881039585964),
-5.404927101606295),
("<time> <part-of-day>intersect by \",\"", -4.48863636973214),
("Octoberyear", -4.306314812938186),
("intersect by \",\"at <time-of-day>", -4.48863636973214),
("absorption of , after named dayintersect by \",\"",
-4.308559482792009),
("yearat <time-of-day>", -5.407171771460119),
("Septemberyear", -5.001706663351954),
-4.306314812938186),
("yearat <time-of-day>", -5.404927101606295),
("Septemberyear", -4.99946199349813),
("<time> <part-of-day>absorption of , after named day",
-4.7140245909001735),
("todaytonight", -5.407171771460119),
("weekday", -4.490881039585964),
("dayweek", -5.407171771460119),
("weekyear", -5.001706663351954),
("Wednesdayu <named-month>", -5.407171771460119),
-4.711779921046349),
("todaytonight", -5.404927101606295),
("weekday", -4.48863636973214), ("dayweek", -5.404927101606295),
("weekyear", -4.99946199349813),
("Wednesdayu <named-month>", -5.404927101606295),
("u <named-day><named-month> <day-of-month> (non ordinal)",
-5.407171771460119),
("u <named-month>year", -5.001706663351954),
("last <cycle> of <time>year", -5.001706663351954),
-5.404927101606295),
("u <named-month>year", -4.99946199349813),
("last <cycle> of <time>year", -4.99946199349813),
("<day-of-month> (non ordinal) <named-month>year",
-5.407171771460119),
("yearminute", -5.407171771460119)],
-5.404927101606295),
("yearminute", -5.404927101606295)],
n = 164},
koData =
ClassData{prior = -1.002951170098997, unseen = -5.733341276897745,
ClassData{prior = -1.0233888674305223, unseen = -5.71042701737487,
likelihoods =
HashMap.fromList
[("since <time-of-day>by <time>", -4.343805421853684),
[("since <time-of-day>by <time>", -4.3208159036289855),
("year<time-of-day> - <time-of-day> (interval)",
-5.0369526024136295),
("hourday", -4.120661870539474),
("dayhour", -3.1651504255120377),
("daymonth", -3.0220495818713644),
("monthday", -3.9383403137455195),
("monthyear", -3.427514689979529),
("yearhour", -4.631487494305465),
("Wednesdayintersect", -5.0369526024136295),
("hh:mmu <named-day>", -3.9383403137455195),
("last <time>today", -4.343805421853684),
("intersectat <time-of-day>", -5.0369526024136295),
("Marchyear", -4.631487494305465),
("u <named-day>September", -5.0369526024136295),
-5.01396308418893),
("hourday", -5.01396308418893), ("dayhour", -3.142160907287339),
("daymonth", -2.9990600636466658),
("monthday", -3.915350795520821),
("monthyear", -3.40452517175483),
("yearhour", -4.608497976080766),
("Wednesdayintersect", -5.01396308418893),
("hh:mmu <named-day>", -3.915350795520821),
("intersectat <time-of-day>", -5.01396308418893),
("Marchyear", -4.608497976080766),
("u <named-day>September", -5.01396308418893),
("<named-day> <day-of-month> (ordinal)September",
-5.0369526024136295),
("Thursdayafter <time-of-day>", -4.120661870539474),
("until <time-of-day>u <named-day>", -5.0369526024136295),
("since <time-of-day>u <named-day>", -4.631487494305465),
("Sundayu <named-month>", -5.0369526024136295),
("absorption of , after named dayJuly", -4.631487494305465),
("JanuaryWednesday", -5.0369526024136295),
("Marchintersect", -5.0369526024136295),
("dayday", -3.9383403137455195),
("<time> <part-of-day>at <time-of-day>", -5.0369526024136295),
("monthmonth", -4.120661870539474),
("hourhour", -5.0369526024136295),
("<time> <part-of-day>Thursday", -5.0369526024136295),
("dayyear", -4.343805421853684),
("Thursday<time> <part-of-day>", -4.631487494305465),
-5.01396308418893),
("Thursdayafter <time-of-day>", -4.097672352314775),
("until <time-of-day>u <named-day>", -5.01396308418893),
("since <time-of-day>u <named-day>", -4.608497976080766),
("Sundayu <named-month>", -5.01396308418893),
("absorption of , after named dayJuly", -4.608497976080766),
("JanuaryWednesday", -5.01396308418893),
("Marchintersect", -5.01396308418893),
("dayday", -3.915350795520821),
("<time> <part-of-day>at <time-of-day>", -5.01396308418893),
("monthmonth", -4.097672352314775),
("hourhour", -5.01396308418893),
("<time> <part-of-day>Thursday", -5.01396308418893),
("dayyear", -4.3208159036289855),
("Thursday<time> <part-of-day>", -4.608497976080766),
("<time-of-day> - <time-of-day> (interval)u <named-day>",
-5.0369526024136295),
("FebruaryWednesday", -5.0369526024136295),
("monthminute", -5.0369526024136295),
-5.01396308418893),
("FebruaryWednesday", -5.01396308418893),
("monthminute", -5.01396308418893),
("absorption of , after named day<day-of-month>(ordinal) <named-month>",
-5.0369526024136295),
("minutemonth", -4.631487494305465),
("MarchTuesday", -4.631487494305465),
-5.01396308418893),
("minutemonth", -4.608497976080766),
("MarchTuesday", -4.608497976080766),
("absorption of , after named day<named-month> <day-of-month> (ordinal)",
-5.0369526024136295),
-5.01396308418893),
("intersect<time-of-day> - <time-of-day> (interval)",
-5.0369526024136295),
-5.01396308418893),
("absorption of , after named day<named-month> <day-of-month> (non ordinal)",
-4.343805421853684),
-4.3208159036289855),
("intersect by \",\"<time-of-day> - <time-of-day> (interval)",
-4.120661870539474),
("Aprilyear", -5.0369526024136295),
-4.097672352314775),
("Aprilyear", -5.01396308418893),
("Julynumeral to|till|before <integer> (hour-of-day)",
-5.0369526024136295),
("Thursdaysince <time-of-day>", -4.120661870539474),
("minutenograin", -3.427514689979529),
("dayminute", -3.332204510175204),
("<time> <part-of-day>intersect", -4.631487494305465),
("Tuesdayu <named-month>", -5.0369526024136295),
("intersectyear", -4.120661870539474),
("after <time-of-day>by <time>", -4.343805421853684),
("intersectSeptember", -4.631487494305465),
("minuteday", -3.0220495818713644),
("absorption of , after named dayintersect",
-5.0369526024136295),
("<time> <part-of-day>intersect by \",\"", -5.0369526024136295),
("intersect by \",\"at <time-of-day>", -4.120661870539474),
-5.01396308418893),
("Thursdaysince <time-of-day>", -4.097672352314775),
("minutenograin", -3.40452517175483),
("dayminute", -3.309214991950505),
("<time> <part-of-day>intersect", -4.608497976080766),
("Tuesdayu <named-month>", -5.01396308418893),
("intersectyear", -4.097672352314775),
("after <time-of-day>by <time>", -4.3208159036289855),
("intersectSeptember", -4.608497976080766),
("minuteday", -2.9990600636466658),
("absorption of , after named dayintersect", -5.01396308418893),
("<time> <part-of-day>intersect by \",\"", -5.01396308418893),
("intersect by \",\"at <time-of-day>", -4.097672352314775),
("absorption of , after named dayintersect by \",\"",
-5.0369526024136295),
("yearat <time-of-day>", -5.0369526024136295),
-5.01396308418893),
("yearat <time-of-day>", -5.01396308418893),
("absorption of , after named daySeptember",
-4.631487494305465),
("MarchMarch", -4.343805421853684),
("after <time-of-day>u <named-day>", -4.631487494305465),
("Wednesdayu <named-month>", -5.0369526024136295),
("absorption of , after named dayFebruary",
-5.0369526024136295),
("hh:mmby <time>", -4.343805421853684),
("u <named-month>year", -3.9383403137455195),
("Tuesdayintersect", -5.0369526024136295),
("JanuaryTuesday", -5.0369526024136295),
("Sundayintersect", -5.0369526024136295),
("Mondayu <named-month>", -5.0369526024136295)],
n = 95}}),
-4.608497976080766),
("MarchMarch", -4.3208159036289855),
("after <time-of-day>u <named-day>", -4.608497976080766),
("Wednesdayu <named-month>", -5.01396308418893),
("absorption of , after named dayFebruary", -5.01396308418893),
("hh:mmby <time>", -4.3208159036289855),
("u <named-month>year", -3.915350795520821),
("Tuesdayintersect", -5.01396308418893),
("JanuaryTuesday", -5.01396308418893),
("Sundayintersect", -5.01396308418893),
("Mondayu <named-month>", -5.01396308418893)],
n = 92}}),
("early morning",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.791759469228055,
@ -574,13 +569,6 @@ classifiers
koData =
ClassData{prior = -infinity, unseen = -1.791759469228055,
likelihoods = HashMap.fromList [], n = 0}}),
("season",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.9459101490553135,
likelihoods = HashMap.fromList [("", 0.0)], n = 5},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("year (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.639057329615259,
@ -1067,22 +1055,22 @@ classifiers
n = 3}}),
("time-of-day (latent)",
Classifier{okData =
ClassData{prior = -0.8050650967639307, unseen = -3.784189633918261,
ClassData{prior = -0.5965203448708736,
unseen = -3.7612001156935624,
likelihoods =
HashMap.fromList
[("integer (numeric)", -0.20585205420414873),
("integer (0..19)", -2.151762203259462)],
[("integer (numeric)", -0.1823215567939546),
("integer (0..19)", -2.128231705849268)],
n = 38},
koData =
ClassData{prior = -0.5925036547802578, unseen = -3.970291913552122,
ClassData{prior = -0.8001193001121132, unseen = -3.58351893845611,
likelihoods =
HashMap.fromList
[("integer (numeric)", -0.48550781578170077),
("integer (20..90)", -2.8526314299133175),
("few", -3.258096538021482),
("integer (0..19)", -1.3862943611198906),
("a pair", -3.258096538021482)],
n = 47}}),
[("integer (numeric)", -0.37729423114146804),
("few", -2.8622008809294686),
("integer (0..19)", -1.6094379124341003),
("a pair", -2.8622008809294686)],
n = 31}}),
("for <duration>",
Classifier{okData =
ClassData{prior = -0.11441035117774422,
@ -1343,23 +1331,17 @@ classifiers
n = 1}}),
("last <time>",
Classifier{okData =
ClassData{prior = -1.7047480922384253, unseen = -2.833213344056216,
ClassData{prior = 0.0, unseen = -2.70805020110221,
likelihoods =
HashMap.fromList
[("evening|night", -2.0794415416798357),
("day", -1.6739764335716716), ("Sunday", -2.0794415416798357),
("hour", -1.6739764335716716), ("Tuesday", -2.0794415416798357),
("week-end", -2.0794415416798357)],
[("evening|night", -1.9459101490553135),
("day", -1.540445040947149), ("Sunday", -1.9459101490553135),
("hour", -1.540445040947149), ("Tuesday", -1.9459101490553135),
("week-end", -1.9459101490553135)],
n = 4},
koData =
ClassData{prior = -0.2006706954621511,
unseen = -3.8066624897703196,
likelihoods =
HashMap.fromList
[("<time-of-day> o'clock", -3.0910424533583156),
("time-of-day (latent)", -0.8938178760220964),
("hour", -0.8397506547518206)],
n = 18}}),
ClassData{prior = -infinity, unseen = -1.9459101490553135,
likelihoods = HashMap.fromList [], n = 0}}),
("March",
Classifier{okData =
ClassData{prior = -0.4795730802618862, unseen = -2.70805020110221,
@ -1455,23 +1437,18 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("next <time>",
Classifier{okData =
ClassData{prior = -0.25131442828090605,
unseen = -3.1780538303479458,
ClassData{prior = 0.0, unseen = -3.0910424533583156,
likelihoods =
HashMap.fromList
[("Wednesday", -2.4423470353692043),
("Monday", -2.4423470353692043),
("Friday", -2.4423470353692043), ("day", -1.1895840668738362),
("March", -2.4423470353692043), ("month", -2.4423470353692043),
("Tuesday", -1.749199854809259)],
[("Wednesday", -2.3513752571634776),
("Monday", -2.3513752571634776),
("Friday", -2.3513752571634776), ("day", -1.0986122886681098),
("March", -2.3513752571634776), ("month", -2.3513752571634776),
("Tuesday", -1.6582280766035324)],
n = 7},
koData =
ClassData{prior = -1.5040773967762742, unseen = -2.639057329615259,
likelihoods =
HashMap.fromList
[("<time-of-day> o'clock", -1.466337068793427),
("hour", -1.466337068793427)],
n = 2}}),
ClassData{prior = -infinity, unseen = -2.0794415416798357,
likelihoods = HashMap.fromList [], n = 0}}),
("last <cycle>",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.044522437723423,
@ -1538,18 +1515,17 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("by the end of <time>",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.833213344056216,
ClassData{prior = 0.0, unseen = -2.639057329615259,
likelihoods =
HashMap.fromList
[("today", -2.0794415416798357),
("next <cycle>", -2.0794415416798357),
("day", -1.3862943611198906),
("this <cycle>", -1.6739764335716716),
("month", -1.6739764335716716),
("this <time>", -2.0794415416798357)],
n = 5},
[("today", -1.8718021769015913),
("next <cycle>", -1.8718021769015913),
("day", -1.466337068793427),
("this <cycle>", -1.466337068793427),
("month", -1.466337068793427)],
n = 4},
koData =
ClassData{prior = -infinity, unseen = -1.9459101490553135,
ClassData{prior = -infinity, unseen = -1.791759469228055,
likelihoods = HashMap.fromList [], n = 0}}),
("in <duration>",
Classifier{okData =
@ -1633,6 +1609,13 @@ classifiers
("after <time-of-day>time-of-day (latent)",
-2.6741486494265287)],
n = 9}}),
("winter",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.3862943611198906,
likelihoods = HashMap.fromList [("", 0.0)], n = 2},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("quarter after|past (hour-of-day)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.6094379124341003,
@ -1902,29 +1885,33 @@ classifiers
("October", -1.1631508098056809),
("month", -0.8266785731844679)],
n = 6}}),
("summer",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.6094379124341003,
likelihoods = HashMap.fromList [("", 0.0)], n = 3},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
("this <time>",
Classifier{okData =
ClassData{prior = -0.1670540846631662,
unseen = -3.5553480614894135,
ClassData{prior = -0.11778303565638351,
unseen = -3.258096538021482,
likelihoods =
HashMap.fromList
[("today", -2.833213344056216),
("Wednesday", -2.833213344056216),
("season", -2.1400661634962708),
("evening|night", -2.833213344056216),
("Monday", -2.833213344056216), ("day", -1.580450375560848),
("afternoon", -2.833213344056216),
("hour", -1.7346010553881064), ("morning", -2.833213344056216),
("week-end", -2.4277482359480516)],
n = 11},
[("Wednesday", -2.5257286443082556),
("evening|night", -2.5257286443082556),
("Monday", -2.5257286443082556), ("day", -1.4271163556401458),
("hour", -1.8325814637483102), ("winter", -2.5257286443082556),
("week-end", -2.120263536200091),
("summer", -2.120263536200091)],
n = 8},
koData =
ClassData{prior = -1.8718021769015913, unseen = -2.833213344056216,
ClassData{prior = -2.1972245773362196,
unseen = -2.4849066497880004,
likelihoods =
HashMap.fromList
[("day", -2.0794415416798357), ("hour", -2.0794415416798357),
("late night", -2.0794415416798357),
("Tuesday", -2.0794415416798357)],
n = 2}}),
[("day", -1.7047480922384253), ("Tuesday", -1.7047480922384253)],
n = 1}}),
("<named-month> <day-of-month> (ordinal)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.5649493574615367,

View File

@ -445,26 +445,26 @@ allExamples = concat
[ "ove zime"
, "zimus"
]
, examples (datetime (2013, 12, 25, 0, 0, 0) Day)
, examples (datetimeHoliday (2013, 12, 25, 0, 0, 0) Day "christmas")
[ "Bozic"
, "zicbo"
]
, examples (datetime (2013, 12, 31, 0, 0, 0) Day)
, examples (datetimeHoliday (2013, 12, 31, 0, 0, 0) Day "new year's eve")
[ "stara godina"
]
, examples (datetime (2014, 1, 1, 0, 0, 0) Day)
, examples (datetimeHoliday (2014, 1, 1, 0, 0, 0) Day "new year's day")
[ "nova godina"
]
, examples (datetime (2013, 2, 14, 0, 0, 0) Day)
, examples (datetimeHoliday (2013, 2, 14, 0, 0, 0) Day "valentine's day")
[ "valentinovo"
]
, examples (datetime (2013, 5, 12, 0, 0, 0) Day)
, examples (datetimeHoliday (2013, 5, 12, 0, 0, 0) Day "Mother's Day")
[ "majcin dan"
]
, examples (datetime (2013, 6, 16, 0, 0, 0) Day)
, examples (datetimeHoliday (2013, 6, 16, 0, 0, 0) Day "Father's Day")
[ "dan oceva"
]
, examples (datetime (2013, 10, 31, 0, 0, 0) Day)
, examples (datetimeHoliday (2013, 10, 31, 0, 0, 0) Day "halloween day")
[ "noc vjestica"
]
, examples (datetimeInterval ((2013, 2, 12, 18, 0, 0), (2013, 2, 13, 0, 0, 0)) Hour)

View File

@ -58,6 +58,26 @@ ruleMonths = mkRuleMonths
, ( "December" , "prosina?c(a|u)?|decemba?r(a|u)?|dec\\.?|pros?\\.?|dvanaest(i|a|o(ga?)?)" )
]
ruleHolidays :: [Rule]
ruleHolidays = mkRuleHolidays
[ ( "new year's eve" , "star(a|u|e) godin(a|e|u)" , monthDay 12 31 )
, ( "new year's day" , "nov(a|u|e) godin(a|e|u)" , monthDay 1 1 )
, ( "christmas eve" , "badnjaka?" , monthDay 12 24 )
, ( "christmas" , "(zi(c|ć)bo|bo(z|ž)i(c|ć))(a|u|ni|na)?", monthDay 12 25 )
, ( "halloween day" , "no(c|ć) vje(s|š)tica" , monthDay 10 31 )
, ( "Mother's Day" , "maj(c|č)in dan" , nthDOWOfMonth 2 7 5)
, ( "Father's Day" , "dan (o(c|č)eva|tata)" , nthDOWOfMonth 3 7 6)
, ( "valentine's day", "valentinov(og?|a|)" , monthDay 2 14 )
]
ruleSeasons :: [Rule]
ruleSeasons = mkRuleSeasons
[ ("summer", "ljet(os?|a)" , monthDay 6 21 , monthDay 9 23 )
, ("fall" , "jesen(i|as)?" , monthDay 9 23 , monthDay 12 21)
, ("winter", "zim(a|e|us)?" , monthDay 12 21, monthDay 3 20 )
, ("spring", "prolje(c|ć)(e|a)", monthDay 3 20 , monthDay 6 21 )
]
ruleHalfIntegerHrStyleHourofday :: Rule
ruleHalfIntegerHrStyleHourofday = Rule
{ name = "half <integer> (HR style hour-of-day)"
@ -236,15 +256,6 @@ ruleZaHalfHourofday = Rule
_ -> Nothing
}
ruleValentinesDay :: Rule
ruleValentinesDay = Rule
{ name = "valentine's day"
, pattern =
[ regex "valentinov(og?|a|)"
]
, prod = \_ -> tt $ monthDay 2 14
}
ruleSinceTimeofday :: Rule
ruleSinceTimeofday = Rule
{ name = "since <time-of-day>"
@ -257,21 +268,12 @@ ruleSinceTimeofday = Rule
_ -> Nothing
}
ruleNewYearsDay :: Rule
ruleNewYearsDay = Rule
{ name = "new year's day"
, pattern =
[ regex "nov(a|u|e) godin(a|e|u)"
]
, prod = \_ -> tt $ monthDay 1 1
}
ruleLastTime :: Rule
ruleLastTime = Rule
{ name = "last <time>"
, pattern =
[ regex "(prethodn(i|u|a|e|o(ga?)?)|pro(s|š)l(ih?|u|a|e|o(ga?)?))"
, dimension Time
, Predicate isOkWithThisNext
]
, prod = \tokens -> case tokens of
(_:Token Time td:_) ->
@ -381,16 +383,6 @@ ruleMonthDdddInterval = Rule
_ -> Nothing
}
ruleSeason4 :: Rule
ruleSeason4 = Rule
{ name = "season"
, pattern =
[ regex "prolje(c|ć)(e|a)"
]
, prod = \_ ->
Token Time <$> interval TTime.Open (monthDay 3 20) (monthDay 6 21)
}
ruleYearLatent2 :: Rule
ruleYearLatent2 = Rule
{ name = "year (latent)"
@ -615,15 +607,6 @@ ruleNamedmonthDayofmonthOrdinal = Rule
_ -> Nothing
}
ruleChristmasEve :: Rule
ruleChristmasEve = Rule
{ name = "christmas eve"
, pattern =
[ regex "badnjaka?"
]
, prod = \_ -> tt $ monthDay 12 24
}
ruleInduringThePartofday :: Rule
ruleInduringThePartofday = Rule
{ name = "in|during the <part-of-day>"
@ -741,26 +724,6 @@ ruleExactlyTimeofday = Rule
_ -> Nothing
}
ruleSeason3 :: Rule
ruleSeason3 = Rule
{ name = "season"
, pattern =
[ regex "zim(a|e|us)?"
]
, prod = \_ ->
Token Time <$> interval TTime.Open (monthDay 12 21) (monthDay 3 20)
}
ruleSeason :: Rule
ruleSeason = Rule
{ name = "season"
, pattern =
[ regex "ljet(os?|a)"
]
, prod = \_ ->
Token Time <$> interval TTime.Open (monthDay 6 21) (monthDay 9 23)
}
ruleUNamedday :: Rule
ruleUNamedday = Rule
{ name = "u <named-day>"
@ -788,15 +751,6 @@ ruleBetweenDatetimeAndDatetimeInterval = Rule
_ -> Nothing
}
ruleNewYearsEve :: Rule
ruleNewYearsEve = Rule
{ name = "new year's eve"
, pattern =
[ regex "star(a|u|e) godin(a|e|u)"
]
, prod = \_ -> tt $ monthDay 12 31
}
ruleByTheEndOfTime :: Rule
ruleByTheEndOfTime = Rule
{ name = "by the end of <time>"
@ -964,7 +918,7 @@ ruleWeekend = Rule
, pattern =
[ regex "(za )?vikenda?"
]
, prod = \_ -> tt weekend
, prod = \_ -> tt $ mkOkForThisNext weekend
}
rulePrijeDuration :: Rule
@ -1017,7 +971,7 @@ ruleNextTime = Rule
{ name = "next <time>"
, pattern =
[ regex "sljede(c|ć)(i|u|a|e(ga?)?)"
, Predicate isNotLatent
, Predicate $ and . sequence [isNotLatent, isOkWithThisNext]
]
, prod = \tokens -> case tokens of
(_:Token Time td:_) -> tt $ predNth 0 True td
@ -1121,7 +1075,7 @@ ruleThisTime = Rule
{ name = "this <time>"
, pattern =
[ regex "ov(aj?|og?|e)(sad)?"
, dimension Time
, Predicate isOkWithThisNext
]
, prod = \tokens -> case tokens of
(_:Token Time td:_) -> tt $ predNth 0 False td
@ -1198,16 +1152,6 @@ ruleYesterday = Rule
, prod = \_ -> tt . cycleNth TG.Day $ - 1
}
ruleSeason2 :: Rule
ruleSeason2 = Rule
{ name = "season"
, pattern =
[ regex "jesen(i|as)?"
]
, prod = \_ ->
Token Time <$> interval TTime.Open (monthDay 9 23) (monthDay 12 21)
}
ruleAfterTimeofday :: Rule
ruleAfterTimeofday = Rule
{ name = "after <time-of-day>"
@ -1220,15 +1164,6 @@ ruleAfterTimeofday = Rule
_ -> Nothing
}
ruleChristmas :: Rule
ruleChristmas = Rule
{ name = "christmas"
, pattern =
[ regex "(zi(c|ć)bo|bo(z|ž)i(c|ć))(a|u|ni|na)?"
]
, prod = \_ -> tt $ monthDay 12 25
}
ruleDayofmonthOrdinal :: Rule
ruleDayofmonthOrdinal = Rule
{ name = "<day-of-month>. (ordinal)"
@ -1358,15 +1293,6 @@ ruleYear = Rule
_ -> Nothing
}
ruleHalloweenDay :: Rule
ruleHalloweenDay = Rule
{ name = "halloween day"
, pattern =
[ regex "no(c|ć) vje(s|š)tica"
]
, prod = \_ -> tt $ monthDay 10 31
}
ruleNamedmonthDayofmonthNonOrdinal :: Rule
ruleNamedmonthDayofmonthNonOrdinal = Rule
{ name = "<named-month> <day-of-month> (non ordinal)"
@ -1391,15 +1317,6 @@ ruleAbsorptionOfAfterNamedDay = Rule
_ -> Nothing
}
ruleFathersDay :: Rule
ruleFathersDay = Rule
{ name = "Father's Day"
, pattern =
[ regex "dan (o(c|č)eva|tata)"
]
, prod = \_ -> tt $ nthDOWOfMonth 3 7 6
}
ruleByTime :: Rule
ruleByTime = Rule
{ name = "by <time>"
@ -1475,7 +1392,7 @@ ruleEveningnight = Rule
, pattern =
[ regex "(na)?ve(c|č)er(i|as)?"
]
, prod = \_ -> Token Time . partOfDay . mkLatent <$>
, prod = \_ -> Token Time . mkOkForThisNext . partOfDay . mkLatent <$>
interval TTime.Open (hour False 18) (hour False 0)
}
@ -1535,15 +1452,6 @@ ruleTomorrow = Rule
, prod = \_ -> tt $ cycleNth TG.Day 1
}
ruleMothersDay :: Rule
ruleMothersDay = Rule
{ name = "Mother's Day"
, pattern =
[ regex "maj(c|č)in dan"
]
, prod = \_ -> tt $ nthDOWOfMonth 2 7 5
}
ruleTimeofdayOclock :: Rule
ruleTimeofdayOclock = Rule
{ name = "<time-of-day> o'clock"
@ -1618,8 +1526,6 @@ rules =
, ruleBetweenTimeofdayAndTimeofdayInterval
, ruleByTheEndOfTime
, ruleByTime
, ruleChristmas
, ruleChristmasEve
, ruleCycleAfterTime
, ruleCycleBeforeTime
, ruleDatetimeDatetimeInterval
@ -1642,12 +1548,10 @@ rules =
, ruleEoyendOfYear
, ruleEveningnight
, ruleExactlyTimeofday
, ruleFathersDay
, ruleForDuration
, ruleFromDatetimeDatetimeInterval
, ruleFromTimeofdayTimeofdayInterval
, ruleHalfIntegerHrStyleHourofday
, ruleHalloweenDay
, ruleHhmm
, ruleHhmmMilitaryPrefixedWithMToAvoidAmbiguityWithYears
, ruleHhmmss
@ -1666,12 +1570,9 @@ rules =
, ruleMidnighteodendOfDay
, ruleMonthDdddInterval
, ruleMorning
, ruleMothersDay
, ruleNameddayDayofmonthOrdinal
, ruleNamedmonthDayofmonthNonOrdinal
, ruleNamedmonthDayofmonthOrdinal
, ruleNewYearsDay
, ruleNewYearsEve
, ruleNextCycle
, ruleNextNCycle
, ruleNextTime
@ -1693,10 +1594,6 @@ rules =
, ruleHourofdayNumeral
, ruleHourofdayQuarter
, ruleHourofdayHalf
, ruleSeason
, ruleSeason2
, ruleSeason3
, ruleSeason4
, ruleSinceTimeofday
, ruleThisCycle
, ruleThisPartofday
@ -1716,7 +1613,6 @@ rules =
, ruleUNamedday
, ruleUNamedmonth
, ruleUntilTimeofday
, ruleValentinesDay
, ruleWeekend
, ruleWithinDuration
, ruleYear
@ -1731,3 +1627,5 @@ rules =
]
++ ruleDaysOfWeek
++ ruleMonths
++ ruleHolidays
++ ruleSeasons