-- 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.Time.SV.Corpus
  ( corpus
  ) where

import Data.String
import Prelude

import Duckling.Locale
import Duckling.Resolve
import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.Time.Types hiding (Month)
import Duckling.TimeGrain.Types hiding (add)

corpus :: Corpus
corpus = (testContext {locale = makeLocale SV Nothing}, testOptions, allExamples)

allExamples :: [Example]
allExamples = concat
  [ examples (datetime (2013, 2, 12, 4, 30, 0) Second)
             [ "nu"
             , "just nu"
             ]
  , examples (datetime (2013, 2, 12, 0, 0, 0) Day)
             [ "idag"
             ]
  , examples (datetime (2013, 2, 11, 0, 0, 0) Day)
             [ "igÃ¥r"
             ]
  , examples (datetime (2013, 2, 13, 0, 0, 0) Day)
             [ "imorgon"
             , "i morgon"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Day)
             [ "mÃ¥ndag"
             , "mÃ¥n"
             , "pÃ¥ mÃ¥ndag"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Day)
             [ "MÃ¥ndag den 18 februari"
             , "MÃ¥n, 18 februari"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "tisdag"
             ]
  , examples (datetime (2013, 2, 14, 0, 0, 0) Day)
             [ "torsdag"
             , "tors"
             , "tors."
             ]
  , examples (datetime (2013, 2, 15, 0, 0, 0) Day)
             [ "fredag"
             , "fre"
             , "fre."
             ]
  , examples (datetime (2013, 2, 16, 0, 0, 0) Day)
             [ "lÃ¶rdag"
             , "lÃ¶r"
             , "lÃ¶r."
             ]
  , examples (datetime (2013, 2, 17, 0, 0, 0) Day)
             [ "sÃ¶ndag"
             , "sÃ¶n"
             , "sÃ¶n."
             ]
  , examples (datetime (2013, 3, 1, 0, 0, 0) Day)
             [ "Den fÃ¶rste mars"
             , "Den fÃ¶rsta mars"
             , "1:a mars"
             , "Den 1:a mars"
             ]
  , examples (datetime (2013, 3, 3, 0, 0, 0) Day)
             [ "3 mars"
             , "den tredje mars"
             , "den 3:e mars"
             ]
  , examples (datetime (2015, 3, 3, 0, 0, 0) Day)
             [ "3 mars 2015"
             , "tredje mars 2015"
             , "3:e mars 2015"
             , "3-3-2015"
             , "03-03-2015"
             , "3/3/2015"
             , "3/3/15"
             , "2015-3-3"
             , "2015-03-03"
             ]
  , examples (datetime (2013, 2, 15, 0, 0, 0) Day)
             [ "PÃ¥ den 15:e"
             , "PÃ¥ den 15"
             , "Den 15:e"
             ]
  , examples (datetime (2013, 2, 15, 0, 0, 0) Day)
             [ "den 15:e februari"
             , "15:e februari"
             , "februari 15"
             , "15-02"
             , "15/02"
             ]
  , examples (datetime (2013, 8, 8, 0, 0, 0) Day)
             [ "8 Aug"
             ]
  , examples (datetime (2014, 10, 0, 0, 0, 0) Month)
             [ "Oktober 2014"
             ]
  , examples (datetime (1974, 10, 31, 0, 0, 0) Day)
             [ "31/10/1974"
             , "31/10/74"
             , "31-10-74"
             ]
  , examples (datetime (2015, 4, 14, 0, 0, 0) Day)
             [ "14april 2015"
             , "April 14, 2015"
             , "fjortonde April 15"
             ]
  , examples (datetime (2013, 2, 22, 0, 0, 0) Day)
             [ "nÃ¤sta fredag igen"
             ]
  , examples (datetime (2013, 3, 0, 0, 0, 0) Month)
             [ "nÃ¤sta mars"
             ]
  , examples (datetime (2014, 3, 0, 0, 0, 0) Month)
             [ "nÃ¤sta mars igen"
             ]
  , examples (datetime (2013, 2, 10, 0, 0, 0) Day)
             [ "SÃ¶ndag, 10 feb"
             , "SÃ¶ndag 10 Feb"
             ]
  , examples (datetime (2013, 2, 13, 0, 0, 0) Day)
             [ "Ons, Feb13"
             , "Ons feb13"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Day)
             [ "MÃ¥ndag, Feb 18"
             , "MÃ¥n, februari 18"
             ]
  , examples (datetime (2013, 2, 11, 0, 0, 0) Week)
             [ "denna vecka"
             ]
  , examples (datetime (2013, 2, 4, 0, 0, 0) Week)
             [ "fÃ¶rra vecka"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Week)
             [ "nÃ¤sta vecka"
             ]
  , examples (datetime (2013, 1, 0, 0, 0, 0) Month)
             [ "fÃ¶rra mÃ¥nad"
             ]
  , examples (datetime (2013, 3, 0, 0, 0, 0) Month)
             [ "nÃ¤sta mÃ¥nad"
             ]
  , examples (datetime (2013, 1, 1, 0, 0, 0) Quarter)
             [ "detta kvartal"
             ]
  , examples (datetime (2013, 4, 1, 0, 0, 0) Quarter)
             [ "nÃ¤sta kvartal"
             ]
  , examples (datetime (2013, 7, 1, 0, 0, 0) Quarter)
             [ "tredje kvartalet"
             , "3:e kvartal"
             ]
  , examples (datetime (2018, 10, 1, 0, 0, 0) Quarter)
             [ "4:e kvartal 2018"
             , "fjÃ¤rde kvartalet 2018"
             ]
  , examples (datetime (2012, 1, 1, 0, 0, 0) Year)
             [ "fÃ¶rra Ã¥r"
             , "fÃ¶rra Ã¥ret"
             , "fÃ¶regÃ¥ende Ã¥r"
             ]
  , examples (datetime (2012, 1, 1, 0, 0, 0) Year)
             [ "i fjol"
             ]
  , examples (datetime (2013, 1, 1, 0, 0, 0) Year)
             [ "i Ã¥r"
             , "detta Ã¥r"
             ]
  , examples (datetime (2014, 1, 1, 0, 0, 0) Year)
             [ "nÃ¤sta Ã¥r"
             ]
  , examples (datetime (2013, 2, 10, 0, 0, 0) Day)
             [ "fÃ¶rra sÃ¶ndag"
             , "sÃ¶ndag i fÃ¶rra veckan"
             , "sÃ¶ndag fÃ¶rra veckan"
             ]
  , examples (datetime (2013, 2, 5, 0, 0, 0) Day)
             [ "fÃ¶rra tisdag"
             , "i tisdags"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "nÃ¤sta tisdag"
             ]
  , examples (datetime (2013, 2, 13, 0, 0, 0) Day)
             [ "nÃ¤sta onsdag"
             ]
  , examples (datetime (2013, 2, 20, 0, 0, 0) Day)
             [ "onsdag i nÃ¤sta vecka"
             , "onsdag nÃ¤sta vecka"
             , "nÃ¤sta onsdag igen"
             ]
  , examples (datetime (2013, 2, 22, 0, 0, 0) Day)
             [ "nÃ¤sta fredag igen"
             ]
  , examples (datetime (2013, 2, 11, 0, 0, 0) Day)
             [ "mÃ¥ndag denna veckan"
             ]
  , examples (datetime (2013, 2, 12, 0, 0, 0) Day)
             [ "tisdag denna vecka"
             ]
  , examples (datetime (2013, 2, 13, 0, 0, 0) Day)
             [ "onsdag denna vecka"
             ]
  , examples (datetime (2013, 2, 14, 0, 0, 0) Day)
             [ "i Ã¶verimorgon"
             ]
  , examples (datetime (2013, 2, 10, 0, 0, 0) Day)
             [ "i fÃ¶rrgÃ¥r"
             ]
  , examples (datetime (2013, 3, 25, 0, 0, 0) Day)
             [ "sista mÃ¥ndag i mars"
             ]
  , examples (datetime (2014, 3, 30, 0, 0, 0) Day)
             [ "sista sÃ¶ndag i mars 2014"
             ]
  , examples (datetime (2013, 10, 3, 0, 0, 0) Day)
             [ "tredje dagen i oktober"
             , "tredje dagen i Oktober"
             ]
  , examples (datetime (2014, 10, 6, 0, 0, 0) Week)
             [ "fÃ¶rsta veckan i oktober 2014"
             , "fÃ¶rsta veckan i Oktober 2014"
             ]
  , examples (datetime (2015, 10, 31, 0, 0, 0) Day)
             [ "sista dagen i oktober 2015"
             , "sista dagen i Oktober 2015"
             ]
  , examples (datetime (2014, 9, 22, 0, 0, 0) Week)
             [ "sista veckan i september 2014"
             , "sista veckan i September 2014"
             ]
  , examples (datetime (2013, 10, 1, 0, 0, 0) Day)
             [ "fÃ¶rsta tisdag i oktober"
             , "fÃ¶rsta tisdagen i Oktober"
             ]
  , examples (datetime (2014, 9, 16, 0, 0, 0) Day)
             [ "tredje tisdagen i september 2014"
             , "tredje tisdagen i September 2014"
             ]
  , examples (datetime (2014, 10, 1, 0, 0, 0) Day)
             [ "fÃ¶rsta onsdagen i oktober 2014"
             , "fÃ¶rsta onsdagen i Oktober 2014"
             ]
  , examples (datetime (2014, 10, 8, 0, 0, 0) Day)
             [ "andra onsdagen i oktober 2014"
             , "andra onsdagen i Oktober 2014"
             ]
  , examples (datetime (2013, 2, 13, 3, 0, 0) Hour)
             [ "klockan 3"
             , "kl. 3"
             ]
  , examples (datetime (2013, 2, 13, 3, 18, 0) Minute)
             [ "3:18"
             ]
  , examples (datetime (2013, 2, 12, 15, 0, 0) Hour)
             [ "klockan 15"
             , "kl. 15"
             , "15h"
             ]
  , examples (datetime (2013, 2, 12, 15, 0, 0) Hour)
             [ "ca. kl. 15"
             , "cirka kl. 15"
             , "omkring klockan 15"
             ]
  , examples (datetime (2013, 2, 13, 17, 0, 0) Hour)
             [ "imorgon klockan 17 exakt"
             , "imorgon kl. 17 precis"
             ]
  , examples (datetime (2013, 2, 12, 15, 15, 0) Minute)
             [ "kvart Ã¶ver 15"
             , "15:15"
             ]
  , examples (datetime (2013, 2, 12, 15, 20, 0) Minute)
             [ "kl. 20 Ã¶ver 15"
             , "klockan 20 Ã¶ver 15"
             , "tjugo Ã¶ver 15"
             , "kl. 15:20"
             , "15:20"
             ]
  , examples (datetime (2013, 2, 12, 15, 30, 0) Minute)
             [ "15:30"
             ]
  , examples (datetime (2013, 2, 12, 15, 23, 24) Second)
             [ "15:23:24"
             ]
  , examples (datetime (2013, 2, 12, 11, 45, 0) Minute)
             [ "kvart i 12"
             , "kvart i tolv"
             , "11:45"
             ]
  , examples (datetime (2013, 2, 16, 9, 0, 0) Hour)
             [ "klockan 9 pÃ¥ lÃ¶rdag"
             ]
  , examples (datetime (2014, 7, 18, 19, 0, 0) Minute)
             [ "Fre, Jul 18, 2014 19:00"
             ]
  , examples (datetime (2014, 7, 18, 0, 0, 0) Day)
             [ "Fre, Jul 18"
             , "Jul 18, Fre"
             ]
  , examples (datetime (2014, 9, 20, 19, 30, 0) Minute)
             [ "kl. 19:30, LÃ¶r, 20 sep"
             ]
  , examples (datetime (2013, 2, 12, 4, 30, 1) Second)
             [ "om 1 sekund"
             , "om en sekund"
             , "en sekund frÃ¥n nu"
             ]
  , examples (datetime (2013, 2, 12, 4, 31, 0) Second)
             [ "om 1 minut"
             , "om en minut"
             ]
  , examples (datetime (2013, 2, 12, 4, 32, 0) Second)
             [ "om 2 minuter"
             , "om tvÃ¥ minuter"
             , "om 2 minuter mer"
             , "om tvÃ¥ minuter mer"
             --, "2 minuter frÃ¥n nu" t14892978
             , "tvÃ¥ minuter frÃ¥n nu"
             ]
  , examples (datetime (2013, 2, 12, 5, 30, 0) Second)
             [ "om 60 minuter"
             ]
  , examples (datetime (2013, 2, 12, 5, 0, 0) Second)
             [ "om en halv timme"
             ]
  , examples (datetime (2013, 2, 12, 7, 0, 0) Second)
             [ "om 2,5 timme"
             , "om 2 och en halv timme"
             , "om tvÃ¥ och en halv timme"
             ]
  , examples (datetime (2013, 2, 12, 5, 30, 0) Minute)
             [ "om en timme"
             , "om 1 timme"
             , "om 1t"
             ]
  , examples (datetime (2013, 2, 12, 6, 30, 0) Minute)
             [ "om ett par timmar"
             ]
  , examples (datetime (2013, 2, 13, 4, 30, 0) Minute)
             [ "om 24 timmar"
             , "2013-02-13 kl. 4:30"
             , "2013-02-13 kl 04:30"
             ]
  , examples (datetime (2013, 2, 13, 4, 0, 0) Hour)
             [ "om en dag"
             ]
  , examples (datetime (2016, 2, 0, 0, 0, 0) Month)
             [ -- "3 Ã¥r frÃ¥n idag" t14892978
             ]
  , examples (datetime (2013, 2, 19, 4, 0, 0) Hour)
             [ "om 7 dagar"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "om en vecka"
             ]
  , examples (datetime (2013, 2, 12, 5, 0, 0) Second)
             [ "om ca. en halv timme"
             , "om cirka en halv timme"
             ]
  , examples (datetime (2013, 2, 5, 4, 0, 0) Hour)
             [ "7 dagar sedan"
             , "sju dagar sedan"
             ]
  , examples (datetime (2013, 1, 29, 4, 0, 0) Hour)
             [ "14 dagar sedan"
             , "fjorton dagar sedan"
             ]
  , examples (datetime (2013, 2, 5, 0, 0, 0) Day)
             [ "en vecka sedan"
             , "1 vecka sedan"
             ]
  , examples (datetime (2013, 1, 22, 0, 0, 0) Day)
             [ "3 veckor sedan"
             , "tre veckor sedan"
             ]
  , examples (datetime (2012, 11, 12, 0, 0, 0) Day)
             [ "3 mÃ¥nader sedan"
             , "tre mÃ¥nader sedan"
             ]
  , examples (datetime (2011, 2, 0, 0, 0, 0) Month)
             [ "tvÃ¥ Ã¥r sedan"
             , "2 Ã¥r sedan"
             ]
  , examples (datetime (1954, 0, 0, 0, 0, 0) Year)
             [ "1954"
             ]
  , examples (datetimeInterval ((2013, 6, 21, 0, 0, 0), (2013, 9, 24, 0, 0, 0)) Day)
             [ "denna sommaren"
             , "den hÃ¤r sommaren"
             ]
  , examples (datetimeInterval ((2012, 12, 21, 0, 0, 0), (2013, 3, 21, 0, 0, 0)) Day)
             [ "denna vintern"
             , "den hÃ¤r vintern"
             ]
  , examples (datetime (2013, 12, 25, 0, 0, 0) Day)
             [ "juldagen"
             ]
  , examples (datetime (2013, 12, 31, 0, 0, 0) Day)
             [ "nyÃ¥rsafton"
             ]
  , examples (datetime (2014, 1, 1, 0, 0, 0) Day)
             [ "nyÃ¥rsdagen"
             , "nyÃ¥rsdag"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 18, 0, 0), (2013, 2, 13, 0, 0, 0)) Hour)
             [ "ikvÃ¤ll"
             ]
  , examples (datetimeInterval ((2013, 2, 8, 18, 0, 0), (2013, 2, 11, 0, 0, 0)) Hour)
             [ "fÃ¶rra helg"
             ]
  , examples (datetimeInterval ((2013, 2, 13, 18, 0, 0), (2013, 2, 14, 0, 0, 0)) Hour)
             [ "imorgon kvÃ¤ll"
             ]
  , examples (datetimeInterval ((2013, 2, 13, 12, 0, 0), (2013, 2, 13, 14, 0, 0)) Hour)
             [ "imorgon lunch"
             ]
  , examples (datetimeInterval ((2013, 2, 11, 18, 0, 0), (2013, 2, 12, 0, 0, 0)) Hour)
             [ "igÃ¥r kvÃ¤ll"
             ]
  , examples (datetimeInterval ((2013, 2, 15, 18, 0, 0), (2013, 2, 18, 0, 0, 0)) Hour)
             [ "denna helgen"
             , "denna helg"
             , "i helgen"
             ]
  , examples (datetimeInterval ((2013, 2, 18, 4, 0, 0), (2013, 2, 18, 12, 0, 0)) Hour)
             [ "mÃ¥ndag morgon"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 29, 58), (2013, 2, 12, 4, 30, 0)) Second)
             [ "senaste 2 sekunder"
             , "senaste tvÃ¥ sekunderna"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 30, 1), (2013, 2, 12, 4, 30, 4)) Second)
             [ "nÃ¤sta 3 sekunder"
             , "nÃ¤sta tre sekunder"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 28, 0), (2013, 2, 12, 4, 30, 0)) Minute)
             [ "senaste 2 minuter"
             , "senaste tvÃ¥ minuter"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 31, 0), (2013, 2, 12, 4, 34, 0)) Minute)
             [ "nÃ¤sta 3 minuter"
             , "nÃ¤sta tre minuter"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 3, 0, 0), (2013, 2, 12, 4, 0, 0)) Hour)
             [ "senaste 1 timme"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 5, 0, 0), (2013, 2, 12, 8, 0, 0)) Hour)
             [ "nÃ¤sta 3 timmar"
             , "nÃ¤sta tre timmar"
             ]
  , examples (datetimeInterval ((2013, 2, 10, 0, 0, 0), (2013, 2, 12, 0, 0, 0)) Day)
             [ "senaste 2 dagar"
             , "senaste tvÃ¥ dagar"
             , "senaste 2 dagar"
             ]
  , examples (datetimeInterval ((2013, 2, 13, 0, 0, 0), (2013, 2, 16, 0, 0, 0)) Day)
             [ "nÃ¤sta 3 dagar"
             , "nÃ¤sta tre dagar"
             ]
  , examples (datetimeInterval ((2013, 1, 28, 0, 0, 0), (2013, 2, 11, 0, 0, 0)) Week)
             [ "senaste 2 veckor"
             , "senaste tvÃ¥ veckorna"
             , "senaste tvÃ¥ veckor"
             ]
  , examples (datetimeInterval ((2013, 2, 18, 0, 0, 0), (2013, 3, 11, 0, 0, 0)) Week)
             [ "nÃ¤sta 3 veckor"
             , "nÃ¤sta tre veckorna"
             ]
  , examples (datetimeInterval ((2012, 12, 0, 0, 0, 0), (2013, 2, 0, 0, 0, 0)) Month)
             [ "senaste 2 mÃ¥nader"
             , "senaste tvÃ¥ mÃ¥nader"
             , "senaste tvÃ¥ mÃ¥nader"
             ]
  , examples (datetimeInterval ((2013, 3, 0, 0, 0, 0), (2013, 6, 0, 0, 0, 0)) Month)
             [ "nÃ¤sta 3 mÃ¥nader"
             , "nÃ¤sta tre mÃ¥nader"
             ]
  , examples (datetimeInterval ((2011, 0, 0, 0, 0, 0), (2013, 0, 0, 0, 0, 0)) Year)
             [ "senaste 2 Ã¥r"
             , "senaste tvÃ¥ Ã¥r"
             , "senaste 2 Ã¥r"
             ]
  , examples (datetimeInterval ((2014, 0, 0, 0, 0, 0), (2017, 0, 0, 0, 0, 0)) Year)
             [ "nÃ¤sta 3 Ã¥r"
             , "nÃ¤sta tre Ã¥r"
             ]
  , examples (datetimeInterval ((2013, 7, 13, 0, 0, 0), (2013, 7, 16, 0, 0, 0)) Day)
             [ "13-15 juli"
             , "13-15 Juli"
             , "13 till 15 Juli"
             , "13 juli till 15 juli"
             ]
  , examples (datetimeInterval ((2013, 8, 8, 0, 0, 0), (2013, 8, 13, 0, 0, 0)) Day)
             [ "8 Aug - 12 Aug"
             , "8 Aug - 12 aug"
             , "8 aug - 12 aug"
             , "8 augusti - 12 augusti"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 9, 30, 0), (2013, 2, 12, 11, 1, 0)) Minute)
             [ "9:30 - 11:00"
             , "9:30 till 11:00"
             ]
  , examples (datetimeInterval ((2013, 2, 14, 9, 30, 0), (2013, 2, 14, 11, 1, 0)) Minute)
             [ "frÃ¥n 9:30 - 11:00 pÃ¥ torsdag"
             , "frÃ¥n 9:30 till 11:00 pÃ¥ torsdag"
             , "mellan 9:30 och 11:00 pÃ¥ torsdag"
             , "9:30 - 11:00 pÃ¥ torsdag"
             , "9:30 till 11:00 pÃ¥ torsdag"
             , "efter 9:30 men fÃ¶re 11:00 pÃ¥ torsdag"
             , "torsdag frÃ¥n 9:30 till 11:00"
             , "torsdag mellan 9:30 och 11:00"
             , "frÃ¥n 9:30 till 11:00 pÃ¥ torsdag"
             ]
  , examples (datetimeInterval ((2013, 2, 14, 9, 0, 0), (2013, 2, 14, 12, 0, 0)) Hour)
             [ "torsdag frÃ¥n 9 till 11"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 11, 30, 0), (2013, 2, 12, 13, 31, 0)) Minute)
             [ "11:30-13:30"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 30, 0), (2013, 2, 26, 0, 0, 0)) Second)
             [ "inom 2 veckor"
             ]
  , examples (datetimeOpenInterval Before (2013, 2, 12, 14, 0, 0) Hour)
             [ "innan kl. 14"
             , "innan klockan 14"
             ]
  , examples (datetime (2013, 2, 12, 13, 0, 0) Minute)
             [ "@ 16 CET"
             , "kl. 16 CET"
             , "klockan 16 CET"
             ]
  , examples (datetime (2013, 2, 14, 6, 0, 0) Minute)
             [ "torsdag kl. 8:00 GMT"
             , "torsdag kl. 8:00 gmt"
             , "torsdag klockan 8:00 GMT"
             , "torsdag klockan 8:00 gmt"
             , "torsdag 08:00 GMT"
             , "torsdag 08:00 gmt"
             ]
  , examples (datetime (2013, 2, 12, 14, 0, 0) Hour)
             [ "idag kl. 14"
             , "idag klockan 14"
             , "kl. 14"
             , "klockan 14"
             ]
  , examples (datetime (2013, 4, 25, 16, 0, 0) Minute)
             [ "25/4 kl. 16:00"
             , "25/4 klockan 16:00"
             , "25-04 klockan 16:00"
             , "25-4 kl. 16:00"
             , "2013-04-25 kl 16:00"
             ]
  , examples (datetime (2013, 2, 13, 15, 0, 0) Minute)
             [ "15:00 imorgon"
             , "kl. 15:00 imorgon"
             , "klockan 15:00 imorgon"
             ]
  , examples (datetimeOpenInterval After (2013, 2, 12, 14, 0, 0) Hour)
             [ "efter kl. 14"
             , "efter klockan 14"
             ]
  , examples (datetimeOpenInterval After (2013, 2, 17, 4, 0, 0) Hour)
             [ "efter 5 dagar"
             , "efter fem dagar"
             ]
  , examples (datetime (2013, 2, 17, 4, 0, 0) Hour)
             [ "om 5 dagar"
             , "om fem dagar"
             ]
  , examples (datetimeOpenInterval After (2013, 2, 13, 14, 0, 0) Hour)
             [ "efter imorgon kl. 14"
             , "efter imorgon klockan 14"
             , "imorgon efter kl. 14"
             , "imorgon efter klockan 14"
             ]
  , examples (datetimeOpenInterval Before (2013, 2, 12, 11, 0, 0) Hour)
             [ "fÃ¶re kl. 11"
             , "fÃ¶re klockan 11"
             ]
  , examples (datetimeOpenInterval Before (2013, 2, 13, 11, 0, 0) Hour)
             [ "imorgon fÃ¶re kl. 11"
             , "imorgon fÃ¶re klockan 11"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 12, 0, 0), (2013, 2, 12, 19, 0, 0)) Hour)
             [ "under eftermiddagen"
             ]
  , examples (datetime (2013, 2, 12, 13, 30, 0) Minute)
             [ "kl. 13:30"
             , "klockan 13:30"
             ]
  , examples (datetime (2013, 2, 12, 4, 45, 0) Second)
             [ "om 15 minuter"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 13, 0, 0), (2013, 2, 12, 17, 0, 0)) Hour)
             [ "efter lunch"
             ]
  , examples (datetime (2013, 2, 12, 10, 30, 0) Minute)
             [ "10:30"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Day)
             [ "nÃ¤sta mÃ¥ndag"
             ]
  ]


-- 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 GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}

module Duckling.Time.SV.Rules
  ( rules
  ) where

import Data.Text (Text)
import Prelude

import Duckling.Dimensions.Types
import Duckling.Duration.Helpers (isGrain)
import Duckling.Numeral.Helpers (parseInt)
import Duckling.Ordinal.Types (OrdinalData(..))
import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Time.Types (TimeData(..))
import Duckling.Types
import qualified Data.Text as Text
import qualified Duckling.Ordinal.Types as TOrdinal
import qualified Duckling.Time.Types as TTime
import qualified Duckling.TimeGrain.Types as TG

ruleDaysOfWeek :: [Rule]
ruleDaysOfWeek = mkRuleDaysOfWeek
  [ ( "Mandag"  , "mÃ¥ndag(en)?s?|mÃ¥n\\.?"    )
  , ( "Tisdag"  , "tisdag(en)?s?|tis?\\.?"   )
  , ( "Onsdag"  , "onsdag(en)?s?|ons\\.?"    )
  , ( "Torsdag" , "torsdag(en)?s?|tors?\\.?" )
  , ( "Fredag"  , "fredag(en)?s?|fre\\.?"    )
  , ( "Lordag"  , "lÃ¶rdag(en)?s?|lÃ¶r\\.?"    )
  , ( "Sondag"  , "sÃ¶ndag(en)?s?|sÃ¶n\\.?"    )
  ]

ruleMonths :: [Rule]
ruleMonths = mkRuleMonths
  [ ("Januari"   , "januari|jan\\.?"     )
  , ("Februari"  , "februari|feb\\.?"    )
  , ("Mars"      , "mars|mar\\.?"        )
  , ("April"     , "april|apr\\.?"       )
  , ("Maj"       , "maj"                 )
  , ("Juni"      , "juni|jun\\.?"        )
  , ("Juli"      , "juli|jul\\.?"        )
  , ("Augusti"   , "augusti|aug\\.?"     )
  , ("September" , "september|sept?\\.?" )
  , ("Oktober"   , "oktober|okt\\.?"     )
  , ("November"  , "november|nov\\.?"    )
  , ("December"  , "december|dec\\.?"    )
  ]

ruleTheDayAfterTomorrow :: Rule
ruleTheDayAfterTomorrow = Rule
  { name = "the day after tomorrow"
  , pattern =
    [ regex "i Ã¶verimorgon"
    ]
  , prod = \_ -> tt $ cycleNth TG.Day 2
  }

ruleRelativeMinutesTotillbeforeIntegerHourofday :: Rule
ruleRelativeMinutesTotillbeforeIntegerHourofday = Rule
  { name = "relative minutes to|till|before <integer> (hour-of-day)"
  , pattern =
    [ Predicate $ isIntegerBetween 1 59
    , regex "i"
    , Predicate isAnHourOfDay
    ]
  , prod = \tokens -> case tokens of
      (token:_:Token Time td:_) -> do
        n <- getIntValue token
        Token Time <$> minutesBefore n td
      _ -> Nothing
  }

ruleRelativeMinutesAfterpastIntegerHourofday :: Rule
ruleRelativeMinutesAfterpastIntegerHourofday = Rule
  { name = "relative minutes after|past <integer> (hour-of-day)"
  , pattern =
    [ Predicate $ isIntegerBetween 1 59
    , regex "Ã¶ver"
    , Predicate isAnHourOfDay
    ]
  , prod = \tokens -> case tokens of
      (token:
       _:
       Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
       _) -> do
        n <- getIntValue token
        tt $ hourMinute True hours n
      _ -> Nothing
  }

ruleHourofdayIntegerAsRelativeMinutes :: Rule
ruleHourofdayIntegerAsRelativeMinutes = Rule
  { name = "<hour-of-day> <integer> (as relative minutes)"
  , pattern =
    [ Predicate $ and . sequence [isNotLatent, isAnHourOfDay]
    , Predicate $ isIntegerBetween 1 59
    ]
  , prod = \tokens -> case tokens of
      (Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
       token:
       _) -> do
        n <- getIntValue token
        tt $ hourMinute True hours n
      _ -> Nothing
  }

ruleQuarterTotillbeforeIntegerHourofday :: Rule
ruleQuarterTotillbeforeIntegerHourofday = Rule
  { name = "quarter to|till|before <integer> (hour-of-day)"
  , pattern =
    [ regex "(en)? ?(kvart)(er)?"
    , regex "i"
    , Predicate isAnHourOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:_:Token Time td:_) -> Token Time <$> minutesBefore 15 td
      _ -> Nothing
  }

ruleQuarterAfterpastIntegerHourofday :: Rule
ruleQuarterAfterpastIntegerHourofday = Rule
  { name = "quarter after|past <integer> (hour-of-day)"
  , pattern =
    [ regex "(en)? ?(kvart)(er)?"
    , regex "Ã¶ver"
    , Predicate isAnHourOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:
       _:
       Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
       _) -> tt $ hourMinute True hours 15
      _ -> Nothing
  }

ruleHourofdayQuarter :: Rule
ruleHourofdayQuarter = Rule
  { name = "<hour-of-day> quarter (as relative minutes)"
  , pattern =
    [ Predicate isAnHourOfDay
    , regex  "(en)? ?(kvart)(er)?"
    ]
  , prod = \tokens -> case tokens of
      (Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
       _) -> tt $ hourMinute True hours 15
      _ -> Nothing
  }

ruleHalfTotillbeforeIntegerHourofday :: Rule
ruleHalfTotillbeforeIntegerHourofday = Rule
  { name = "half to|till|before <integer> (hour-of-day)"
  , pattern =
    [ regex "halvtimme"
    , regex "i"
    , Predicate isAnHourOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:_:Token Time td:_) -> Token Time <$> minutesBefore 30 td
      _ -> Nothing
  }

ruleHalfAfterpastIntegerHourofday :: Rule
ruleHalfAfterpastIntegerHourofday = Rule
  { name = "half after|past <integer> (hour-of-day)"
  , pattern =
    [ regex "halvtimme"
    , regex "Ã¶ver"
    , Predicate isAnHourOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:
       _:
       Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
       _) -> tt $ hourMinute True hours 30
      _ -> Nothing
  }

ruleHourofdayHalf :: Rule
ruleHourofdayHalf = Rule
  { name = "<hour-of-day> half (as relative minutes)"
  , pattern =
    [ Predicate isAnHourOfDay
    , regex "halvtimme"
    ]
  , prod = \tokens -> case tokens of
      (Token Time TimeData {TTime.form = Just (TTime.TimeOfDay (Just hours) _)}:
       _) -> tt $ hourMinute True hours 30
      _ -> Nothing
  }

ruleTheOrdinalCycleOfTime :: Rule
ruleTheOrdinalCycleOfTime = Rule
  { name = "the <ordinal> <cycle> of <time>"
  , pattern =
    [ regex "den"
    , dimension Ordinal
    , dimension TimeGrain
    , regex "av|i|frÃ¥n"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
      _ -> Nothing
  }

ruleNthTimeOfTime2 :: Rule
ruleNthTimeOfTime2 = Rule
  { name = "nth <time> of <time>"
  , pattern =
    [ regex "den"
    , dimension Ordinal
    , dimension Time
    , regex "av|i"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:
       Token Ordinal OrdinalData{TOrdinal.value = v}:
       Token Time td1:
       _:
       Token Time td2:
       _) -> Token Time . predNth (v - 1) False <$> intersect td2 td1
      _ -> Nothing
  }

ruleNewYearsDay :: Rule
ruleNewYearsDay = Rule
  { name = "new year's day"
  , pattern =
    [ regex "nyÃ¥rsdag(en)?"
    ]
  , prod = \_ -> tt $ monthDay 1 1
  }

ruleLastTime :: Rule
ruleLastTime = Rule
  { name = "last <time>"
  , pattern =
    [ regex "(sista|fÃ¶rra|senaste)"
    , Predicate isOkWithThisNext
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ predNth (-1) False td
      _ -> Nothing
  }

ruleDatetimeDatetimeInterval :: Rule
ruleDatetimeDatetimeInterval = Rule
  { name = "<datetime> - <datetime> (interval)"
  , pattern =
    [ Predicate isNotLatent
    , regex "\\-|till|till och med|tom"
    , Predicate isNotLatent
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:_:Token Time td2:_) ->
        Token Time <$> interval TTime.Closed td1 td2
      _ -> Nothing
  }

ruleEvening :: Rule
ruleEvening = Rule
  { name = "evening"
  , pattern =
    [ regex "kvÃ¤ll(en)?"
    ]
  , prod = \_ ->
      let from = hour False 18
          to = hour False 0
      in Token Time . mkLatent . partOfDay <$>
           interval TTime.Open from to
  }

ruleTheDayofmonthNonOrdinal :: Rule
ruleTheDayofmonthNonOrdinal = Rule
  { name = "the <day-of-month> (non ordinal)"
  , pattern =
    [ regex "den"
    , Predicate isDOMInteger
    ]
  , prod = \tokens -> case tokens of
      (_:token:_) -> do
        v <- getIntValue token
        tt . mkLatent $ dayOfMonth v
      _ -> Nothing
  }

ruleCycleAfterTime :: Rule
ruleCycleAfterTime = Rule
  { name = "<cycle> after <time>"
  , pattern =
    [ dimension TimeGrain
    , regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter False grain 1 td
      _ -> Nothing
  }

ruleInDuration :: Rule
ruleInDuration = Rule
  { name = "in <duration>"
  , pattern =
    [ regex "om"
    , dimension Duration
    ]
  , prod = \tokens -> case tokens of
      (_:Token Duration dd:_) ->
        tt $ inDuration dd
      _ -> Nothing
  }

ruleNow :: Rule
ruleNow = Rule
  { name = "now"
  , pattern =
    [ regex "just nu|nu|(i )?detta Ã¶gonblick"
    ]
  , prod = \_ -> tt now
  }

ruleLastCycleOfTime :: Rule
ruleLastCycleOfTime = Rule
  { name = "last <cycle> of <time>"
  , pattern =
    [ regex "sista"
    , dimension TimeGrain
    , regex "av|i"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleLastOf grain td
      _ -> Nothing
  }

ruleFromDatetimeDatetimeInterval :: Rule
ruleFromDatetimeDatetimeInterval = Rule
  { name = "from <datetime> - <datetime> (interval)"
  , pattern =
    [ regex "frÃ¥n"
    , dimension Time
    , regex "\\-|till|till och med|tom"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td1:_:Token Time td2:_) ->
        Token Time <$> interval TTime.Closed td1 td2
      _ -> Nothing
  }

ruleMonthDdddInterval :: Rule
ruleMonthDdddInterval = Rule
  { name = "<month> dd-dd (interval)"
  , pattern =
    [ regex "([012]?\\d|30|31)(er|\\.)?"
    , regex "\\-|till"
    , regex "([012]?\\d|30|31)(er|\\.)?"
    , Predicate isAMonth
    ]
  , prod = \tokens -> case tokens of
      (Token RegexMatch (GroupMatch (m1:_)):
       _:
       Token RegexMatch (GroupMatch (m2:_)):
       Token Time td:
       _) -> do
        v1 <- parseInt m1
        v2 <- parseInt m2
        from <- intersect (dayOfMonth v1) td
        to <- intersect (dayOfMonth v2) td
        Token Time <$> interval TTime.Closed from to
      _ -> Nothing
  }

ruleTheCycleAfterTime :: Rule
ruleTheCycleAfterTime = Rule
  { name = "the <cycle> after <time>"
  , pattern =
    [ dimension TimeGrain
    , regex "(en|na|et)? efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter False grain 1 td
      _ -> Nothing
  }

ruleTheCycleBeforeTime :: Rule
ruleTheCycleBeforeTime = Rule
  { name = "the <cycle> before <time>"
  , pattern =
    [ dimension TimeGrain
    , regex "(en|na|et)? fÃ¶re"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter False grain (-1) td
      _ -> Nothing
  }

ruleYearLatent2 :: Rule
ruleYearLatent2 = Rule
  { name = "year (latent)"
  , pattern =
    [ Predicate $ isIntegerBetween 2101 10000
    ]
  , prod = \tokens -> case tokens of
      (token:_) -> do
        v <- getIntValue token
        tt . mkLatent $ year v
      _ -> Nothing
  }

ruleTimeAfterNext :: Rule
ruleTimeAfterNext = Rule
  { name = "<time> after next"
  , pattern =
    [ regex "nÃ¤sta"
    , dimension Time
    , regex "igen"
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ predNth 1 True td
      _ -> Nothing
  }

ruleTheIdesOfNamedmonth :: Rule
ruleTheIdesOfNamedmonth = Rule
  { name = "the ides of <named-month>"
  , pattern =
    [ regex "mitten av"
    , Predicate isAMonth
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td@TimeData {TTime.form = Just (TTime.Month m)}:_) ->
        Token Time <$>
          intersect (dayOfMonth $ if elem m [3, 5, 7, 10] then 15 else 13) td
      _ -> Nothing
  }

ruleNoon :: Rule
ruleNoon = Rule
  { name = "noon"
  , pattern =
    [ regex "middag|(kl(\\.|ockan)?)? tolv"
    ]
  , prod = \_ -> tt $ hour False 12
  }

ruleToday :: Rule
ruleToday = Rule
  { name = "today"
  , pattern =
    [ regex "i dag|idag"
    ]
  , prod = \_ -> tt today
  }

ruleThisnextDayofweek :: Rule
ruleThisnextDayofweek = Rule
  { name = "this|next <day-of-week>"
  , pattern =
    [ regex "(kommande|nÃ¤sta)"
    , Predicate isADayOfWeek
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ predNth 0 True td
      _ -> Nothing
  }

ruleLastDayofweek :: Rule
ruleLastDayofweek = Rule
  { name = "last <day-of-week>"
  , pattern =
    [ regex "i"
    , Predicate isADayOfWeek
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) -> tt $ predNth (-1) True td
      _ -> Nothing
  }

ruleTheDayBeforeYesterday :: Rule
ruleTheDayBeforeYesterday = Rule
  { name = "the day before yesterday"
  , pattern =
    [ regex "i fÃ¶rrgÃ¥r"
    ]
  , prod = \_ -> tt . cycleNth TG.Day $ - 2
  }

ruleBetweenTimeofdayAndTimeofdayInterval :: Rule
ruleBetweenTimeofdayAndTimeofdayInterval = Rule
  { name = "between <time-of-day> and <time-of-day> (interval)"
  , pattern =
    [ regex "mellan"
    , Predicate isATimeOfDay
    , regex "och"
    , Predicate isATimeOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td1:_:Token Time td2:_) ->
        Token Time <$> interval TTime.Closed td1 td2
      _ -> Nothing
  }

ruleNextCycle :: Rule
ruleNextCycle = Rule
  { name = "next <cycle>"
  , pattern =
    [ regex "nÃ¤sta|kommande"
    , dimension TimeGrain
    ]
  , prod = \tokens -> case tokens of
      (_:Token TimeGrain grain:_) ->
        tt $ cycleNth grain 1
      _ -> Nothing
  }

ruleTheCycleOfTime :: Rule
ruleTheCycleOfTime = Rule
  { name = "the <cycle> of <time>"
  , pattern =
    [ dimension TimeGrain
    , regex "(en|na|et)? av"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter True grain 0 td
      _ -> Nothing
  }

ruleTimeofdayApproximately :: Rule
ruleTimeofdayApproximately = Rule
  { name = "<time-of-day> approximately"
  , pattern =
    [ Predicate isATimeOfDay
    , regex "(cirka|ca\\.|-?ish)"
    ]
  , prod = \tokens -> case tokens of
      (Token Time td:_) -> tt $ notLatent td
      _ -> Nothing
  }

ruleOnDate :: Rule
ruleOnDate = Rule
  { name = "on <date>"
  , pattern =
    [ regex "den|pÃ¥|under"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) -> tt $ notLatent td
      _ -> Nothing
  }

ruleDurationFromNow :: Rule
ruleDurationFromNow = Rule
  { name = "<duration> from now"
  , pattern =
    [ dimension Duration
    , regex "frÃ¥n (idag|nu)"
    ]
  , prod = \tokens -> case tokens of
      (Token Duration dd:_) ->
        tt $ inDuration dd
      _ -> Nothing
  }

ruleLunch :: Rule
ruleLunch = Rule
  { name = "lunch"
  , pattern =
    [ regex "lunch(en)?"
    ]
  , prod = \_ ->
      let from = hour False 12
          to = hour False 14
      in Token Time . mkLatent . partOfDay <$>
           interval TTime.Open from to
  }

ruleLastCycle :: Rule
ruleLastCycle = Rule
  { name = "last <cycle>"
  , pattern =
    [ regex "sista|senaste|f(Ã¶)rra|f(Ã¶)reg(Ã¥)ende"
    , dimension TimeGrain
    ]
  , prod = \tokens -> case tokens of
      (_:Token TimeGrain grain:_) ->
        tt . cycleNth grain $ - 1
      _ -> Nothing
  }

ruleDdmm :: Rule
ruleDdmm = Rule
  { name = "dd/mm"
  , pattern =
    [ regex "(3[01]|[12]\\d|0?[1-9])[\\/-](0?[1-9]|1[0-2])"
    ]
  , prod = \tokens -> case tokens of
      (Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
        d <- parseInt m1
        m <- parseInt m2
        tt $ monthDay m d
      _ -> Nothing
  }

ruleAfternoon :: Rule
ruleAfternoon = Rule
  { name = "afternoon"
  , pattern =
    [ regex "eftermiddag(en)?"
    ]
  , prod = \_ ->
      let from = hour False 12
          to = hour False 19
      in Token Time . mkLatent . partOfDay <$>
           interval TTime.Open from to
  }

ruleTimeBeforeLast :: Rule
ruleTimeBeforeLast = Rule
  { name = "<time> before last"
  , pattern =
    [ regex "sista"
    , dimension Time
    , regex "igen"
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ predNth (-2) False td
      _ -> Nothing
  }

ruleNamedmonthDayofmonthOrdinal :: Rule
ruleNamedmonthDayofmonthOrdinal = Rule
  { name = "<named-month> <day-of-month> (ordinal)"
  , pattern =
    [ Predicate isAMonth
    , Predicate isDOMOrdinal
    ]
  , prod = \tokens -> case tokens of
      (Token Time td:token:_) -> Token Time <$> intersectDOM td token
      _ -> Nothing
  }

ruleChristmasEve :: Rule
ruleChristmasEve = Rule
  { name = "christmas eve"
  , pattern =
    [ regex "julafton?"
    ]
  , prod = \_ -> tt $ monthDay 12 24
  }

ruleInduringThePartofday :: Rule
ruleInduringThePartofday = Rule
  { name = "in|during the <part-of-day>"
  , pattern =
    [ regex "om|i"
    , Predicate isAPartOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ notLatent td
      _ -> Nothing
  }

ruleDayofmonthordinalNamedmonth :: Rule
ruleDayofmonthordinalNamedmonth = Rule
  { name = "<day-of-month>(ordinal) <named-month>"
  , pattern =
    [ Predicate isDOMOrdinal
    , Predicate isAMonth
    ]
  , prod = \tokens -> case tokens of
      (token:Token Time td:_) -> Token Time <$> intersectDOM td token
      _ -> Nothing
  }

ruleIntersectBy :: Rule
ruleIntersectBy = Rule
  { name = "intersect by \",\""
  , pattern =
    [ Predicate isNotLatent
    , regex ","
    , Predicate isNotLatent
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:_:Token Time td2:_) ->
        Token Time <$> intersect td1 td2
      _ -> Nothing
  }

ruleNthTimeAfterTime :: Rule
ruleNthTimeAfterTime = Rule
  { name = "nth <time> after <time>"
  , pattern =
    [ dimension Ordinal
    , dimension Time
    , regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal OrdinalData{TOrdinal.value = v}:
       Token Time td1:
       _:
       Token Time td2:
       _) -> tt $ predNthAfter (v - 1) td1 td2
      _ -> Nothing
  }

ruleAfterDuration :: Rule
ruleAfterDuration = Rule
  { name = "after <duration>"
  , pattern =
    [ regex "efter"
    , dimension Duration
    ]
  , prod = \tokens -> case tokens of
      (_:Token Duration dd:_) ->
        tt . withDirection TTime.After $ inDuration dd
      _ -> Nothing
  }

ruleTimeofdayLatent :: Rule
ruleTimeofdayLatent = Rule
  { name = "time-of-day (latent)"
  , pattern =
    [ Predicate $ isIntegerBetween 0 23
    ]
  , prod = \tokens -> case tokens of
      (token:_) -> do
        n <- getIntValue token
        tt . mkLatent $ hour False n
      _ -> Nothing
  }

ruleDayofmonthOrdinalOfNamedmonth :: Rule
ruleDayofmonthOrdinalOfNamedmonth = Rule
  { name = "<day-of-month> (ordinal) of <named-month>"
  , pattern =
    [ Predicate isDOMOrdinal
    , regex "av|i"
    , Predicate isAMonth
    ]
  , prod = \tokens -> case tokens of
      (token:_:Token Time td:_) -> Token Time <$> intersectDOM td token
      _ -> Nothing
  }

ruleFromTimeofdayTimeofdayInterval :: Rule
ruleFromTimeofdayTimeofdayInterval = Rule
  { name = "from <time-of-day> - <time-of-day> (interval)"
  , pattern =
    [ regex "(efter|frÃ¥n)"
    , Predicate isATimeOfDay
    , regex "((men )?fÃ¶re)|\\-|till|till och med|tom"
    , Predicate isATimeOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td1:_:Token Time td2:_) ->
        Token Time <$> interval TTime.Closed td1 td2
      _ -> Nothing
  }

ruleExactlyTimeofday :: Rule
ruleExactlyTimeofday = Rule
  { name = "exactly <time-of-day>"
  , pattern =
    [ regex "(precis|exakt)( kl.| klockan)?"
    , Predicate isATimeOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) -> tt $ notLatent td
      _ -> Nothing
  }

ruleInduringThePartofday2 :: Rule
ruleInduringThePartofday2 = Rule
  { name = "in|during the <part-of-day>"
  , pattern =
    [ regex "om|i"
    , Predicate isAPartOfDay
    , regex "en|ten"
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ notLatent td
      _ -> Nothing
  }

ruleSeasons :: [Rule]
ruleSeasons = mkRuleSeasons
  [ ( "sommar"  , "sommar(en)"       , monthDay  6 21, monthDay  9 23 )
  , ( "vinter"  , "vinter(n)"           , monthDay 12 21, monthDay  3 20 )
  ]

ruleBetweenDatetimeAndDatetimeInterval :: Rule
ruleBetweenDatetimeAndDatetimeInterval = Rule
  { name = "between <datetime> and <datetime> (interval)"
  , pattern =
    [ regex "mellan"
    , dimension Time
    , regex "och"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td1:_:Token Time td2:_) ->
        Token Time <$> interval TTime.Closed td1 td2
      _ -> Nothing
  }

ruleNewYearsEve :: Rule
ruleNewYearsEve = Rule
  { name = "new year's eve"
  , pattern =
    [ regex "nyÃ¥rsafton?"
    ]
  , prod = \_ -> tt $ monthDay 12 31
  }

ruleDurationAgo :: Rule
ruleDurationAgo = Rule
  { name = "<duration> ago"
  , pattern =
    [ dimension Duration
    , regex "sedan"
    ]
  , prod = \tokens -> case tokens of
      (Token Duration dd:_) ->
        tt $ durationAgo dd
      _ -> Nothing
  }

ruleByTheEndOfTime :: Rule
ruleByTheEndOfTime = Rule
  { name = "by the end of <time>"
  , pattern =
    [ regex "i slutet av"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) -> Token Time <$> interval TTime.Closed now td
      _ -> Nothing
  }

ruleAfterWork :: Rule
ruleAfterWork = Rule
  { name = "after work"
  , pattern =
    [ regex "efter jobbet"
    ]
  , prod = \_ -> do
      td2 <- interval TTime.Open (hour False 17) (hour False 21)
      Token Time . partOfDay <$> intersect today td2
  }

ruleLastNCycle :: Rule
ruleLastNCycle = Rule
  { name = "last n <cycle>"
  , pattern =
    [ regex "sista|senaste|fÃ¶rra"
    , Predicate $ isIntegerBetween 1 9999
    , dimension TimeGrain
    ]
  , prod = \tokens -> case tokens of
      (_:token:Token TimeGrain grain:_) -> do
        v <- getIntValue token
        tt $ cycleN True grain (- v)
      _ -> Nothing
  }

ruleTimeofdaySharp :: Rule
ruleTimeofdaySharp = Rule
  { name = "<time-of-day> sharp"
  , pattern =
    [ Predicate isATimeOfDay
    , regex "(sharp|precis|exakt)"
    ]
  , prod = \tokens -> case tokens of
      (Token Time td:_) -> tt $ notLatent td
      _ -> Nothing
  }

ruleWithinDuration :: Rule
ruleWithinDuration = Rule
  { name = "within <duration>"
  , pattern =
    [ regex "(innanfÃ¶r|inom)"
    , dimension Duration
    ]
  , prod = \tokens -> case tokens of
      (_:Token Duration dd:_) ->
        Token Time <$> interval TTime.Open now (inDuration dd)
      _ -> Nothing
  }

ruleMidnighteodendOfDay :: Rule
ruleMidnighteodendOfDay = Rule
  { name = "midnight|EOD|end of day"
  , pattern =
    [ regex "midnatt|EOD"
    ]
  , prod = \_ -> tt $ hour False 0
  }

ruleDayofmonthNonOrdinalNamedmonth :: Rule
ruleDayofmonthNonOrdinalNamedmonth = Rule
  { name = "<day-of-month> (non ordinal) <named-month>"
  , pattern =
    [ Predicate isDOMInteger
    , Predicate isAMonth
    ]
  , prod = \tokens -> case tokens of
      (token:Token Time td:_) -> Token Time <$> intersectDOM td token
      _ -> Nothing
  }

ruleIntersect :: Rule
ruleIntersect = Rule
  { name = "intersect"
  , pattern =
    [ Predicate isNotLatent
    , Predicate isNotLatent
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:Token Time td2:_) ->
        Token Time <$> intersect td1 td2
      _ -> Nothing
  }

ruleAboutTimeofday :: Rule
ruleAboutTimeofday = Rule
  { name = "about <time-of-day>"
  , pattern =
    [ regex "(omkring|cirka|vid|runt|ca\\.)( kl\\.| klockan)?"
    , Predicate isATimeOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) -> tt $ notLatent td
      _ -> Nothing
  }

ruleUntilTimeofday :: Rule
ruleUntilTimeofday = Rule
  { name = "until <time-of-day>"
  , pattern =
    [ regex "innan|fÃ¶re|intill"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ withDirection TTime.Before td
      _ -> Nothing
  }

ruleAtTimeofday :: Rule
ruleAtTimeofday = Rule
  { name = "at <time-of-day>"
  , pattern =
    [ regex "klockan|kl.|kl|@"
    , Predicate isATimeOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ notLatent td
      _ -> Nothing
  }

ruleNthTimeOfTime :: Rule
ruleNthTimeOfTime = Rule
  { name = "nth <time> of <time>"
  , pattern =
    [ dimension Ordinal
    , dimension Time
    , regex "av|i"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal OrdinalData{TOrdinal.value = v}:
       Token Time td1:
       _:
       Token Time td2:
       _) -> Token Time . predNth (v - 1) False <$> intersect td2 td1
      _ -> Nothing
  }

ruleTimePartofday :: Rule
ruleTimePartofday = Rule
  { name = "<time> <part-of-day>"
  , pattern =
    [ dimension Time
    , Predicate isAPartOfDay
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:Token Time td2:_) ->
        Token Time <$> intersect td1 td2
      _ -> Nothing
  }

ruleWeekend :: Rule
ruleWeekend = Rule
  { name = "week-end"
  , pattern =
    [ regex "((week(\\s|-)?end)|helg)(en)?"
    ]
  , prod = \_ -> tt $ mkOkForThisNext weekend
  }

ruleEomendOfMonth :: Rule
ruleEomendOfMonth = Rule
  { name = "EOM|End of month"
  , pattern =
    [ regex "EOM"
    ]
  , prod = \_ -> tt $ cycleNth TG.Month 1
  }

ruleLastYear :: Rule
ruleLastYear = Rule
  { name = "Last year"
  , pattern =
    [ regex "i fjol|ifjol"
    ]
  , prod = \_ -> tt . cycleNth TG.Year $ - 1
  }

ruleNthTimeAfterTime2 :: Rule
ruleNthTimeAfterTime2 = Rule
  { name = "nth <time> after <time>"
  , pattern =
    [ regex "den"
    , dimension Ordinal
    , dimension Time
    , regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:
       Token Ordinal OrdinalData{TOrdinal.value = v}:
       Token Time td1:
       _:
       Token Time td2:
       _) -> tt $ predNthAfter (v - 1) td1 td2
      _ -> Nothing
  }

ruleNextTime :: Rule
ruleNextTime = Rule
  { name = "next <time>"
  , pattern =
    [ regex "nÃ¤sta|kommande"
    , Predicate $ and . sequence [isNotLatent, isOkWithThisNext]
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ predNth 0 True td
      _ -> Nothing
  }

ruleOrdinalQuarterYear :: Rule
ruleOrdinalQuarterYear = Rule
  { name = "<ordinal> quarter <year>"
  , pattern =
    [ dimension Ordinal
    , Predicate $ isGrain TG.Quarter
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal od:_:Token Time td:_) ->
        tt $ cycleNthAfter False TG.Quarter (TOrdinal.value od - 1) td
      _ -> Nothing
  }

ruleYyyymmdd :: Rule
ruleYyyymmdd = Rule
  { name = "yyyy-mm-dd"
  , pattern =
    [ 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
        y <- parseInt m1
        m <- parseInt m2
        d <- parseInt m3
        tt $ yearMonthDay y m d
      _ -> Nothing
  }

ruleTheOrdinalCycleAfterTime :: Rule
ruleTheOrdinalCycleAfterTime = Rule
  { name = "the <ordinal> <cycle> after <time>"
  , pattern =
    [ regex "den"
    , dimension Ordinal
    , dimension TimeGrain
    , regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
      _ -> Nothing
  }

ruleIntersectByOfFromS :: Rule
ruleIntersectByOfFromS = Rule
  { name = "intersect by \"of\", \"from\", \"'s\""
  , pattern =
    [ Predicate isNotLatent
    , regex "i"
    , Predicate isNotLatent
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:_:Token Time td2:_) ->
        Token Time <$> intersect td1 td2
      _ -> Nothing
  }

ruleNextNCycle :: Rule
ruleNextNCycle = Rule
  { name = "next n <cycle>"
  , pattern =
    [ regex "nÃ¤sta"
    , Predicate $ isIntegerBetween 1 9999
    , dimension TimeGrain
    ]
  , prod = \tokens -> case tokens of
      (_:token:Token TimeGrain grain:_) -> do
        v <- getIntValue token
        tt $ cycleN True grain v
      _ -> Nothing
  }

ruleADuration :: Rule
ruleADuration = Rule
  { name = "a <duration>"
  , pattern =
    [ regex "(om )?en|ett"
    , dimension Duration
    ]
  , prod = \tokens -> case tokens of
      (_:Token Duration dd:_) ->
        tt $ inDuration dd
      _ -> Nothing
  }

ruleMorning :: Rule
ruleMorning = Rule
  { name = "morning"
  , pattern =
    [ regex "morgon(en)?"
    ]
  , prod = \_ ->
      let from = hour False 4
          to = hour False 12
      in Token Time . mkLatent . partOfDay <$>
           interval TTime.Open from to
  }

ruleThisPartofday :: Rule
ruleThisPartofday = Rule
  { name = "this <part-of-day>"
  , pattern =
    [ regex "i|denna"
    , Predicate isAPartOfDay
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) -> Token Time . partOfDay <$> intersect today td
      _ -> Nothing
  }

ruleThisCycle :: Rule
ruleThisCycle = Rule
  { name = "this <cycle>"
  , pattern =
    [ regex "denna|detta|i|nuvarande"
    , dimension TimeGrain
    ]
  , prod = \tokens -> case tokens of
      (_:Token TimeGrain grain:_) ->
        tt $ cycleNth grain 0
      _ -> Nothing
  }

ruleThisTime :: Rule
ruleThisTime = Rule
  { name = "this <time>"
  , pattern =
    [ regex "(denna|detta|i|den hÃ¤r)"
    , Predicate isOkWithThisNext
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt $ predNth 0 False td
      _ -> Nothing
  }

ruleDayofmonthNonOrdinalOfNamedmonth :: Rule
ruleDayofmonthNonOrdinalOfNamedmonth = Rule
  { name = "<day-of-month> (non ordinal) of <named-month>"
  , pattern =
    [ Predicate isDOMInteger
    , regex "av|i"
    , Predicate isAMonth
    ]
  , prod = \tokens -> case tokens of
      (token:_:Token Time td:_) -> Token Time <$> intersectDOM td token
      _ -> Nothing
  }

ruleAfterLunch :: Rule
ruleAfterLunch = Rule
  { name = "after lunch"
  , pattern =
    [ regex "efter (lunch)"
    ]
  , prod = \_ -> do
      td2 <- interval TTime.Open (hour False 13) (hour False 17)
      Token Time . partOfDay <$> intersect today td2
  }

ruleOnANamedday :: Rule
ruleOnANamedday = Rule
  { name = "on a named-day"
  , pattern =
    [ regex "pÃ¥ en"
    , Predicate isADayOfWeek
    ]
  , prod = \tokens -> case tokens of
      (_:x:_) -> Just x
      _ -> Nothing
  }

ruleYearLatent :: Rule
ruleYearLatent = Rule
  { name = "year (latent)"
  , pattern =
    [ Predicate $ isIntegerBetween 1 999
    ]
  , prod = \tokens -> case tokens of
      (token:_) -> do
        v <- getIntValue token
        tt . mkLatent $ year v
      _ -> Nothing
  }

ruleYesterday :: Rule
ruleYesterday = Rule
  { name = "yesterday"
  , pattern =
    [ regex "i gÃ¥r|igÃ¥r"
    ]
  , prod = \_ -> tt . cycleNth TG.Day $ - 1
  }

ruleAfterTimeofday :: Rule
ruleAfterTimeofday = Rule
  { name = "after <time-of-day>"
  , pattern =
    [ regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td:_) ->
        tt . notLatent $ withDirection TTime.After td
      _ -> Nothing
  }

ruleChristmas :: Rule
ruleChristmas = Rule
  { name = "christmas"
  , pattern =
    [ regex "juldag(en)?"
    ]
  , prod = \_ -> tt $ monthDay 12 25
  }

ruleNight :: Rule
ruleNight = Rule
  { name = "night"
  , pattern =
    [ regex "natt(en)?"
    ]
  , prod = \_ ->
      let from = hour False 0
          to = hour False 4
      in Token Time . mkLatent . partOfDay <$>
           interval TTime.Open from to
  }

ruleDayofmonthOrdinal :: Rule
ruleDayofmonthOrdinal = Rule
  { name = "<day-of-month> (ordinal)"
  , pattern =
    [ Predicate isDOMOrdinal
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal OrdinalData{TOrdinal.value = v}:_) ->
        tt . mkLatent $ dayOfMonth v
      _ -> Nothing
  }

ruleOrdinalCycleAfterTime :: Rule
ruleOrdinalCycleAfterTime = Rule
  { name = "<ordinal> <cycle> after <time>"
  , pattern =
    [ dimension Ordinal
    , dimension TimeGrain
    , regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
      _ -> Nothing
  }

ruleOrdinalCycleOfTime :: Rule
ruleOrdinalCycleOfTime = Rule
  { name = "<ordinal> <cycle> of <time>"
  , pattern =
    [ dimension Ordinal
    , dimension TimeGrain
    , regex "av|i|frÃ¥n"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal od:Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter True grain (TOrdinal.value od - 1) td
      _ -> Nothing
  }

ruleHhmm :: Rule
ruleHhmm = Rule
  { name = "hh:mm"
  , pattern =
    [ regex "((?:[01]?\\d)|(?:2[0-3]))[:.]([0-5]\\d)"
    ]
  , prod = \tokens -> case tokens of
      (Token RegexMatch (GroupMatch (m1:m2:_)):_) -> do
        h <- parseInt m1
        m <- parseInt m2
        tt $ hourMinute False h m
      _ -> Nothing
  }

ruleTonight :: Rule
ruleTonight = Rule
  { name = "tonight"
  , pattern =
    [ regex "ikvÃ¤ll"
    ]
  , prod = \_ -> do
      td2 <- interval TTime.Open (hour False 18) (hour False 0)
      Token Time . partOfDay <$> intersect today td2
  }

ruleYear :: Rule
ruleYear = Rule
  { name = "year"
  , pattern =
    [ Predicate $ isIntegerBetween 1000 2100
    ]
  , prod = \tokens -> case tokens of
      (token:_) -> do
        v <- getIntValue token
        tt $ year v
      _ -> Nothing
  }

ruleNamedmonthDayofmonthNonOrdinal :: Rule
ruleNamedmonthDayofmonthNonOrdinal = Rule
  { name = "<named-month> <day-of-month> (non ordinal)"
  , pattern =
    [ Predicate isAMonth
    , Predicate isDOMInteger
    ]
  , prod = \tokens -> case tokens of
      (Token Time td:token:_) -> Token Time <$> intersectDOM td token
      _ -> Nothing
  }

ruleAbsorptionOfAfterNamedDay :: Rule
ruleAbsorptionOfAfterNamedDay = Rule
  { name = "absorption of , after named day"
  , pattern =
    [ Predicate isADayOfWeek
    , regex ","
    ]
  , prod = \tokens -> case tokens of
      (x:_) -> Just x
      _ -> Nothing
  }

ruleLastDayofweekOfTime :: Rule
ruleLastDayofweekOfTime = Rule
  { name = "last <day-of-week> of <time>"
  , pattern =
    [ regex "sista"
    , Predicate isADayOfWeek
    , regex "av|i"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (_:Token Time td1:_:Token Time td2:_) ->
        tt $ predLastOf td1 td2
      _ -> Nothing
  }

ruleCycleBeforeTime :: Rule
ruleCycleBeforeTime = Rule
  { name = "<cycle> before <time>"
  , pattern =
    [ dimension TimeGrain
    , regex "fÃ¶re"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token TimeGrain grain:_:Token Time td:_) ->
        tt $ cycleNthAfter False grain (-1) td
      _ -> Nothing
  }

ruleDdmmyyyy :: Rule
ruleDdmmyyyy = Rule
  { name = "dd/mm/yyyy"
  , pattern =
    [ regex "(3[01]|[12]\\d|0?[1-9])[\\/-](0?[1-9]|1[0-2])[\\/-](\\d{2,4})"
    ]
  , prod = \tokens -> case tokens of
      (Token RegexMatch (GroupMatch (m1:m2:m3:_)):_) -> do
        y <- parseInt m3
        m <- parseInt m2
        d <- parseInt m1
        tt $ yearMonthDay y m d
      _ -> Nothing
  }

ruleTimeofdayTimeofdayInterval :: Rule
ruleTimeofdayTimeofdayInterval = Rule
  { name = "<time-of-day> - <time-of-day> (interval)"
  , pattern =
    [ Predicate $ and . sequence [isNotLatent, isATimeOfDay]
    , regex "\\-|till|till och med|tom"
    , Predicate isATimeOfDay
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:_:Token Time td2:_) ->
        Token Time <$> interval TTime.Closed td1 td2
      _ -> Nothing
  }

ruleDurationAfterTime :: Rule
ruleDurationAfterTime = Rule
  { name = "<duration> after <time>"
  , pattern =
    [ dimension Duration
    , regex "efter"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Duration dd:_:Token Time td:_) ->
        tt $ durationAfter dd td
      _ -> Nothing
  }

ruleOrdinalQuarter :: Rule
ruleOrdinalQuarter = Rule
  { name = "<ordinal> quarter"
  , pattern =
    [ dimension Ordinal
    , Predicate $ isGrain TG.Quarter
    ]
  , prod = \tokens -> case tokens of
      (Token Ordinal OrdinalData{TOrdinal.value = v}:_) -> tt .
        cycleNthAfter False TG.Quarter (v - 1) $ cycleNth TG.Year 0
      _ -> Nothing
  }

ruleTheDayofmonthOrdinal :: Rule
ruleTheDayofmonthOrdinal = Rule
  { name = "the <day-of-month> (ordinal)"
  , pattern =
    [ regex "den"
    , Predicate isDOMOrdinal
    ]
  , prod = \tokens -> case tokens of
      (_:
       Token Ordinal OrdinalData{TOrdinal.value = v}:
       _) -> tt $ dayOfMonth v
      _ -> Nothing
  }

ruleDurationBeforeTime :: Rule
ruleDurationBeforeTime = Rule
  { name = "<duration> before <time>"
  , pattern =
    [ dimension Duration
    , regex "fÃ¶re"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Duration dd:_:Token Time td:_) ->
        tt $ durationBefore dd td
      _ -> Nothing
  }

rulePartofdayOfTime :: Rule
rulePartofdayOfTime = Rule
  { name = "<part-of-day> of <time>"
  , pattern =
    [ Predicate isAPartOfDay
    , regex "(en |ten )?den"
    , dimension Time
    ]
  , prod = \tokens -> case tokens of
      (Token Time td1:_:Token Time td2:_) ->
        Token Time <$> intersect td1 td2
      _ -> Nothing
  }

ruleEoyendOfYear :: Rule
ruleEoyendOfYear = Rule
  { name = "EOY|End of year"
  , pattern =
    [ regex "EOY"
    ]
  , prod = \_ -> tt $ cycleNth TG.Year 1
  }

ruleTomorrow :: Rule
ruleTomorrow = Rule
  { name = "tomorrow"
  , pattern =
    [ regex "i morgon|imorgon"
    ]
  , prod = \_ -> tt $ cycleNth TG.Day 1
  }

ruleTimeofdayOclock :: Rule
ruleTimeofdayOclock = Rule
  { name = "<time-of-day> o'clock"
  , pattern =
    [ Predicate isATimeOfDay
    , regex "( )?h"
    ]
  , prod = \tokens -> case tokens of
      (Token Time td:_) ->
        tt $ notLatent td
      _ -> Nothing
  }

ruleDayofmonthordinalNamedmonthYear :: Rule
ruleDayofmonthordinalNamedmonthYear = Rule
  { name = "<day-of-month>(ordinal) <named-month> year"
  , pattern =
    [ Predicate isDOMOrdinal
    , Predicate isAMonth
    , regex "(\\d{2,4})"
    ]
  , prod = \tokens -> case tokens of
      (token:
       Token Time td:
       Token RegexMatch (GroupMatch (match:_)):
       _) -> do
         y <- parseInt match
         dom <- intersectDOM td token
         Token Time <$> intersect dom (year y)
      _ -> Nothing
  }

ruleHhmmss :: Rule
ruleHhmmss = Rule
  { name = "hh:mm:ss"
  , pattern =
    [ regex "((?:[01]?\\d)|(?:2[0-3]))[:.]([0-5]\\d)[:.]([0-5]\\d)"
    ]
  , prod = \tokens -> case tokens of
      (Token RegexMatch (GroupMatch (hh:mm:ss:_)):_) -> do
        h <- parseInt hh
        m <- parseInt mm
        s <- parseInt ss
        tt $ hourMinuteSecond False h m s
      _ -> Nothing
  }

ruleTimezone :: Rule
ruleTimezone = Rule
  { name = "<time> timezone"
  , pattern =
    [ Predicate $ and . sequence [isNotLatent, isATimeOfDay]
    , regex "\\b(YEKT|YEKST|YAKT|YAKST|WITA|WIT|WIB|WGT|WGST|WFT|WET|WEST|WAT|WAST|VUT|VLAT|VLAST|VET|UZT|UYT|UYST|UTC|ULAT|TVT|TMT|TLT|TKT|TJT|TFT|TAHT|SST|SRT|SGT|SCT|SBT|SAST|SAMT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PHT|PHOT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|NCT|MYT|MVT|MUT|MST|MSK|MSD|MMT|MHT|MDT|MAWT|MART|MAGT|MAGST|LINT|LHST|LHDT|KUYT|KST|KRAT|KRAST|KGT|JST|IST|IRST|IRKT|IRKST|IRDT|IOT|IDT|ICT|HOVT|HKT|GYT|GST|GMT|GILT|GFT|GET|GAMT|GALT|FNT|FKT|FKST|FJT|FJST|EST|EGT|EGST|EET|EEST|EDT|ECT|EAT|EAST|EASST|DAVT|ChST|CXT|CVT|CST|COT|CLT|CLST|CKT|CHAST|CHADT|CET|CEST|CDT|CCT|CAT|CAST|BTT|BST|BRT|BRST|BOT|BNT|AZT|AZST|AZOT|AZOST|AWST|AWDT|AST|ART|AQTT|ANAT|ANAST|AMT|AMST|ALMT|AKST|AKDT|AFT|AEST|AEDT|ADT|ACST|ACDT)\\b"
    ]
  , prod = \tokens -> case tokens of
      (Token Time td:
       Token RegexMatch (GroupMatch (tz:_)):
       _) -> Token Time <$> inTimezone (Text.toUpper tz) td
      _ -> Nothing
  }

rules :: [Rule]
rules =
  [ ruleADuration
  , ruleAboutTimeofday
  , ruleAbsorptionOfAfterNamedDay
  , ruleAfterDuration
  , ruleAfterLunch
  , ruleAfterTimeofday
  , ruleAfterWork
  , ruleAfternoon
  , ruleAtTimeofday
  , ruleBetweenDatetimeAndDatetimeInterval
  , ruleBetweenTimeofdayAndTimeofdayInterval
  , ruleByTheEndOfTime
  , ruleChristmas
  , ruleChristmasEve
  , ruleCycleAfterTime
  , ruleCycleBeforeTime
  , ruleDatetimeDatetimeInterval
  , ruleDayofmonthNonOrdinalNamedmonth
  , ruleDayofmonthNonOrdinalOfNamedmonth
  , ruleDayofmonthOrdinal
  , ruleDayofmonthOrdinalOfNamedmonth
  , ruleDayofmonthordinalNamedmonth
  , ruleDayofmonthordinalNamedmonthYear
  , ruleDdmm
  , ruleDdmmyyyy
  , ruleDurationAfterTime
  , ruleDurationAgo
  , ruleDurationBeforeTime
  , ruleDurationFromNow
  , ruleEomendOfMonth
  , ruleEoyendOfYear
  , ruleEvening
  , ruleExactlyTimeofday
  , ruleFromDatetimeDatetimeInterval
  , ruleFromTimeofdayTimeofdayInterval
  , ruleHhmm
  , ruleHhmmss
  , ruleHourofdayIntegerAsRelativeMinutes
  , ruleHourofdayQuarter
  , ruleHourofdayHalf
  , ruleInDuration
  , ruleInduringThePartofday
  , ruleInduringThePartofday2
  , ruleIntersect
  , ruleIntersectBy
  , ruleIntersectByOfFromS
  , ruleLastCycle
  , ruleLastCycleOfTime
  , ruleLastDayofweekOfTime
  , ruleLastNCycle
  , ruleLastTime
  , ruleLastYear
  , ruleLunch
  , ruleMidnighteodendOfDay
  , ruleMonthDdddInterval
  , ruleMorning
  , ruleNamedmonthDayofmonthNonOrdinal
  , ruleNamedmonthDayofmonthOrdinal
  , ruleNewYearsDay
  , ruleNewYearsEve
  , ruleNextCycle
  , ruleNextNCycle
  , ruleNextTime
  , ruleNight
  , ruleNoon
  , ruleNow
  , ruleNthTimeAfterTime
  , ruleNthTimeAfterTime2
  , ruleNthTimeOfTime
  , ruleNthTimeOfTime2
  , ruleOnANamedday
  , ruleOnDate
  , ruleOrdinalCycleAfterTime
  , ruleOrdinalCycleOfTime
  , ruleOrdinalQuarter
  , ruleOrdinalQuarterYear
  , rulePartofdayOfTime
  , ruleRelativeMinutesAfterpastIntegerHourofday
  , ruleQuarterAfterpastIntegerHourofday
  , ruleHalfAfterpastIntegerHourofday
  , ruleRelativeMinutesTotillbeforeIntegerHourofday
  , ruleQuarterTotillbeforeIntegerHourofday
  , ruleHalfTotillbeforeIntegerHourofday
  , ruleTheCycleAfterTime
  , ruleTheCycleBeforeTime
  , ruleTheCycleOfTime
  , ruleTheDayAfterTomorrow
  , ruleTheDayBeforeYesterday
  , ruleTheDayofmonthNonOrdinal
  , ruleTheDayofmonthOrdinal
  , ruleTheIdesOfNamedmonth
  , ruleTheOrdinalCycleAfterTime
  , ruleTheOrdinalCycleOfTime
  , ruleThisCycle
  , ruleThisPartofday
  , ruleThisTime
  , ruleThisnextDayofweek
  , ruleLastDayofweek
  , ruleTimeAfterNext
  , ruleTimeBeforeLast
  , ruleTimePartofday
  , ruleTimeofdayApproximately
  , ruleTimeofdayLatent
  , ruleTimeofdayOclock
  , ruleTimeofdaySharp
  , ruleTimeofdayTimeofdayInterval
  , ruleToday
  , ruleTomorrow
  , ruleTonight
  , ruleUntilTimeofday
  , ruleWeekend
  , ruleWithinDuration
  , ruleYear
  , ruleYearLatent
  , ruleYearLatent2
  , ruleYesterday
  , ruleYyyymmdd
  , ruleTimezone
  ]
  ++ ruleDaysOfWeek
  ++ ruleMonths
  ++ ruleSeasons


-- 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.Time.TimeZone.Parse
  ( parseTimezone
  ) where

import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import Data.String
import Data.Text (Text)
import Data.Time (TimeZone(..))
import Prelude

-- `TimeZone` reads anything but only accepts timezones known
-- from the provided locale.
parseTimezone :: Text -> Maybe TimeZone
parseTimezone x = HashMap.lookup x tzs

tzs :: HashMap Text TimeZone
tzs = HashMap.fromList
  [ ( "YEKT", TimeZone 300 False "YEKT" )
  , ( "YEKST", TimeZone 360 True "YEKST" )
  , ( "YAKT", TimeZone 540 False "YAKT" )
  , ( "YAKST", TimeZone 600 True "YAKST" )
  , ( "WITA", TimeZone 480 False "WITA" )
  , ( "WIT", TimeZone 420 False "WIT" )
  , ( "WIB", TimeZone 420 False "WIB" )
  , ( "WGT", TimeZone (-180) False "WGT" )
  , ( "WGST", TimeZone (-120) True "WGST" )
  , ( "WFT", TimeZone 720 False "WFT" )
  , ( "WET", TimeZone 0 False "WET" )
  , ( "WEST", TimeZone 60 True "WEST" )
  , ( "WAT", TimeZone 60 False "WAT" )
  , ( "WAST", TimeZone 120 True "WAST" )
  , ( "VUT", TimeZone 660 False "VUT" )
  , ( "VLAT", TimeZone 660 False "VLAT" )
  , ( "VLAST", TimeZone 660 True "VLAST" )
  , ( "VET", TimeZone (-270) False "VET" )
  , ( "UZT", TimeZone 300 False "UZT" )
  , ( "UYT", TimeZone (-180) False "UYT" )
  , ( "UYST", TimeZone (-120) True "UYST" )
  , ( "UTC", TimeZone 0 False "UTC" )
  , ( "ULAT", TimeZone 480 False "ULAT" )
  , ( "TVT", TimeZone 720 False "TVT" )
  , ( "TMT", TimeZone 300 False "TMT" )
  , ( "TLT", TimeZone 540 False "TLT" )
  , ( "TKT", TimeZone 780 False "TKT" )
  , ( "TJT", TimeZone 300 False "TJT" )
  , ( "TFT", TimeZone 300 False "TFT" )
  , ( "TAHT", TimeZone (-600) False "TAHT" )
  , ( "SST", TimeZone (-660) False "SST" )
  , ( "SRT", TimeZone (-180) False "SRT" )
  , ( "SGT", TimeZone 480 False "SGT" )
  , ( "SCT", TimeZone 240 False "SCT" )
  , ( "SBT", TimeZone 660 False "SBT" )
  , ( "SAST", TimeZone 120 False "SAST" )
  , ( "SAMT", TimeZone 300 False "SAMT" )
  , ( "RET", TimeZone 240 False "RET" )
  , ( "PYT", TimeZone (-240) False "PYT" )
  , ( "PYST", TimeZone (-180) True "PYST" )
  , ( "PWT", TimeZone (-420) True "PWT" )
  , ( "PST", TimeZone (-480) False "PST" )
  , ( "PONT", TimeZone 660 False "PONT" )
  , ( "PMST", TimeZone (-180) False "PMST" )
  , ( "PMDT", TimeZone (-120) True "PMDT" )
  , ( "PKT", TimeZone 300 False "PKT" )
  , ( "PHT", TimeZone 480 False "PHT" )
  , ( "PHOT", TimeZone 780 False "PHOT" )
  , ( "PGT", TimeZone 600 False "PGT" )
  , ( "PETT", TimeZone 720 False "PETT" )
  , ( "PETST", TimeZone 720 True "PETST" )
  , ( "PET", TimeZone (-300) False "PET" )
  , ( "PDT", TimeZone (-420) False "PDT" )
  , ( "OMST", TimeZone 360 False "OMST" )
  , ( "OMSST", TimeZone 420 True "OMSST" )
  , ( "NZST", TimeZone 720 False "NZST" )
  , ( "NZDT", TimeZone 780 False "NZDT" )
  , ( "NUT", TimeZone (-660) False "NUT" )
  , ( "NST", TimeZone (-660) False "NST" )
  , ( "NPT", TimeZone (-600) True "NPT" )
  , ( "NOVT", TimeZone 360 False "NOVT" )
  , ( "NOVST", TimeZone 420 True "NOVST" )
  , ( "NFT", TimeZone 690 False "NFT" )
  , ( "NDT", TimeZone (-150) True "NDT" )
  , ( "NCT", TimeZone 660 False "NCT" )
  , ( "MYT", TimeZone 480 False "MYT" )
  , ( "MVT", TimeZone 300 False "MVT" )
  , ( "MUT", TimeZone 240 False "MUT" )
  , ( "MST", TimeZone (-420) False "MST" )
  , ( "MSK", TimeZone 180 False "MSK" )
  , ( "MSD", TimeZone 240 True "MSD" )
  , ( "MMT", TimeZone 390 False "MMT" )
  , ( "MHT", TimeZone 720 False "MHT" )
  , ( "MDT", TimeZone (-360) True "MDT" )
  , ( "MAWT", TimeZone 300 False "MAWT" )
  , ( "MART", TimeZone (-570) False "MART" )
  , ( "MAGT", TimeZone 600 False "MAGT" )
  , ( "MAGST", TimeZone 720 True "MAGST" )
  , ( "LINT", TimeZone 840 False "LINT" )
  , ( "LHST", TimeZone 630 False "LHST" )
  , ( "LHDT", TimeZone 660 True "LHDT" )
  , ( "KUYT", TimeZone 180 False "KUYT" )
  , ( "KST", TimeZone 540 False "KST" )
  , ( "KRAT", TimeZone 420 False "KRAT" )
  , ( "KRAST", TimeZone 480 True "KRAST" )
  , ( "KGT", TimeZone 360 False "KGT" )
  , ( "JST", TimeZone 540 False "JST" )
  , ( "IST", TimeZone 330 False "IST" )
  , ( "IRST", TimeZone 210 False "IRST" )
  , ( "IRKT", TimeZone 480 False "IRKT" )
  , ( "IRKST", TimeZone 540 True "IRKST" )
  , ( "IRDT", TimeZone 270 True "IRDT" )
  , ( "IOT", TimeZone 360 False "IOT" )
  , ( "IDT", TimeZone 180 True "IDT" )
  , ( "ICT", TimeZone 420 False "ICT" )
  , ( "HOVT", TimeZone 420 False "HOVT" )
  , ( "HKT", TimeZone 480 False "HKT" )
  , ( "GYT", TimeZone (-240) False "GYT" )
  , ( "GST", TimeZone 240 False "GST" )
  , ( "GMT", TimeZone 0 False "GMT" )
  , ( "GILT", TimeZone 720 False "GILT" )
  , ( "GFT", TimeZone (-180) False "GFT" )
  , ( "GET", TimeZone 240 False "GET" )
  , ( "GAMT", TimeZone (-540) False "GAMT" )
  , ( "GALT", TimeZone (-360) False "GALT" )
  , ( "FNT", TimeZone (-120) False "FNT" )
  , ( "FKT", TimeZone (-240) False "FKT" )
  , ( "FKST", TimeZone (-180) False "FKST" )
  , ( "FJT", TimeZone 720 False "FJT" )
  , ( "FJST", TimeZone 780 True "FJST" )
  , ( "EST", TimeZone (-300) False "EST" )
  , ( "EGT", TimeZone (-60) False "EGT" )
  , ( "EGST", TimeZone 0 True "EGST" )
  , ( "EET", TimeZone 120 False "EET" )
  , ( "EEST", TimeZone 180 True "EEST" )
  , ( "EDT", TimeZone (-240) True "EDT" )
  , ( "ECT", TimeZone (-300) False "ECT" )
  , ( "EAT", TimeZone 180 False "EAT" )
  , ( "EAST", TimeZone (-300) False "EAST" )
  , ( "EASST", TimeZone (-300) True "EASST" )
  , ( "DAVT", TimeZone 420 False "DAVT" )
  , ( "ChST", TimeZone 600 False "ChST" )
  , ( "CXT", TimeZone 420 False "CXT" )
  , ( "CVT", TimeZone (-60) False "CVT" )
  , ( "CST", TimeZone (-360) False "CST" )
  , ( "COT", TimeZone (-300) False "COT" )
  , ( "CLT", TimeZone (-180) False "CLT" )
  , ( "CLST", TimeZone (-180) True "CLST" )
  , ( "CKT", TimeZone (-600) False "CKT" )
  , ( "CHAST", TimeZone 765 False "CHAST" )
  , ( "CHADT", TimeZone 825 True "CHADT" )
  , ( "CET", TimeZone 60 False "CET" )
  , ( "CEST", TimeZone 120 True "CEST" )
  , ( "CDT", TimeZone (-300) True "CDT" )
  , ( "CCT", TimeZone 390 False "CCT" )
  , ( "CAT", TimeZone 120 False "CAT" )
  , ( "CAST", TimeZone 180 True "CAST" )
  , ( "BTT", TimeZone 360 False "BTT" )
  , ( "BST", TimeZone 60 False "BST" )
  , ( "BRT", TimeZone (-180) False "BRT" )
  , ( "BRST", TimeZone (-120) True "BRST" )
  , ( "BOT", TimeZone (-240) False "BOT" )
  , ( "BNT", TimeZone 480 False "BNT" )
  , ( "AZT", TimeZone 240 False "AZT" )
  , ( "AZST", TimeZone 300 True "AZST" )
  , ( "AZOT", TimeZone (-60) False "AZOT" )
  , ( "AZOST", TimeZone 0 True "AZOST" )
  , ( "AWST", TimeZone 480 False "AWST" )
  , ( "AWDT", TimeZone 540 True "AWDT" )
  , ( "AST", TimeZone (-240) False "AST" )
  , ( "ART", TimeZone (-180) False "ART" )
  , ( "AQTT", TimeZone 300 False "AQTT" )
  , ( "ANAT", TimeZone 720 False "ANAT" )
  , ( "ANAST", TimeZone 720 True "ANAST" )
  , ( "AMT", TimeZone 240 False "AMT" )
  , ( "AMST", TimeZone 300 True "AMST" )
  , ( "ALMT", TimeZone 360 False "ALMT" )
  , ( "AKST", TimeZone (-540) False "AKST" )
  , ( "AKDT", TimeZone (-480) True "AKDT" )
  , ( "AFT", TimeZone 270 False "AFT" )
  , ( "AEST", TimeZone 600 False "AEST" )
  , ( "AEDT", TimeZone 660 True "AEDT" )
  , ( "ADT", TimeZone (-180) True "ADT" )
  , ( "ACST", TimeZone 570 False "ACST" )
  , ( "ACDT", TimeZone 630 True "ACDT" )
  ]


-- 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.Time.TR.Corpus
  ( corpus
  ) where

import Data.String
import Prelude

import Duckling.Locale
import Duckling.Resolve
import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.TimeGrain.Types
    ( Grain(Minute, Hour, Year, Quarter, Week, Month, Day, Second) )

context :: Context
context = testContext {locale = makeLocale TR Nothing}

-- Tuesday Feb 12, 2013 at 4:30am is the "now" for the tests
corpus :: Corpus
corpus = (context, testOptions, allExamples)

allExamples :: [Example]
allExamples = concat
  [ examples (datetime (2013, 2, 12, 4, 30, 0) Second)
             [ "ÅŸimdi"
             , "ÅŸu an"
             ]
  , examples (datetime (2013, 2, 12, 0, 0, 0) Day)
             [ "bugÃ¼n"
             ]
  , examples (datetime (2014, 1, 1, 0, 0, 0) Year)
             [ "2014"
             ]
  , examples (datetime (2013, 2, 11, 0, 0, 0) Day)
             [ "dÃ¼n"
             ]
  , examples (datetime (2013, 2, 13, 0, 0, 0) Day)
             [ "yarÄ±n"
             ]
  , examples (datetime (2013, 2, 14, 0, 0, 0) Day)
             [ "yarÄ±ndan sonraki"
             , "yarÄ±ndan sonraki gÃ¼n"
             ]
  , examples (datetime (2013, 3, 1, 0, 0, 0) Month)
             [ "ay sonu"
             ]
  , examples (datetime (2014, 1, 1, 0, 0, 0) Year)
             [ "yÄ±l sonu"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Day)
             [ "pazartesi"
             , "bu pazartesi"
             , "18 ÅŸubat pazartesi"
             , "ÅŸubat 18 pazartesi"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "salÄ±"
             , "sal"
             , "bu salÄ±"
             , "19 ÅŸubat salÄ±"
             ]
  , examples (datetime (2013, 2, 14, 0, 0, 0) Day)
             [ "perÅŸembe"
             , "per"
             ]
  , examples (datetime (2013, 2, 15, 0, 0, 0) Day)
             [ "cuma"
             , "cum"
             ]
  , examples (datetime (2013, 2, 16, 0, 0, 0) Day)
             [ "cumartesi"
             , "cmt"
             ]
  , examples (datetime (2013, 2, 17, 0, 0, 0) Day)
             [ "pazar"
             ]
  , examples (datetime (2013, 3, 3, 0, 0, 0) Day)
             [ "martÄ±n Ã¼Ã§Ã¼"
             , "3 mart"
             ]
  , examples (datetime (2013, 3, 15, 0, 0, 0) Day)
             [ "martÄ±n ortasÄ±"
             ]
  , examples (datetime (2013, 2, 13, 0, 0, 0) Day)
             [ "ÅŸubatÄ±n ortasÄ±"
             ]
  , examples (datetime (2015, 3, 3, 0, 0, 0) Day)
             [ "mart 3 2015"
             , "mart Ã¼Ã§ 2015"
             , "3 mart 2015"
             , "Ã¼Ã§ mart 2015"
             , "3/3/2015"
             , "2015-3-3"
             , "2015-03-03"
             ]
  , examples (datetime (2013, 8, 8, 0, 0, 0) Day)
             [ "AÄŸu 8"
             , "AÄŸustos 8"
             ]
  , examples (datetime (2014, 7, 18, 0, 0, 0) Day)
             [ "cuma temmuz 18"
             , "temmuz 18 cuma"
             , "18 temmuz cuma"
             ]
  , examples (datetime (2014, 10, 1, 0, 0, 0) Month)
             [ "Ekim 2014"
             ]
  , examples (datetime (2015, 4, 14, 0, 0, 0) Day)
             [ "14 nisan 2015"
             , "nisan 14 2015"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "Ã¶nÃ¼mÃ¼zdeki salÄ±"
             , "sonraki salÄ±"
             ]
  , examples (datetime (2013, 2, 15, 0, 0, 0) Day)
             [ "sonraki cuma"
             ]
  , examples (datetime (2013, 3, 1, 0, 0, 0) Month)
             [ "Ã¶nÃ¼mÃ¼zdeki mart"
             , "sonraki mart"
             , "sonraki ay"
             , "Ã¶nÃ¼mÃ¼zdeki ay"
             ]
  , examples (datetime (2013, 3, 1, 0, 0, 0) Month)
             [ "Ã¶nÃ¼mÃ¼zdeki mart"
             ]
  , examples (datetime (2013, 2, 10, 0, 0, 0) Day)
             [ "pazar 10 ÅŸubat"
             ]
  , examples (datetime (2013, 2, 11, 0, 0, 0) Week)
             [ "bu hafta"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Week)
             [ "Ã¶nÃ¼mÃ¼zdeki hafta"
             ]
  , examples (datetime (2013, 2, 4, 0, 0, 0) Week)
             [ "geÃ§en hafta"
             , "geÃ§tiÄŸimiz hafta"
             , "Ã¶nceki hafta"
             ]
  , examples (datetime (2013, 2, 18, 0, 0, 0) Week)
             [ "sonraki hafta"
             , "gelecek hafta"
             , "Ã¶nÃ¼mÃ¼zdeki hafta"
             ]
  , examples (datetime (2013, 1, 1, 0, 0, 0) Month)
             [ "geÃ§en ay"
             , "geÃ§tiÄŸimiz ay"
             , "Ã¶nceki ay"
             ]
  , examples (datetime (2013, 3, 1, 0, 0, 0) Month)
             [ "Ã¶nÃ¼mÃ¼zdeki ay"
             , "sonraki ay"
             , "gelecek ay"
             ]
  , examples (datetime (2013, 1, 1, 0, 0, 0) Quarter)
             [ "bu Ã§eyrek yÄ±l"
             ]
  , examples (datetime (2013, 4, 1, 0, 0, 0) Quarter)
             [ "sonraki Ã§eyrek yÄ±l"
             ]
  , examples (datetime (2013, 7, 1, 0, 0, 0) Quarter)
             [ "Ã¼Ã§Ã¼ncÃ¼ Ã§eyrek yÄ±l"
             ]
  , examples (datetime (2013, 10, 1, 0, 0, 0) Quarter)
             [ "dÃ¶rdÃ¼ncÃ¼ Ã§eyrek yÄ±l"
             ]
  , examples (datetime (2012, 1, 1, 0, 0, 0) Year)
             [ "geÃ§en yÄ±l"
             ]
  , examples (datetime (2013, 1, 1, 0, 0, 0) Year)
             [ "bu yÄ±l"
             ]
  , examples (datetime (2014, 1, 1, 0, 0, 0) Year)
             [ "sonraki yÄ±l"
             ]
  , examples (datetime (2013, 2, 10, 0, 0, 0) Day)
             [ "geÃ§en pazar"
             , "geÃ§en hafta pazar"
             ]
  , examples (datetime (2013, 2, 5, 0, 0, 0) Day)
             [ "geÃ§en salÄ±"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "Ã¶nÃ¼mÃ¼zdeki salÄ±"
             , "gelecek salÄ±"
             , "sonraki salÄ±"
             ]
  , examples (datetime (2013, 2, 20, 0, 0, 0) Day)
             [ "gelecek hafta Ã§arÅŸamba"
             ]
  , examples (datetime (2013, 2, 14, 0, 0, 0) Day)
             [ "yarÄ±ndan sonraki gÃ¼n"
             ]
  , examples (datetime (2013, 2, 13, 17, 0, 0) Hour)
             [ "sonraki gÃ¼n saat 17"
             ]
  , examples (datetime (2013, 2, 10, 0, 0, 0) Day)
             [ "dÃ¼n deÄŸil evvelsi gÃ¼n"
             , "dÃ¼nden Ã¶nceki gÃ¼n"
             , "Ã¶bÃ¼rki gÃ¼n"
             , "Ã¶bÃ¼rsÃ¼ gÃ¼n"
             ]
  , examples (datetime (2013, 2, 10, 8, 0, 0) Hour)
             [ "dÃ¼nden Ã¶nceki gÃ¼n saat 8"
             ]
  , examples (datetime (2013, 10, 1, 0, 0, 0) Day)
             [ "ekimin birinci salÄ±"
             , "ekimin birinci salÄ±sÄ±"
             ]
  , examples (datetime (2014, 10, 1, 0, 0, 0) Day)
             [ "ekim 2014 birinci Ã§arÅŸambasÄ±"
             ]
  , examples (datetime (2013, 2, 12, 15, 0, 0) Hour)
             [ "saat 3"
             ]
  , examples (datetime (2013, 2, 12, 10, 0, 0) Hour)
             [ "sabah saat 10"
             ]
  , examples (datetime (2013, 2, 13, 3, 18, 0) Minute)
             [ "3:18"
             , "03:18"
             ]
  , examples (datetime (2013, 2, 12, 15, 0, 0) Hour)
             [ "saat 15"
             ]
  , examples (datetime (2013, 2, 12, 15, 0, 0) Minute)
             [ "15:00"
             ]
  , examples (datetime (2013, 2, 12, 15, 3, 0) Minute)
             [ "saat 15:03"
             , "15:03"
             ]
  , examples (datetime (2013, 2, 12, 9, 59, 0) Minute)
             [ "saat dokuz elli dokuz"
             ]
  , examples (datetime (2013, 9, 20, 19, 30, 0) Minute)
             [ "20 eylÃ¼l cuma saat 19:30"
             ]
  , examples (datetime (2013, 2, 16, 9, 0, 0) Hour)
             [ "cumartesi saat 9"
             , "cumartesi sabah saat 9"
             ]
  , examples (datetime (2014, 7, 18, 19, 0, 0) Minute)
             [ "18 temmuz 2014 cuma saat 19:00"
             , "saat 19:00 18 temmuz 2014 cuma"
             ]
  , examples (datetime (2013, 2, 12, 4, 30, 1) Second)
             [ "bir saniye iÃ§inde"
             , "bir saniye iÃ§erisinde"
             , "1 saniye iÃ§erisinde"
             , "1 saniye iÃ§inde"
             ]
  , examples (datetime (2013, 2, 12, 4, 31, 0) Second)
             [ "bir dakika iÃ§inde"
             , "bir dakika iÃ§erisinde"
             , "1 dakika iÃ§inde"
             , "1 dakika iÃ§erisinde"
             ]
  , examples (datetime (2013, 2, 12, 4, 32, 0) Second)
             [ "2 dakika iÃ§inde"
             ]
  , examples (datetime (2013, 2, 12, 5, 30, 0) Second)
             [ "60 dakika iÃ§inde"
             ]
  , examples (datetime (2013, 2, 12, 5, 30, 0) Minute)
             [ "bir saat iÃ§inde"
             ]
  , examples (datetime (2013, 2, 13, 4, 0, 0) Hour)
             [ "bir gÃ¼n sonra"
             ]
  , examples (datetime (2013, 2, 19, 4, 0, 0) Hour)
             [ "7 gÃ¼n iÃ§inde"
             ]
  , examples (datetime (2017, 2, 1, 17, 0, 0) Hour)
             [ "4 yÄ±l sonra saat 17"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "1 hafta iÃ§inde"
             , "1 hafta sonra"
             ]
  , examples (datetime (2013, 2, 5, 4, 0, 0) Hour)
             [ "7 gÃ¼n Ã¶nce"
             ]
  , examples (datetime (2013, 1, 29, 4, 0, 0) Hour)
             [ "14 gÃ¼n Ã¶nce"
             ]
  , examples (datetime (2013, 1, 29, 0, 0, 0) Day)
             [ "iki hafta Ã¶nce"
             ]
  , examples (datetime (2013, 2, 5, 0, 0, 0) Day)
             [ "bir hafta Ã¶nce"
             , "1 hafta Ã¶nce"
             ]
  , examples (datetime (2013, 1, 22, 0, 0, 0) Day)
             [ "Ã¼Ã§ hafta Ã¶nce"
             ]
  , examples (datetime (2012, 11, 12, 0, 0, 0) Day)
             [ "Ã¼Ã§ ay Ã¶nce"
             ]
  , examples (datetime (2011, 2, 1, 0, 0, 0) Month)
             [ "iki yÄ±l Ã¶nce"
             ]
  , examples (datetime (2013, 2, 19, 4, 0, 0) Hour)
             [ "7 gÃ¼n sonra"
             ]
  , examples (datetime (2013, 2, 26, 4, 0, 0) Hour)
             [ "14 gÃ¼n sonra"
             ]
  , examples (datetime (2013, 2, 26, 0, 0, 0) Day)
             [ "iki hafta sonra"
             ]
  , examples (datetime (2013, 2, 19, 0, 0, 0) Day)
             [ "bir hafta sonra"
             , "1 hafta sonra"
             ]
  , examples (datetime (2013, 3, 5, 0, 0, 0) Day)
             [ "Ã¼Ã§ hafta sonra"
             ]
  , examples (datetime (2013, 5, 12, 0, 0, 0) Day)
             [ "Ã¼Ã§ ay sonra"
             ]
  , examples (datetime (2015, 2, 1, 0, 0, 0) Month)
             [ "iki yÄ±l sonra"
             ]
  , examples (datetime (2014, 1, 1, 0, 0, 0) Day)
             [ "yÄ±lbaÅŸÄ±ndan sonra bir yÄ±l"
             , "yÄ±lbaÅŸÄ±ndan bir yÄ±l sonra"
             ]
  , examples (datetimeInterval ((2013, 12, 18, 0, 0, 0), (2013, 12, 29, 0, 0, 0)) Day)
             [ "18 aralÄ±ktan itibaren 10 gÃ¼n boyunca"
             , "18 aralÄ±ktan itibaren 10 gÃ¼n sÃ¼resince"
             ]
  , examples (datetime (2013, 2, 12, 16, 30, 0) Minute)
             [ "saat 16'dan 30 dakika sonra"
             ]
  , examples (datetimeInterval ((2013, 6, 21, 0, 0, 0), (2013, 9, 24, 0, 0, 0)) Day)
             [ "bu yaz"
             ]
  , examples (datetimeInterval ((2012, 12, 21, 0, 0, 0), (2013, 3, 21, 0, 0, 0)) Day)
             [ "bu kÄ±ÅŸ"
             ]
  , examples (datetimeInterval ((2011, 12, 21, 0, 0, 0), (2012, 03, 21, 0, 0, 0)) Day)
             [ "geÃ§en kÄ±ÅŸ"
             , "Ã¶nceki kÄ±ÅŸ"
             ]
  , examples (datetimeInterval ((2013, 3, 20, 0, 0, 0), (2013, 6, 22, 0, 0, 0)) Day)
             [ "gelecek ilkbahar"
             ]
  , examples (datetimeHoliday (2014, 1, 1, 0, 0, 0) Day "YÄ±lbaÅŸÄ±")
             [ "yÄ±lbaÅŸÄ±"
             ]
  , examples (datetimeHoliday (2014, 1, 1, 18, 0, 0) Hour "YÄ±lbaÅŸÄ±")
             [ "yÄ±lbaÅŸÄ± saat 18"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 18, 0, 0), (2013, 2, 13, 0, 0, 0)) Hour)
             [ "bu akÅŸam"
             ]
  , examples (datetimeInterval ((2013, 2, 8, 18, 0, 0), (2013, 2, 11, 0, 0, 0)) Hour)
             [ "geÃ§en hafta sonu"
             ]
  , examples (datetimeInterval ((2013, 2, 13, 18, 0, 0), (2013, 2, 14, 0, 0, 0)) Hour)
             [ "yarÄ±n akÅŸam"
             ]
  , examples (datetimeInterval ((2013, 2, 13, 12, 0, 0), (2013, 2, 13, 14, 0, 0)) Hour)
             [ "yarÄ±n Ã¶ÄŸle yemeÄŸi"
             ]
  , examples (datetimeInterval ((2013, 2, 11, 18, 0, 0), (2013, 2, 12, 0, 0, 0)) Hour)
             [ "dÃ¼n akÅŸam"
             ]
  , examples (datetimeInterval ((2013, 2, 15, 18, 0, 0), (2013, 2, 18, 0, 0, 0)) Hour)
             [ "bu hafta sonu"
             ]
  , examples (datetimeInterval ((2013, 2, 18, 0, 0, 0), (2013, 2, 18, 12, 0, 0)) Hour)
             [ "pazartesi sabah"
             ]
  , examples (datetimeInterval ((2013, 2, 15, 0, 0, 0), (2013, 2, 15, 12, 0, 0)) Hour)
             [ "15 ÅŸubat sabahÄ±"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 29, 58), (2013, 2, 12, 4, 30, 0)) Second)
             [ "son 2 saniye"
             , "son iki saniye"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 30, 1), (2013, 2, 12, 4, 30, 4)) Second)
             [ "sonraki 3 saniye"
             , "sonraki Ã¼Ã§ saniye"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 28, 0), (2013, 2, 12, 4, 30, 0)) Minute)
             [ "son 2 dakika"
             , "son iki dakika"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 3, 0, 0), (2013, 2, 12, 4, 0, 0)) Hour)
             [ "son 1 saat"
             , "son bir saat"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 5, 0, 0), (2013, 2, 12, 8, 0, 0)) Hour)
             [ "sonraki 3 saat"
             , "sonraki Ã¼Ã§ saat"
             ]
  , examples (datetimeInterval ((2013, 2, 10, 0, 0, 0), (2013, 2, 12, 0, 0, 0)) Day)
             [ "son iki gÃ¼n"
             , "son 2 gÃ¼n"
             ]
  , examples (datetimeInterval ((2013, 1, 28, 0, 0, 0), (2013, 2, 11, 0, 0, 0)) Week)
             [ "geÃ§tiÄŸimiz iki hafta"
             , "Ã¶nceki iki hafta"
             ]
  , examples (datetimeInterval ((2013, 2, 18, 0, 0, 0), (2013, 3, 11, 0, 0, 0)) Week)
             [ "Ã¶nÃ¼mÃ¼zdeki Ã¼Ã§ hafta"
             , "sonraki Ã¼Ã§ hafta"
             ]
  , examples (datetimeInterval ((2012, 12, 1, 0, 0, 0), (2013, 2, 1, 0, 0, 0)) Month)
             [ "son 2 ay"
             , "son iki ay"
             ]
  , examples (datetimeInterval ((2011, 1, 1, 0, 0, 0), (2013, 1, 1, 0, 0, 0)) Year)
             [ "son 2 yÄ±l"
             , "son iki yÄ±l"
             ]
  , examples (datetimeInterval ((2014, 1, 1, 0, 0, 0), (2017, 1, 1, 0, 0, 0)) Year)
             [ "Ã¶nÃ¼mÃ¼zdeki Ã¼Ã§ yÄ±l"
             , "Ã¶nÃ¼mÃ¼zdeki 3 yÄ±l"
             ]
  , examples (datetimeInterval ((2013, 8, 8, 0, 0, 0), (2013, 8, 13, 0, 0, 0)) Day)
             [ "8 AÄŸu - 12 AÄŸu"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 9, 30, 0), (2013, 2, 12, 11, 1, 0)) Minute)
             [ "9:30 - 11:00"
             ]
  , examples (datetimeInterval ((2013, 2, 14, 9, 30, 0), (2013, 2, 14, 11, 1, 0)) Minute)
             [ "perÅŸembe 9:30 - 11:00"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 15, 0, 0), (2013, 2, 12, 17, 0, 0)) Hour)
             [ "saat 15-16"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 15, 30, 0), (2013, 2, 12, 18, 1, 0)) Minute)
             [ "saat 15:30 - 18"
             ]
  , examples (datetimeInterval ((2013, 2, 14, 9, 0, 0), (2013, 2, 14, 12, 0, 0)) Hour)
             [ "perÅŸembe saat 9-11"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 11, 30, 0), (2013, 2, 12, 13, 31, 0)) Minute)
             [ "saat 11:30-13:30"
             ]
  , examples (datetime (2013, 9, 21, 13, 30, 0) Minute)
             [ "21 eylÃ¼l cumartesi saat 13:30"
             ]
  , examples (datetime (2013, 2, 26, 0, 0, 0) Day)
             [ "2 hafta iÃ§inde"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 30, 0), (2013, 2, 13, 0, 0, 0)) Second)
             [ "gÃ¼n sonuna kadar"
             ]
  , examples (datetimeInterval ((2013, 2, 12, 4, 30, 0), (2013, 3, 1, 0, 0, 0)) Second)
             [ "ay sonuna kadar"
             ]
  , examples (datetime (2013, 3, 1, 0, 0, 0) Month)
             [ "ay sonunda"
             , "ay sonu"
             ]
  , examples (datetime (2013, 2, 12, 10, 30, 0) Minute)
             [ "saat 10:30 civarÄ±"
             , "10:30 civarÄ±"
             , "yaklaÅŸÄ±k saat 10:30"
             , "saat yaklaÅŸÄ±k 10:30"
             ]
  , examples (datetime (2013, 2, 12, 19, 30, 0) Minute)
             [ "akÅŸam saat 19:30"
             ]
  , examples (datetime (2013, 2, 13, 15, 0, 0) Minute)
             [ "yarÄ±n saat 15:00"
             ]
  , examples (datetimeInterval ((2013, 2, 11, 0, 0, 0), (2013, 2, 17, 0, 0, 0)) Day)
             [ "hafta boyunca"
             ]
  , examples (datetimeHoliday (1950, 7, 16, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "ramazan bayramÄ± 1950"
             , "1950 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (1975, 10, 6, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "1975 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (1988, 5, 16, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "1988 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (2018, 6, 15, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "2018 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (2013, 8, 8, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "2013 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (2046, 8, 4, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "2046 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (2050, 6, 21, 0, 0, 0) Day "Ramazan BayramÄ±")
             [ "2050 ramazan bayramÄ±"
             ]
  , examples (datetimeHoliday (2018, 8, 21, 0, 0, 0) Day "Kurban BayramÄ±")
             [ "2018 kurban bayramÄ±"
             ]
  , examples (datetimeHoliday (1980, 10, 19, 0, 0, 0) Day "Kurban BayramÄ±")
             [ "1980 kurban bayramÄ±"
             ]
  , examples (datetimeHoliday (1966, 4, 1, 0, 0, 0) Day "Kurban BayramÄ±")
             [ "1966 kurban bayramÄ±"
             ]
  , examples (datetimeHoliday (1974, 1, 3, 0, 0, 0) Day "Kurban BayramÄ±")
             [ "1974 kurban bayramÄ±"
             ]
  , examples (datetimeHoliday (2013, 4, 23, 0, 0, 0) Day "Ulusal Egemenlik ve Ã‡ocuk BayramÄ±")
             [ "ulusal egemenlik ve Ã§ocuk bayramÄ±"
             , "Ã§ocuk bayramÄ±"
             ]
  , examples (datetimeHoliday (2013, 5, 1, 0, 0, 0) Day "Emek ve DayanÄ±ÅŸma GÃ¼nÃ¼")
             [ "emek ve dayanÄ±ÅŸma gÃ¼nÃ¼"
             ]
  , examples (datetimeHoliday (2013, 5, 19, 0, 0, 0) Day "AtatÃ¼rkâ€™Ã¼ Anma, GenÃ§lik ve Spor BayramÄ±")
             [ "genÃ§lik ve spor bayramÄ±"
             , "genÃ§lik bayramÄ±"
             , "spor bayramÄ±"
             ]
  , examples (datetimeHoliday (2013, 8, 30, 0, 0, 0) Day "Zafer BayramÄ±")
             [ "zafer bayramÄ±"
             ]
  , examples (datetimeHoliday (2013, 10, 29, 0, 0, 0) Day "Cumhuriyet BayramÄ±")
             [ "cumhuriyet bayramÄ±"
             ]
  ]


-- 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.Time.ZH.CN.Corpus
  ( allExamples
  ) where

import Data.String
import Prelude

import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.Time.Types hiding (Month)
import Duckling.TimeGrain.Types hiding (add)

allExamples :: [Example]
allExamples = concat
  [ examples (datetime (2013, 10, 1, 0, 0, 0) Day)
             [ "å›½åº†"
             , "åœ‹æ…¶"
             , "å›½åº†èŠ‚"
             , "å›½åº†ç¯€"
             , "åœ‹æ…¶èŠ‚"
             , "åœ‹æ…¶ç¯€"
             ]
  , examples (datetimeInterval ((2013, 10, 1, 18, 0, 0), (2013, 10, 2, 0, 0, 0)) Hour)
             [ "å›½åº†èŠ‚æ™šä¸Š"
             , "åœ‹æ…¶ç¯€æ™šä¸Š"
             ]
  ]


-- 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 GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}

module Duckling.Time.ZH.CN.Rules
  ( rules
  ) where

import Prelude

import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Types

ruleNationalDay :: Rule
ruleNationalDay = Rule
  { name = "national day"
  , pattern =
    [ regex "(å›½åº†|åœ‹æ…¶)(èŠ‚|ç¯€)?"
    ]
  , prod = \_ -> tt $ monthDay 10 1
  }

rules :: [Rule]
rules =
  [ ruleNationalDay
  ]


-- 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.Time.ZH.HK.Corpus
  ( allExamples
  ) where

import Data.String
import Prelude

import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.Time.Types hiding (Month)
import Duckling.TimeGrain.Types hiding (add)

allExamples :: [Example]
allExamples = concat
  [ examples (datetime (2013, 10, 1, 0, 0, 0) Day)
             [ "å›½åº†"
             , "åœ‹æ…¶"
             , "å›½åº†èŠ‚"
             , "å›½åº†ç¯€"
             , "åœ‹æ…¶èŠ‚"
             , "åœ‹æ…¶ç¯€"
             ]
  , examples (datetimeInterval ((2013, 10, 1, 18, 0, 0), (2013, 10, 2, 0, 0, 0)) Hour)
             [ "å›½åº†èŠ‚æ™šä¸Š"
             , "åœ‹æ…¶ç¯€æ™šä¸Š"
             ]
  ]


-- 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 GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}

module Duckling.Time.ZH.HK.Rules
  ( rules
  ) where

import Prelude

import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Types

ruleNationalDay :: Rule
ruleNationalDay = Rule
  { name = "national day"
  , pattern =
    [ regex "(å›½åº†|åœ‹æ…¶)(èŠ‚|ç¯€)?"
    ]
  , prod = \_ -> tt $ monthDay 10 1
  }

rules :: [Rule]
rules =
  [ ruleNationalDay
  ]


-- 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.Time.ZH.MO.Corpus
  ( allExamples
  ) where

import Data.String
import Prelude

import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.Time.Types hiding (Month)
import Duckling.TimeGrain.Types hiding (add)

allExamples :: [Example]
allExamples = concat
  [ examples (datetime (2013, 10, 1, 0, 0, 0) Day)
             [ "å›½åº†"
             , "åœ‹æ…¶"
             , "å›½åº†èŠ‚"
             , "å›½åº†ç¯€"
             , "åœ‹æ…¶èŠ‚"
             , "åœ‹æ…¶ç¯€"
             ]
  , examples (datetimeInterval ((2013, 10, 1, 18, 0, 0), (2013, 10, 2, 0, 0, 0)) Hour)
             [ "å›½åº†èŠ‚æ™šä¸Š"
             , "åœ‹æ…¶ç¯€æ™šä¸Š"
             ]
  ]


-- 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 GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}

module Duckling.Time.ZH.MO.Rules
  ( rules
  ) where

import Prelude

import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Types

ruleNationalDay :: Rule
ruleNationalDay = Rule
  { name = "national day"
  , pattern =
    [ regex "(å›½åº†|åœ‹æ…¶)(èŠ‚|ç¯€)?"
    ]
  , prod = \_ -> tt $ monthDay 10 1
  }

rules :: [Rule]
rules =
  [ ruleNationalDay
  ]


-- 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.Time.ZH.TW.Corpus
  ( allExamples
  ) where

import Data.String
import Prelude

import Duckling.Testing.Types hiding (examples)
import Duckling.Time.Corpus
import Duckling.Time.Types hiding (Month)
import Duckling.TimeGrain.Types hiding (add)

allExamples :: [Example]
allExamples = concat
  [ examples (datetime (2013, 10, 10, 0, 0, 0) Day)
             [ "å›½åº†"
             , "åœ‹æ…¶"
             , "å›½åº†èŠ‚"
             , "å›½åº†ç¯€"
             , "åœ‹æ…¶èŠ‚"
             , "åœ‹æ…¶ç¯€"
             ]
  , examples (datetimeInterval ((2013, 10, 10, 18, 0, 0), (2013, 10, 11, 0, 0, 0)) Hour)
             [ "å›½åº†èŠ‚æ™šä¸Š"
             , "åœ‹æ…¶ç¯€æ™šä¸Š"
             ]
  ]


-- 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 GADTs #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# LANGUAGE OverloadedStrings #-}

module Duckling.Time.ZH.TW.Rules
  ( rules
  ) where

import Prelude

import Duckling.Regex.Types
import Duckling.Time.Helpers
import Duckling.Types

ruleNationalDay :: Rule
ruleNationalDay = Rule
  { name = "national day"
  , pattern =
    [ regex "(å›½åº†|åœ‹æ…¶)(èŠ‚|ç¯€)?"
    ]
  , prod = \_ -> tt $ monthDay 10 10
  }

rules :: [Rule]
rules =
  [ ruleNationalDay
  ]