Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #249 (wrong parsing of yyyy-mm-dd dates in DE) #282

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Duckling/Time/DE/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Duckling.Time.DE.Corpus

import Data.String
import Prelude
import Data.Time

import Duckling.Locale
import Duckling.Resolve
Expand All @@ -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"
Expand Down Expand Up @@ -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"
]
Expand Down Expand Up @@ -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
]
4 changes: 2 additions & 2 deletions Duckling/Time/DE/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down