mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
adds frequent durations in German (#509)
Summary: Found a lacking frequent duration in German and a small typo in the existing one. Pull Request resolved: https://github.com/facebook/duckling/pull/509 Reviewed By: patapizza Differential Revision: D24690104 Pulled By: chessai fbshipit-source-id: b49a7a636abf5b92f2fe7c0d5b2ca2fe64acbaa2
This commit is contained in:
parent
eb043d7018
commit
e7264b55c9
97
Duckling/Duration/DE/Corpus.hs
Normal file
97
Duckling/Duration/DE/Corpus.hs
Normal file
@ -0,0 +1,97 @@
|
||||
-- Copyright (c) 2016-present, Facebook, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This source code is licensed under the BSD-style license found in the
|
||||
-- LICENSE file in the root directory of this source tree.
|
||||
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Duration.DE.Corpus
|
||||
( corpus
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Data.String
|
||||
|
||||
import Duckling.Duration.Types
|
||||
import Duckling.Locale
|
||||
import Duckling.Resolve
|
||||
import Duckling.Testing.Types
|
||||
import Duckling.TimeGrain.Types (Grain(..))
|
||||
|
||||
corpus :: Corpus
|
||||
corpus = (testContext {locale = makeLocale DE Nothing}, testOptions, allExamples)
|
||||
|
||||
allExamples :: [Example]
|
||||
allExamples = concat
|
||||
[ examples (DurationData 1 Second)
|
||||
[ "ein sekunde"
|
||||
, "zirka eine sekunde"
|
||||
]
|
||||
, examples (DurationData 30 Minute)
|
||||
[ "1/2 stunde"
|
||||
, "1/2stunde"
|
||||
, "eine halbe stunde"
|
||||
, "einer halben stunde"
|
||||
, "halbe stunde"
|
||||
, "halben stunde"
|
||||
, "ungefahr einer halben stunde"
|
||||
]
|
||||
, examples (DurationData 15 Minute)
|
||||
[ "einer Viertelstunde"
|
||||
, "eine viertelstunde"
|
||||
, "ViErTelStUnDe"
|
||||
, "genau viertelstunde"
|
||||
]
|
||||
, examples (DurationData 45 Minute)
|
||||
[ "3/4 stunde"
|
||||
, "3/4stunde"
|
||||
, "eine dreiviertel stunde"
|
||||
, "einer dreiviertel stunde"
|
||||
, "dreiviertel stunde"
|
||||
, "drei viertelstunden"
|
||||
]
|
||||
, examples (DurationData 92 Minute)
|
||||
[ "92 minuten"
|
||||
, "zweiundneunzig minuten"
|
||||
, "eine Stunde und zweiunddreißig Minuten"
|
||||
, "ein stunde und zweiunddreissig minuten"
|
||||
]
|
||||
, examples (DurationData 30 Day)
|
||||
[ "30 tage"
|
||||
, "dreißig tage"
|
||||
, "dreissig tage"
|
||||
]
|
||||
, examples (DurationData 7 Week)
|
||||
[ "7 Wochen"
|
||||
, "sieben wochen"
|
||||
]
|
||||
, examples (DurationData 90 Minute)
|
||||
[ "1,5 stunden"
|
||||
, "1,5 stunde"
|
||||
, "90 min"
|
||||
, "90min"
|
||||
]
|
||||
, examples (DurationData 75 Minute)
|
||||
[ "1,25 stunden"
|
||||
]
|
||||
, examples (DurationData 31719604 Second)
|
||||
[ "1 Jahr, 2 Tage, 3 Stunden und 4 Sekunden"
|
||||
, "1 Jahr 2 Tage 3 Stunden und 4 Sekunden"
|
||||
]
|
||||
, examples (DurationData 330 Second)
|
||||
[ "5 und eine halbe Minuten"
|
||||
, "5,5 min"
|
||||
]
|
||||
, examples (DurationData 330 Minute)
|
||||
[ "5 und eine halbe stunden"
|
||||
, "5,5 stunde"
|
||||
, "exakt 5,5 stunden"
|
||||
]
|
||||
, examples (DurationData 930 Second)
|
||||
[ "15,5 minuten"
|
||||
, "15,5 minute"
|
||||
, "15,5 min"
|
||||
]
|
||||
]
|
@ -6,131 +6,244 @@
|
||||
|
||||
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Duration.DE.Rules
|
||||
( rules ) where
|
||||
|
||||
import Control.Monad (join)
|
||||
import qualified Data.Text as Text
|
||||
import Prelude
|
||||
import Data.String
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers
|
||||
import Duckling.Numeral.Helpers (parseInteger)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import Duckling.Regex.Types
|
||||
import Control.Monad (join)
|
||||
import qualified Data.Text as Text
|
||||
import Prelude
|
||||
import Duckling.Numeral.Helpers (parseInteger)
|
||||
import Duckling.Duration.Types (DurationData(..))
|
||||
import qualified Duckling.Duration.Types as TDuration
|
||||
import Data.String
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import Duckling.Types
|
||||
|
||||
ruleQuarterOfAnHour :: Rule
|
||||
ruleQuarterOfAnHour = Rule
|
||||
{ name = "quarter of an hour"
|
||||
, pattern =
|
||||
[ regex "(einer? )?Viertelstunde"
|
||||
]
|
||||
, prod = \_ -> Just $ Token Duration $ duration TG.Minute 15
|
||||
}
|
||||
|
||||
ruleHalfAnHour :: Rule
|
||||
ruleHalfAnHour = Rule
|
||||
{ name = "half an hour"
|
||||
, pattern =
|
||||
[ regex "(1/2\\s?|(einer )halbe?n? )stunde"
|
||||
[ regex "(1/2\\s?|(eine )?halbe |(einer )?halben )stunde"
|
||||
]
|
||||
, prod = \_ -> Just . Token Duration $ duration TG.Minute 30
|
||||
, prod = \_ -> Just $ Token Duration $ duration TG.Minute 30
|
||||
}
|
||||
|
||||
ruleThreeQuartersOfAnHour :: Rule
|
||||
ruleThreeQuartersOfAnHour = Rule
|
||||
{ name = "three-quarters of an hour"
|
||||
, pattern =
|
||||
[ regex "3/4\\s?stunde|(einer? )?dreiviertel stunde|drei viertelstunden"
|
||||
]
|
||||
, prod = \_ -> Just $ Token Duration $ duration TG.Minute 45
|
||||
}
|
||||
|
||||
ruleFortnight :: Rule
|
||||
ruleFortnight = Rule
|
||||
{ name = "fortnight"
|
||||
, pattern =
|
||||
[ regex "(a|one)? fortnight"
|
||||
[ regex "zwei Wochen"
|
||||
]
|
||||
, prod = \_ -> Just . Token Duration $ duration TG.Day 14
|
||||
, prod = \_ -> Just $ Token Duration $ duration TG.Day 14
|
||||
}
|
||||
|
||||
ruleIntegerMoreUnitofduration :: Rule
|
||||
ruleIntegerMoreUnitofduration = Rule
|
||||
{ name = "<integer> more <unit-of-duration>"
|
||||
rulePrecision :: Rule
|
||||
rulePrecision = Rule
|
||||
{ name = "about|exactly <duration>"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, regex "mehr|weniger"
|
||||
, dimension TimeGrain
|
||||
[ regex "ungef(ä|a)hr|zirka|genau|exakt"
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:
|
||||
_:
|
||||
Token TimeGrain grain:
|
||||
_) -> Just . Token Duration . duration grain $ floor v
|
||||
, prod = \case
|
||||
(_:token:_) -> Just token
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleNumeralnumberHours :: Rule
|
||||
ruleNumeralnumberHours = Rule
|
||||
{ name = "number.number hours"
|
||||
ruleCommaNumeralHours :: Rule
|
||||
ruleCommaNumeralHours = Rule
|
||||
{ name = "number,number hours"
|
||||
, pattern =
|
||||
[ regex "(\\d+)\\.(\\d+) stunden?"
|
||||
[ regex "(\\d+),(\\d+)"
|
||||
, Predicate $ isGrain TG.Hour
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
, prod = \case
|
||||
(Token RegexMatch (GroupMatch (h:m:_)):_) -> do
|
||||
hh <- parseInteger h
|
||||
mnum <- parseInteger m
|
||||
let mden = 10 ^ Text.length m
|
||||
Just . Token Duration $ minutesFromHourMixedFraction hh mnum mden
|
||||
Just $ Token Duration $ minutesFromHourMixedFraction hh mnum mden
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleIntegerAndAnHalfHours :: Rule
|
||||
ruleIntegerAndAnHalfHours = Rule
|
||||
{ name = "<integer> and an half hours"
|
||||
ruleCommaNumeralMinutes :: Rule
|
||||
ruleCommaNumeralMinutes = Rule
|
||||
{ name = "number,number minutes"
|
||||
, pattern =
|
||||
[ regex "(\\d+),(\\d+)"
|
||||
, Predicate $ isGrain TG.Minute
|
||||
]
|
||||
, prod = \case
|
||||
(Token RegexMatch (GroupMatch (m:s:_)):_) -> do
|
||||
mm <- parseInteger m
|
||||
ss <- parseInteger s
|
||||
let sden = 10 ^ Text.length s
|
||||
Just $ Token Duration $ secondsFromHourMixedFraction mm ss sden
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleAndHalfHour :: Rule
|
||||
ruleAndHalfHour = Rule
|
||||
{ name = "<integer> and a half hour"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, regex "ein ?halb stunden?"
|
||||
, regex "(und )?(ein(en?)? )?halb(en?)?"
|
||||
, Predicate $ isGrain TG.Hour
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
, prod = \case
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:_) ->
|
||||
Just . Token Duration . duration TG.Minute $ 30 + 60 * floor v
|
||||
Just $ Token Duration $ duration TG.Minute $ 30 + 60 * floor v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleAUnitofduration :: Rule
|
||||
ruleAUnitofduration = Rule
|
||||
ruleAndHalfMinute :: Rule
|
||||
ruleAndHalfMinute = Rule
|
||||
{ name = "<integer> and a half minutes"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, regex "(und )?(ein(en?)? ?)?halb(en?)?"
|
||||
, Predicate $ isGrain TG.Minute
|
||||
]
|
||||
, prod = \case
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:_) ->
|
||||
Just $ Token Duration $ duration TG.Second $ 30 + 60 * floor v
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleArticle :: Rule
|
||||
ruleArticle = Rule
|
||||
{ name = "a <unit-of-duration>"
|
||||
, pattern =
|
||||
[ regex "eine?(r|n)?"
|
||||
[ regex "ein(en?)?"
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_) -> Just . Token Duration $ duration grain 1
|
||||
, prod = \case
|
||||
(_:Token TimeGrain grain:_) -> Just $ Token Duration $ duration grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleAboutDuration :: Rule
|
||||
ruleAboutDuration = Rule
|
||||
{ name = "about <duration>"
|
||||
ruleHalfTimeGrain :: Rule
|
||||
ruleHalfTimeGrain = Rule
|
||||
{ name = "half a <time-grain>"
|
||||
, pattern =
|
||||
[ regex "ungefähr|zirka"
|
||||
, dimension Duration
|
||||
[ regex "(ein(en)?)?(1/2|halbe?)"
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> Just token
|
||||
, prod = \case
|
||||
(_:Token TimeGrain grain:_) -> Token Duration <$> nPlusOneHalf grain 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleExactlyDuration :: Rule
|
||||
ruleExactlyDuration = Rule
|
||||
{ name = "exactly <duration>"
|
||||
ruleCompositeDurationCommasAnd :: Rule
|
||||
ruleCompositeDurationCommasAnd = Rule
|
||||
{ name = "composite <duration> (with ,/and)"
|
||||
, pattern =
|
||||
[ regex "genau|exakt"
|
||||
[ Predicate isNatural
|
||||
, dimension TimeGrain
|
||||
, regex ",|und"
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:token:_) -> Just token
|
||||
, prod = \case
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:
|
||||
Token TimeGrain g:
|
||||
_:
|
||||
Token Duration dd@DurationData{TDuration.grain = dg}:
|
||||
_) | g > dg -> Just $ Token Duration $ duration g (floor v) <> dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleCompositeDuration :: Rule
|
||||
ruleCompositeDuration = Rule
|
||||
{ name = "composite <duration>"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, dimension TimeGrain
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \case
|
||||
(Token Numeral NumeralData{TNumeral.value = v}:
|
||||
Token TimeGrain g:
|
||||
Token Duration dd@DurationData{TDuration.grain = dg}:
|
||||
_) | g > dg -> Just $ Token Duration $ duration g (floor v) <> dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleCompositeDurationAnd :: Rule
|
||||
ruleCompositeDurationAnd = Rule
|
||||
{ name = "composite <duration> and <duration>"
|
||||
, pattern =
|
||||
[ dimension Duration
|
||||
, regex ",|und"
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \case
|
||||
(Token Duration DurationData{TDuration.value = v, TDuration.grain = g}:
|
||||
_:
|
||||
Token Duration dd@DurationData{TDuration.grain = dg}:
|
||||
_) | g > dg -> Just $ Token Duration $ duration g v <> dd
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleHoursAndMinutes :: Rule
|
||||
ruleHoursAndMinutes = Rule
|
||||
{ name = "<integer> hour and <integer>"
|
||||
, pattern =
|
||||
[ Predicate isNatural
|
||||
, regex "(ein(en?) )?stunden?( und)?"
|
||||
, Predicate isNatural
|
||||
, Predicate $ isGrain TG.Minute
|
||||
]
|
||||
, prod = \case
|
||||
(Token Numeral h:
|
||||
_:
|
||||
Token Numeral m:
|
||||
_) -> Just $ Token Duration $ duration TG.Minute $
|
||||
floor (TNumeral.value m) + 60 * floor (TNumeral.value h)
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
rules :: [Rule]
|
||||
rules =
|
||||
[ ruleAUnitofduration
|
||||
, ruleAboutDuration
|
||||
, ruleExactlyDuration
|
||||
, ruleFortnight
|
||||
[ ruleQuarterOfAnHour
|
||||
, ruleHalfAnHour
|
||||
, ruleIntegerAndAnHalfHours
|
||||
, ruleIntegerMoreUnitofduration
|
||||
, ruleNumeralnumberHours
|
||||
, ruleThreeQuartersOfAnHour
|
||||
, rulePrecision
|
||||
, ruleCommaNumeralHours
|
||||
, ruleCommaNumeralMinutes
|
||||
, ruleFortnight
|
||||
, ruleAndHalfHour
|
||||
, ruleAndHalfMinute
|
||||
, ruleArticle
|
||||
, ruleHalfTimeGrain
|
||||
, ruleCompositeDurationCommasAnd
|
||||
, ruleCompositeDuration
|
||||
, ruleCompositeDurationAnd
|
||||
, ruleHoursAndMinutes
|
||||
, ruleAndHalfMinute
|
||||
]
|
||||
|
@ -15,14 +15,13 @@ module Duckling.Duration.EN.Rules
|
||||
) where
|
||||
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.String
|
||||
import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers
|
||||
import Duckling.Duration.Types (DurationData(..))
|
||||
import Duckling.Numeral.Helpers (parseInt, parseInteger)
|
||||
import Duckling.Numeral.Helpers (parseInteger)
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Types
|
||||
|
@ -89,7 +89,7 @@ ruleInteger3 :: Rule
|
||||
ruleInteger3 = Rule
|
||||
{ name = "integer ([2-9][1-9])"
|
||||
, pattern =
|
||||
[ regex "(ein|zwei|drei|vier|fünf|sechs|sieben|acht|neun)und(zwanzig|dreissig|vierzig|fünfzig|sechzig|siebzig|achtzig|neunzig)"
|
||||
[ regex "(ein|zwei|drei|vier|fünf|sechs|sieben|acht|neun)und(zwanzig|dreissig|dreißig|vierzig|fünfzig|sechzig|siebzig|achtzig|neunzig)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
|
||||
@ -107,6 +107,7 @@ ruleInteger3 = Rule
|
||||
v2 <- case Text.toLower m2 of
|
||||
"zwanzig" -> Just 20
|
||||
"dreissig" -> Just 30
|
||||
"dreißig" -> Just 30
|
||||
"vierzig" -> Just 40
|
||||
"fünfzig" -> Just 50
|
||||
"sechzig" -> Just 60
|
||||
@ -266,6 +267,7 @@ tensMap :: HashMap Text Integer
|
||||
tensMap = HashMap.fromList
|
||||
[ ( "zwanzig" , 20 )
|
||||
, ( "dreissig", 30 )
|
||||
, ( "dreißig" , 30 )
|
||||
, ( "vierzig" , 40 )
|
||||
, ( "fünfzig" , 50 )
|
||||
, ( "sechzig" , 60 )
|
||||
@ -279,7 +281,7 @@ ruleInteger2 :: Rule
|
||||
ruleInteger2 = Rule
|
||||
{ name = "integer (20..90)"
|
||||
, pattern =
|
||||
[ regex "(zwanzig|dreissig|vierzig|fünfzig|sechzig|siebzig|achtzig|neunzig)"
|
||||
[ regex "(zwanzig|dreissig|dreißig|vierzig|fünfzig|sechzig|siebzig|achtzig|neunzig)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) ->
|
||||
|
@ -224,12 +224,12 @@ classifiers
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("mm/dd",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.40546510810816444,
|
||||
ClassData{prior = -0.37729423114146804,
|
||||
unseen = -3.258096538021482,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 24},
|
||||
koData =
|
||||
ClassData{prior = -1.0986122886681098, unseen = -2.639057329615259,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 12}}),
|
||||
ClassData{prior = -1.157452788691043, unseen = -2.5649493574615367,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 11}}),
|
||||
("at <time-of-day>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.137201121513485, unseen = -4.3694478524670215,
|
||||
@ -474,13 +474,13 @@ classifiers
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("hour (grain)",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.15415067982725836,
|
||||
unseen = -2.0794415416798357,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 6},
|
||||
ClassData{prior = -0.2231435513142097,
|
||||
unseen = -2.3025850929940455,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 8},
|
||||
koData =
|
||||
ClassData{prior = -1.9459101490553135,
|
||||
unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 1}}),
|
||||
ClassData{prior = -1.6094379124341003,
|
||||
unseen = -1.3862943611198906,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 2}}),
|
||||
("Gr\252ndonnerstag",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.9459101490553135,
|
||||
@ -519,6 +519,17 @@ classifiers
|
||||
[("ordinal (digits)quarter (grain)", -0.916290731874155),
|
||||
("quarter", -0.916290731874155)],
|
||||
n = 1}}),
|
||||
("a <duration>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -infinity, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [], n = 0},
|
||||
koData =
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("half a <time-grain>", -0.6931471805599453),
|
||||
("minute", -0.6931471805599453)],
|
||||
n = 1}}),
|
||||
("Mai",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.0986122886681098,
|
||||
@ -533,6 +544,23 @@ classifiers
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("<integer> and a half hour",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -1.3862943611198906,
|
||||
unseen = -1.6094379124341003,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("integer (0..19)hour (grain)", -0.6931471805599453),
|
||||
("hour", -0.6931471805599453)],
|
||||
n = 1},
|
||||
koData =
|
||||
ClassData{prior = -0.2876820724517809,
|
||||
unseen = -2.1972245773362196,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("integer (0..19)hour (grain)", -0.6931471805599453),
|
||||
("hour", -0.6931471805599453)],
|
||||
n = 3}}),
|
||||
("intersect",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.11795690334351183,
|
||||
@ -947,13 +975,6 @@ classifiers
|
||||
[("week", -1.6094379124341003),
|
||||
("week (grain)", -1.6094379124341003)],
|
||||
n = 1}}),
|
||||
("number.number hours",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 1},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("Dreifaltigkeitssonntag",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.791759469228055,
|
||||
@ -1134,6 +1155,17 @@ classifiers
|
||||
("daymonth", -1.0986122886681098),
|
||||
("ordinal (1..31)DienstagSeptember", -1.791759469228055)],
|
||||
n = 3}}),
|
||||
("half a <time-grain>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -infinity, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [], n = 0},
|
||||
koData =
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("hour (grain)", -0.6931471805599453),
|
||||
("hour", -0.6931471805599453)],
|
||||
n = 1}}),
|
||||
("the <day-of-month> (non ordinal)",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
@ -1619,6 +1651,17 @@ classifiers
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("number,number hours",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("hour (grain)", -0.6931471805599453),
|
||||
("hour", -0.6931471805599453)],
|
||||
n = 1},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("Guru Gobind Singh Jayanti",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
@ -1711,21 +1754,14 @@ classifiers
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("a <unit-of-duration>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -3.1354942159291497,
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("week", -1.9924301646902063),
|
||||
("hour (grain)", -2.3978952727983707),
|
||||
("year (grain)", -2.3978952727983707),
|
||||
("second", -2.3978952727983707),
|
||||
("week (grain)", -1.9924301646902063),
|
||||
("minute (grain)", -2.3978952727983707),
|
||||
("year", -2.3978952727983707),
|
||||
("second (grain)", -2.3978952727983707),
|
||||
("hour", -2.3978952727983707), ("minute", -2.3978952727983707)],
|
||||
n = 6},
|
||||
[("year (grain)", -0.6931471805599453),
|
||||
("year", -0.6931471805599453)],
|
||||
n = 1},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -2.3978952727983707,
|
||||
ClassData{prior = -infinity, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("Dhanteras",
|
||||
Classifier{okData =
|
||||
@ -1939,18 +1975,23 @@ classifiers
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 3}}),
|
||||
("<duration> ago",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -3.1354942159291497,
|
||||
ClassData{prior = -0.13353139262452263,
|
||||
unseen = -3.044522437723423,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("week", -1.4816045409242156), ("day", -1.9924301646902063),
|
||||
("year", -2.3978952727983707),
|
||||
("<integer> <unit-of-duration>", -1.0116009116784799),
|
||||
("a <unit-of-duration>", -2.3978952727983707),
|
||||
("month", -2.3978952727983707)],
|
||||
n = 8},
|
||||
[("week", -1.6094379124341003), ("day", -1.8971199848858813),
|
||||
("year", -2.3025850929940455),
|
||||
("<integer> <unit-of-duration>", -0.916290731874155),
|
||||
("month", -2.3025850929940455)],
|
||||
n = 7},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -1.9459101490553135,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
ClassData{prior = -2.0794415416798357,
|
||||
unseen = -2.1972245773362196,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("day", -1.3862943611198906),
|
||||
("fortnight", -1.3862943611198906)],
|
||||
n = 1}}),
|
||||
("last <time>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -2.0794415416798357,
|
||||
@ -2026,13 +2067,6 @@ classifiers
|
||||
-3.0910424533583156),
|
||||
("minute", -2.174751721484161)],
|
||||
n = 14}}),
|
||||
("<integer> and an half hours",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [("integer (0..19)", 0.0)], n = 1},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("Isra and Mi'raj",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.791759469228055,
|
||||
@ -2061,6 +2095,13 @@ classifiers
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("decimal number",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0},
|
||||
koData =
|
||||
ClassData{prior = 0.0, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 1}}),
|
||||
("Aschermontag",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
@ -2170,6 +2211,21 @@ classifiers
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -3.1354942159291497,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("about|exactly <duration>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.6931471805599453, unseen = -1.791759469228055,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("half an hour", -0.916290731874155),
|
||||
("minute", -0.916290731874155)],
|
||||
n = 1},
|
||||
koData =
|
||||
ClassData{prior = -0.6931471805599453, unseen = -1.791759469228055,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("<integer> and a half hour", -0.916290731874155),
|
||||
("minute", -0.916290731874155)],
|
||||
n = 1}}),
|
||||
("Purim",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.6931471805599453,
|
||||
@ -2193,23 +2249,29 @@ classifiers
|
||||
n = 4}}),
|
||||
("in <duration>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -4.07753744390572,
|
||||
ClassData{prior = -0.10008345855698253,
|
||||
unseen = -3.912023005428146,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("week", -2.6741486494265287),
|
||||
("number.number hours", -3.367295829986474),
|
||||
("second", -2.9618307218783095), ("day", -2.9618307218783095),
|
||||
("half an hour", -3.367295829986474),
|
||||
("year", -3.367295829986474),
|
||||
("<integer> <unit-of-duration>", -1.2878542883066382),
|
||||
("a <unit-of-duration>", -2.451005098112319),
|
||||
("<integer> and an half hours", -3.367295829986474),
|
||||
("hour", -2.268683541318364), ("minute", -1.6625477377480489),
|
||||
("about <duration>", -3.367295829986474)],
|
||||
n = 23},
|
||||
[("week", -2.793208009442517),
|
||||
("<integer> and a half hour", -3.1986731175506815),
|
||||
("second", -3.1986731175506815), ("day", -2.793208009442517),
|
||||
("half an hour", -3.1986731175506815),
|
||||
("year", -3.1986731175506815),
|
||||
("<integer> <unit-of-duration>", -1.1192315758708455),
|
||||
("number,number hours", -3.1986731175506815),
|
||||
("hour", -2.2823823856765264),
|
||||
("about|exactly <duration>", -3.1986731175506815),
|
||||
("minute", -1.589235205116581)],
|
||||
n = 19},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -2.5649493574615367,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
ClassData{prior = -2.3513752571634776, unseen = -2.772588722239781,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("<integer> and a half hour", -2.0149030205422647),
|
||||
("about|exactly <duration>", -2.0149030205422647),
|
||||
("minute", -1.6094379124341003)],
|
||||
n = 2}}),
|
||||
("<datetime> - <datetime> (interval)",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -0.9694005571881036, unseen = -4.189654742026425,
|
||||
@ -2248,6 +2310,13 @@ classifiers
|
||||
("dayminute", -2.0476928433652555),
|
||||
("<day-of-month> (ordinal)mm/dd/yyyy", -3.4339872044851463)],
|
||||
n = 36}}),
|
||||
("fortnight",
|
||||
Classifier{okData =
|
||||
ClassData{prior = -infinity, unseen = -0.6931471805599453,
|
||||
likelihoods = HashMap.fromList [], n = 0},
|
||||
koData =
|
||||
ClassData{prior = 0.0, unseen = -1.3862943611198906,
|
||||
likelihoods = HashMap.fromList [("", 0.0)], n = 2}}),
|
||||
("Orthodoxer Ostersonntag",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.0986122886681098,
|
||||
@ -2586,17 +2655,6 @@ classifiers
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("about <duration>",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -1.6094379124341003,
|
||||
likelihoods =
|
||||
HashMap.fromList
|
||||
[("half an hour", -0.6931471805599453),
|
||||
("minute", -0.6931471805599453)],
|
||||
n = 1},
|
||||
koData =
|
||||
ClassData{prior = -infinity, unseen = -1.0986122886681098,
|
||||
likelihoods = HashMap.fromList [], n = 0}}),
|
||||
("Eid al-Fitr",
|
||||
Classifier{okData =
|
||||
ClassData{prior = 0.0, unseen = -2.1972245773362196,
|
||||
|
@ -352,7 +352,7 @@ allExamples = concat
|
||||
, "in 30 minuten"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 7, 0, 0) Second)
|
||||
[ "in 2.5 stunden"
|
||||
[ "in 2,5 stunden"
|
||||
, "in zwei ein halb stunden"
|
||||
]
|
||||
, examples (datetime (2013, 2, 12, 5, 30, 0) Minute)
|
||||
|
@ -21,7 +21,7 @@ import Duckling.Types
|
||||
|
||||
grains :: [(Text, String, TG.Grain)]
|
||||
grains = [ ("second (grain)", "sekunden?", TG.Second)
|
||||
, ("minute (grain)", "minuten?", TG.Minute)
|
||||
, ("minute (grain)", "min(uten?)?", TG.Minute)
|
||||
, ("hour (grain)", "stunden?", TG.Hour)
|
||||
, ("day (grain)", "tage?n?", TG.Day)
|
||||
, ("week (grain)", "wochen?", TG.Week)
|
||||
|
22
tests/Duckling/Duration/DE/Tests.hs
Normal file
22
tests/Duckling/Duration/DE/Tests.hs
Normal file
@ -0,0 +1,22 @@
|
||||
-- Copyright (c) 2016-present, Facebook, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This source code is licensed under the BSD-style license found in the
|
||||
-- LICENSE file in the root directory of this source tree.
|
||||
|
||||
|
||||
module Duckling.Duration.DE.Tests
|
||||
( tests
|
||||
) where
|
||||
|
||||
import Data.String
|
||||
import Test.Tasty
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.DE.Corpus
|
||||
import Duckling.Testing.Asserts
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "ES Tests"
|
||||
[ makeCorpusTest [Seal Duration] corpus
|
||||
]
|
Loading…
Reference in New Issue
Block a user