From 1ab5f447d2635fe6d48887a501d333a52adff5b9 Mon Sep 17 00:00:00 2001 From: Julien Odent Date: Mon, 16 Oct 2017 09:43:53 -0700 Subject: [PATCH] en_CA + fix Canadian Thanksgiving 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 --- Duckling/Locale.hs | 5 +- Duckling/Ranking/Classifiers/EN_CA.hs | 2349 +++++++++++++++++++++++++ Duckling/Rules/EN.hs | 3 + Duckling/Time/EN/CA/Corpus.hs | 60 + Duckling/Time/EN/CA/Rules.hs | 69 + Duckling/Time/EN/Corpus.hs | 42 +- Duckling/Time/EN/GB/Corpus.hs | 21 + Duckling/Time/EN/GB/Rules.hs | 10 + Duckling/Time/EN/Rules.hs | 4 - Duckling/Time/EN/US/Corpus.hs | 21 + Duckling/Time/EN/US/Rules.hs | 11 + duckling.cabal | 3 + exe/Duckling/Ranking/Generate.hs | 2 + tests/Duckling/Time/EN/GB/Tests.hs | 24 - tests/Duckling/Time/EN/Tests.hs | 8 +- tests/Duckling/Time/EN/US/Tests.hs | 24 - 16 files changed, 2580 insertions(+), 76 deletions(-) create mode 100644 Duckling/Ranking/Classifiers/EN_CA.hs create mode 100644 Duckling/Time/EN/CA/Corpus.hs create mode 100644 Duckling/Time/EN/CA/Rules.hs delete mode 100644 tests/Duckling/Time/EN/GB/Tests.hs delete mode 100644 tests/Duckling/Time/EN/US/Tests.hs diff --git a/Duckling/Locale.hs b/Duckling/Locale.hs index 65155f8d7..826da7852 100644 --- a/Duckling/Locale.hs +++ b/Duckling/Locale.hs @@ -69,7 +69,8 @@ instance TextShow Lang where -- | ISO 3166-1 alpha-2 Country code (includes regions and territories). -- See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 data Region - = CN + = CA + | CN | GB | HK | MO @@ -100,6 +101,6 @@ makeLocale lang (Just region) allLocales :: HashMap Lang (HashSet Region) allLocales = HashMap.fromList - [ (EN, HashSet.fromList [GB, US]) + [ (EN, HashSet.fromList [CA, GB, US]) , (ZH, HashSet.fromList [CN, HK, MO, TW]) ] diff --git a/Duckling/Ranking/Classifiers/EN_CA.hs b/Duckling/Ranking/Classifiers/EN_CA.hs new file mode 100644 index 000000000..5574da61a --- /dev/null +++ b/Duckling/Ranking/Classifiers/EN_CA.hs @@ -0,0 +1,2349 @@ +-- 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. + +----------------------------------------------------------------- +-- Auto-generated by regenClassifiers +-- +-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +-- @generated +----------------------------------------------------------------- +{-# LANGUAGE OverloadedStrings #-} +module Duckling.Ranking.Classifiers.EN_CA (classifiers) where +import Data.String +import Prelude +import qualified Data.HashMap.Strict as HashMap +import Duckling.Ranking.Types + +classifiers :: Classifiers +classifiers + = HashMap.fromList + [(" to|till|before ", + Classifier{okData = + ClassData{prior = -2.0794415416798357, unseen = -1.791759469228055, + likelihoods = + HashMap.fromList + [("integer (numeric)noon|midnight|EOD|end of day", + -0.916290731874155), + ("hour", -0.916290731874155)], + n = 1}, + koData = + ClassData{prior = -0.13353139262452263, + unseen = -2.890371757896165, + likelihoods = + HashMap.fromList + [("hour", -0.7537718023763802), + ("integer (numeric)time-of-day (latent)", -0.7537718023763802)], + n = 7}}), + ("