From 12b3f025dd4271d17b8924b468919a061a16846d Mon Sep 17 00:00:00 2001 From: Martin Heuschober Date: Sat, 17 Nov 2018 17:42:24 +0100 Subject: [PATCH] fix issue #249 (wrong parsing of yyyy-mm-dd dates in DE) - took regex from EN (which is working) - added test cases from 2016-01-01 to 2018-12-31 - change non-breaking space to regular space --- Duckling/Time/DE/Corpus.hs | 9 +++++++-- Duckling/Time/DE/Rules.hs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Duckling/Time/DE/Corpus.hs b/Duckling/Time/DE/Corpus.hs index 23ad818b7..68ea36cac 100644 --- a/Duckling/Time/DE/Corpus.hs +++ b/Duckling/Time/DE/Corpus.hs @@ -15,6 +15,7 @@ module Duckling.Time.DE.Corpus import Data.String import Prelude +import Data.Time import Duckling.Locale import Duckling.Resolve @@ -36,7 +37,7 @@ negativeCorpus = (testContext {locale = makeLocale DE Nothing}, testOptions, exa ] allExamples :: [Example] -allExamples = concat +allExamples = concat $ [ examples (datetime (2013, 2, 12, 4, 30, 0) Second) [ "jetzt" , "genau jetzt" @@ -631,7 +632,7 @@ allExamples = concat , examples (datetime (2013, 12, 10, 0, 0, 0) Day) [ "10.12." ] -  , examples (datetimeInterval ((2013, 2, 12, 18, 30, 0), (2013, 2, 12, 19, 1, 0)) Minute) + , examples (datetimeInterval ((2013, 2, 12, 18, 30, 0), (2013, 2, 12, 19, 1, 0)) Minute) [ "18:30h - 19:00h" , "18:30h/19:00h" ] @@ -666,4 +667,8 @@ allExamples = concat , examples (datetime (2013, 2, 12, 17, 10, 0) Minute) [ "17h10" ] + ]++ + [ examples (datetime (yyyy, mm, dd, 0, 0, 0) Day) [fromString $ show day] + | day <- [fromGregorian 2016 1 1..fromGregorian 2018 12 31] + , let (yyyy,mm,dd) = toGregorian day ] diff --git a/Duckling/Time/DE/Rules.hs b/Duckling/Time/DE/Rules.hs index 34df3fb38..9a9c586fe 100644 --- a/Duckling/Time/DE/Rules.hs +++ b/Duckling/Time/DE/Rules.hs @@ -20,7 +20,7 @@ import qualified Data.Text as Text import Duckling.Dimensions.Types import Duckling.Numeral.Helpers (parseInt) import Duckling.Ordinal.Types (OrdinalData (..)) -import Duckling.Regex.Types +import Duckling.Regex.Types (GroupMatch(..)) import Duckling.Time.Helpers import Duckling.Time.Types (TimeData (..)) import Duckling.Types @@ -1050,7 +1050,7 @@ ruleYyyymmdd :: Rule ruleYyyymmdd = Rule { name = "yyyy-mm-dd" , pattern = - [ regex "(\\d{2,4})-(0?[1-9]|10|11|12)-([012]?[1-9]|10|20|30|31)" + [ regex "(\\d{2,4})-(0?[1-9]|1[0-2])-(3[01]|[12]\\d|0?[1-9])" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (m1:m2:m3:_)):_) -> do