NB: Bringing latest changes

Summary:
* Numeral: fixed "hundre" (not "hundred")
* Numeral: added "tretti", "søtti"
* Time: updated last times to support "sist"
* Time: christmas days

Reviewed By: niteria

Differential Revision: D4958919

fbshipit-source-id: e4eecf5
This commit is contained in:
Julien Odent 2017-04-28 07:46:01 -07:00 committed by Facebook Github Bot
parent 2182d94edb
commit 5ba2c9e9a1
5 changed files with 92 additions and 47 deletions

View File

@ -66,6 +66,16 @@ allExamples = concat
, "tyve"
, "Tjue"
]
, examples (NumeralValue 30)
[ "30"
, "tretti"
, "tredve"
]
, examples (NumeralValue 70)
[ "70"
, "søtti"
, "sytti"
]
, examples (NumeralValue 1.1)
[ "1,1"
, "1,10"
@ -107,6 +117,9 @@ allExamples = concat
[ "5 tusen"
, "fem tusen"
]
, examples (NumeralValue 100)
[ "hundre"
]
, examples (NumeralValue 5020)
[ "fem tusen og tjue"
]

View File

@ -175,11 +175,11 @@ rulePowersOfTen :: Rule
rulePowersOfTen = Rule
{ name = "powers of tens"
, pattern =
[ regex "(hundrede?|tusen?|million(er)?)"
[ regex "(hundre(de)?|tusen?|million(er)?)"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (match:_)):_) -> case Text.toLower match of
"hundred" -> double 1e2 >>= withGrain 2 >>= withMultipliable
"hundre" -> double 1e2 >>= withGrain 2 >>= withMultipliable
"hundrede" -> double 1e2 >>= withGrain 2 >>= withMultipliable
"tuse" -> double 1e3 >>= withGrain 3 >>= withMultipliable
"tusen" -> double 1e3 >>= withGrain 3 >>= withMultipliable
@ -254,10 +254,12 @@ dozensMap = HashMap.fromList
[ ( "tyve" , 20 )
, ( "tjue" , 20 )
, ( "tredve" , 30 )
, ( "tretti" , 30 )
, ( "f\x00f8rti" , 40 )
, ( "femti" , 50 )
, ( "seksti" , 60 )
, ( "sytti" , 70 )
, ( "s\x00f8tti" , 70 )
, ( "\x00e5tti" , 80 )
, ( "nitti" , 90 )
]
@ -266,7 +268,7 @@ ruleInteger2 :: Rule
ruleInteger2 = Rule
{ name = "integer (20..90)"
, pattern =
[ regex "(tyve|tjue|tredve|f\x00f8rti|femti|seksti|sytti|\x00e5tti|nitti)"
[ regex "(tyve|tjue|tredve|tretti|f\x00f8rti|femti|seksti|sytti|s\x00f8tti|\x00e5tti|nitti)"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (match:_)):_) ->

View File

@ -205,8 +205,8 @@ classifiers
n = 3}}),
("month (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.3978952727983707,
likelihoods = HashMap.fromList [("", 0.0)], n = 9},
ClassData{prior = 0.0, unseen = -2.4849066497880004,
likelihoods = HashMap.fromList [("", 0.0)], n = 10},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -432,8 +432,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("year (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -2.772588722239781,
likelihoods = HashMap.fromList [("", 0.0)], n = 14},
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}}),
@ -629,8 +629,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("week (grain)",
Classifier{okData =
ClassData{prior = 0.0, unseen = -3.332204510175204,
likelihoods = HashMap.fromList [("", 0.0)], n = 26},
ClassData{prior = 0.0, unseen = -3.367295829986474,
likelihoods = HashMap.fromList [("", 0.0)], n = 27},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -843,6 +843,13 @@ classifiers
-1.3862943611198906),
("minute", -1.3862943611198906)],
n = 4}}),
("christmas days",
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}}),
("time-of-day (latent)",
Classifier{okData =
ClassData{prior = -0.99714282850325, unseen = -3.713572066704308,
@ -1036,8 +1043,8 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("named-day",
Classifier{okData =
ClassData{prior = 0.0, unseen = -4.2626798770413155,
likelihoods = HashMap.fromList [("", 0.0)], n = 69},
ClassData{prior = 0.0, unseen = -4.290459441148391,
likelihoods = HashMap.fromList [("", 0.0)], n = 71},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1098,15 +1105,16 @@ classifiers
likelihoods = HashMap.fromList [], n = 0}}),
("last <time>",
Classifier{okData =
ClassData{prior = -2.268683541318364, unseen = -2.5649493574615367,
ClassData{prior = -1.6739764335716716,
unseen = -2.9444389791664407,
likelihoods =
HashMap.fromList
[("day", -1.3862943611198906),
("named-day", -1.3862943611198906),
[("day", -1.2809338454620642),
("named-day", -1.2809338454620642),
("hour", -1.791759469228055), ("week-end", -1.791759469228055)],
n = 3},
n = 6},
koData =
ClassData{prior = -0.10919929196499197, unseen = -4.07753744390572,
ClassData{prior = -0.2076393647782445, unseen = -4.07753744390572,
likelihoods =
HashMap.fromList
[("day", -1.8632184332102),
@ -1216,17 +1224,18 @@ classifiers
n = 4}}),
("last <cycle>",
Classifier{okData =
ClassData{prior = -0.6931471805599453, unseen = -2.833213344056216,
ClassData{prior = -0.45198512374305727,
unseen = -3.1354942159291497,
likelihoods =
HashMap.fromList
[("week", -1.6739764335716716),
("month (grain)", -2.0794415416798357),
("year (grain)", -2.0794415416798357),
("week (grain)", -1.6739764335716716),
("year", -2.0794415416798357), ("month", -2.0794415416798357)],
n = 4},
[("week", -1.7047480922384253),
("month (grain)", -1.9924301646902063),
("year (grain)", -1.9924301646902063),
("week (grain)", -1.7047480922384253),
("year", -1.9924301646902063), ("month", -1.9924301646902063)],
n = 7},
koData =
ClassData{prior = -0.6931471805599453, unseen = -2.833213344056216,
ClassData{prior = -1.0116009116784799, unseen = -2.833213344056216,
likelihoods =
HashMap.fromList
[("week", -1.6739764335716716),
@ -1486,8 +1495,8 @@ classifiers
likelihoods = HashMap.fromList [("", 0.0)], n = 12}}),
("week-end",
Classifier{okData =
ClassData{prior = 0.0, unseen = -1.9459101490553135,
likelihoods = HashMap.fromList [("", 0.0)], n = 5},
ClassData{prior = 0.0, unseen = -2.0794415416798357,
likelihoods = HashMap.fromList [("", 0.0)], n = 6},
koData =
ClassData{prior = -infinity, unseen = -0.6931471805599453,
likelihoods = HashMap.fromList [], n = 0}}),
@ -1556,29 +1565,30 @@ classifiers
n = 9}}),
("this <time>",
Classifier{okData =
ClassData{prior = -1.3350010667323402,
unseen = -3.7376696182833684,
ClassData{prior = -1.2443240998495033,
unseen = -3.8501476017100584,
likelihoods =
HashMap.fromList
[("week", -3.0204248861443626),
("intersect", -2.6149597780361984),
("season", -2.1041341542702074),
("next <cycle>", -3.0204248861443626),
("named-month", -2.6149597780361984),
("day", -2.1041341542702074), ("hour", -1.7676619176489945),
("evening", -3.0204248861443626),
("month", -2.1041341542702074),
("morning", -3.0204248861443626),
("week-end", -2.1041341542702074)],
n = 15},
[("week", -3.1354942159291497),
("intersect", -2.7300291078209855),
("season", -2.2192034840549946),
("next <cycle>", -3.1354942159291497),
("named-month", -2.7300291078209855),
("day", -1.8827312474337816),
("christmas days", -2.7300291078209855),
("hour", -1.8827312474337816), ("evening", -3.1354942159291497),
("month", -2.2192034840549946),
("morning", -3.1354942159291497),
("week-end", -2.2192034840549946)],
n = 17},
koData =
ClassData{prior = -0.3053816495511819, unseen = -4.564348191467836,
ClassData{prior = -0.3398678256223512, unseen = -4.574710978503383,
likelihoods =
HashMap.fromList
[("intersect", -1.988927534139004),
("named-month", -1.6094379124341003),
("hour", -1.988927534139004), ("month", -1.1198896871153945),
("morning", -1.988927534139004)],
[("intersect", -1.9993988340062996),
("named-month", -1.6199092123013958),
("hour", -1.9993988340062996), ("month", -1.1303609869826898),
("morning", -1.9993988340062996)],
n = 42}}),
("within <duration>",
Classifier{okData =

View File

@ -147,12 +147,14 @@ allExamples = concat
]
, examples (datetime (2013, 2, 4, 0, 0, 0) Week)
[ "forrige uke"
, "sist uke"
]
, examples (datetime (2013, 2, 18, 0, 0, 0) Week)
[ "neste uke"
]
, examples (datetime (2013, 1, 0, 0, 0, 0) Month)
[ "forrige måned"
, "sist måned"
]
, examples (datetime (2013, 3, 0, 0, 0, 0) Month)
[ "neste måned"
@ -173,6 +175,7 @@ allExamples = concat
]
, examples (datetime (2012, 0, 0, 0, 0, 0) Year)
[ "forrige år"
, "sist år"
]
, examples (datetime (2012, 0, 0, 0, 0, 0) Year)
[ "i fjor"
@ -186,10 +189,12 @@ allExamples = concat
]
, examples (datetime (2013, 2, 10, 0, 0, 0) Day)
[ "forrige søndag"
, "sist søndag"
, "søndag i forrige uke"
]
, examples (datetime (2013, 2, 5, 0, 0, 0) Day)
[ "forrige tirsdag"
, "sist tirsdag"
]
, examples (datetime (2013, 2, 19, 0, 0, 0) Day)
[ "neste tirsdag"
@ -431,6 +436,7 @@ allExamples = concat
]
, examples (datetimeInterval ((2013, 2, 8, 18, 0, 0), (2013, 2, 11, 0, 0, 0)) Hour)
[ "forrige helg"
, "sist helg"
]
, examples (datetimeInterval ((2013, 2, 13, 18, 0, 0), (2013, 2, 14, 0, 0, 0)) Hour)
[ "i morgen kveld"
@ -450,6 +456,10 @@ allExamples = concat
, examples (datetimeInterval ((2013, 2, 18, 4, 0, 0), (2013, 2, 18, 12, 0, 0)) Hour)
[ "mandag morgen"
]
, examples (datetimeInterval ((2013, 12, 24, 0, 0, 0), (2013, 12, 31, 0, 0, 0)) Day)
[ "i romjulen"
, "i romjula"
]
, examples (datetimeInterval ((2013, 2, 12, 4, 29, 58), (2013, 2, 12, 4, 30, 0)) Second)
[ "siste 2 sekunder"
, "siste to sekunder"

View File

@ -254,7 +254,7 @@ ruleLastTime :: Rule
ruleLastTime = Rule
{ name = "last <time>"
, pattern =
[ regex "(siste|forrige|seneste)"
[ regex "(siste?|forrige|seneste)"
, dimension Time
]
, prod = \tokens -> case tokens of
@ -643,7 +643,7 @@ ruleLastCycle :: Rule
ruleLastCycle = Rule
{ name = "last <cycle>"
, pattern =
[ regex "siste|seneste|forrige"
[ regex "siste?|seneste|forrige"
, dimension TimeGrain
]
, prod = \tokens -> case tokens of
@ -953,7 +953,7 @@ ruleLastNCycle :: Rule
ruleLastNCycle = Rule
{ name = "last n <cycle>"
, pattern =
[ regex "siste|seneste|forrige"
[ regex "siste?|seneste|forrige"
, Predicate $ isIntegerBetween 1 9999
, dimension TimeGrain
]
@ -964,6 +964,15 @@ ruleLastNCycle = Rule
_ -> Nothing
}
ruleChristmasDays :: Rule
ruleChristmasDays = Rule
{ name = "christmas days"
, pattern =
[ regex "romjul(a|en)"
]
, prod = \_ -> tt $ interval TTime.Open (monthDay 12 24, monthDay 12 30)
}
ruleTimeofdaySharp :: Rule
ruleTimeofdaySharp = Rule
{ name = "<time-of-day> sharp"
@ -1823,6 +1832,7 @@ rules =
, ruleByTheEndOfTime
, ruleChristmas
, ruleChristmasEve
, ruleChristmasDays
, ruleConstitutionDay
, ruleCycleAfterTime
, ruleCycleBeforeTime