-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: * `en_CA` locale * In Canada, Thanksgiving Day is the second Monday of October. * Black Friday is the same as the US. * However Canada observes both DDMM and MMDD formats. Defer to later, falling back to US. Reviewed By: blandinw Differential Revision: D6058909 fbshipit-source-id: 3d4e05e
- Loading branch information
1 parent
fb1dcaa
commit 1ab5f44
Showing
16 changed files
with
2,580 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
-- 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. An additional grant | ||
-- of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Duckling.Time.EN.CA.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, 2, 15, 0, 0, 0) Day) | ||
[ "2/15" | ||
, "on 2/15" | ||
, "2 / 15" | ||
, "2-15" | ||
, "2 - 15" | ||
] | ||
, examples (datetime (1974, 10, 31, 0, 0, 0) Day) | ||
[ "10/31/1974" | ||
, "10/31/74" | ||
, "10-31-74" | ||
] | ||
, examples (datetime (2013, 4, 25, 16, 0, 0) Minute) | ||
[ "4/25 at 4:00pm" | ||
] | ||
, examples (datetime (2013, 10, 14, 0, 0, 0) Day) | ||
[ "thanksgiving day" | ||
, "thanksgiving" | ||
, "thanksgiving 2013" | ||
, "this thanksgiving" | ||
, "next thanksgiving day" | ||
] | ||
, examples (datetime (2014, 10, 13, 0, 0, 0) Day) | ||
[ "thanksgiving of next year" | ||
, "thanksgiving 2014" | ||
] | ||
, examples (datetime (2012, 10, 8, 0, 0, 0) Day) | ||
[ "last thanksgiving" | ||
, "thanksgiving day 2012" | ||
] | ||
, examples (datetime (2016, 10, 10, 0, 0, 0) Day) | ||
[ "thanksgiving 2016" | ||
] | ||
, examples (datetime (2017, 10, 9, 0, 0, 0) Day) | ||
[ "thanksgiving 2017" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
-- 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. An additional grant | ||
-- of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
|
||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE NoRebindableSyntax #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Duckling.Time.EN.CA.Rules | ||
( rules | ||
) where | ||
|
||
import Data.Maybe | ||
import Prelude | ||
|
||
import Duckling.Dimensions.Types | ||
import Duckling.Numeral.Helpers (parseInt) | ||
import Duckling.Regex.Types | ||
import Duckling.Time.Helpers | ||
import Duckling.Time.Types (TimeData (..)) | ||
import Duckling.Types | ||
|
||
-- Although one can see both MMDD and DDMM in Canada, | ||
-- there is no direct way to implement this today. Let's fallback to MMDD (US). | ||
ruleMMDD :: Rule | ||
ruleMMDD = Rule | ||
{ name = "mm/dd" | ||
, pattern = [regex "(0?[1-9]|1[0-2])\\s?[/-]\\s?(3[01]|[12]\\d|0?[1-9])"] | ||
, prod = \tokens -> case tokens of | ||
(Token RegexMatch (GroupMatch (mm:dd:_)):_) -> do | ||
m <- parseInt mm | ||
d <- parseInt dd | ||
tt $ monthDay m d | ||
_ -> Nothing | ||
} | ||
|
||
ruleMMDDYYYY :: Rule | ||
ruleMMDDYYYY = Rule | ||
{ name = "mm/dd/yyyy" | ||
, pattern = | ||
[regex "(0?[1-9]|1[0-2])[/-](3[01]|[12]\\d|0?[1-9])[-/](\\d{2,4})"] | ||
, prod = \tokens -> case tokens of | ||
(Token RegexMatch (GroupMatch (mm:dd:yy:_)):_) -> do | ||
y <- parseInt yy | ||
m <- parseInt mm | ||
d <- parseInt dd | ||
tt $ yearMonthDay y m d | ||
_ -> Nothing | ||
} | ||
|
||
ruleThanksgiving :: Rule | ||
ruleThanksgiving = Rule | ||
{ name = "Thanksgiving Day" | ||
, pattern = | ||
[ regex "thanks?giving( day)?" | ||
] | ||
, prod = \_ -> tt $ nthDOWOfMonth 2 1 10 -- Second Monday of October | ||
} | ||
|
||
rules :: [Rule] | ||
rules = | ||
[ ruleMMDD | ||
, ruleMMDDYYYY | ||
, ruleThanksgiving | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.