2017-03-08 21:33:55 +03:00
|
|
|
-- 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 OverloadedStrings #-}
|
|
|
|
|
|
|
|
module Duckling.Ordinal.PT.Rules
|
|
|
|
( rules ) where
|
|
|
|
|
|
|
|
import qualified Data.Text as Text
|
|
|
|
import Prelude
|
|
|
|
import Data.String
|
|
|
|
|
|
|
|
import Duckling.Dimensions.Types
|
|
|
|
import Duckling.Ordinal.Helpers
|
|
|
|
import Duckling.Regex.Types
|
|
|
|
import Duckling.Types
|
|
|
|
|
|
|
|
ruleOrdinalsPrimeiro :: Rule
|
|
|
|
ruleOrdinalsPrimeiro = Rule
|
|
|
|
{ name = "ordinals (primeiro..10)"
|
|
|
|
, pattern =
|
2017-09-07 22:33:31 +03:00
|
|
|
[ regex "((primeir|segund|quart|quint|sext|s(e|é)tim|oitav|non|d(e|é)cim)(os?|as?))"
|
2017-03-08 21:33:55 +03:00
|
|
|
]
|
|
|
|
, prod = \tokens -> case tokens of
|
|
|
|
(Token RegexMatch (GroupMatch (match:_)):_) -> case Text.toLower match of
|
|
|
|
"primeira" -> Just $ ordinal 1
|
|
|
|
"primeiros" -> Just $ ordinal 1
|
|
|
|
"primeiras" -> Just $ ordinal 1
|
|
|
|
"primeiro" -> Just $ ordinal 1
|
|
|
|
"segundo" -> Just $ ordinal 2
|
|
|
|
"segunda" -> Just $ ordinal 2
|
|
|
|
"segundas" -> Just $ ordinal 2
|
|
|
|
"segundos" -> Just $ ordinal 2
|
|
|
|
"terceiros" -> Just $ ordinal 3
|
|
|
|
"terceiro" -> Just $ ordinal 3
|
|
|
|
"terceiras" -> Just $ ordinal 3
|
|
|
|
"terceira" -> Just $ ordinal 3
|
|
|
|
"quartos" -> Just $ ordinal 4
|
|
|
|
"quarto" -> Just $ ordinal 4
|
|
|
|
"quarta" -> Just $ ordinal 4
|
|
|
|
"quartas" -> Just $ ordinal 4
|
|
|
|
"quinto" -> Just $ ordinal 5
|
|
|
|
"quinta" -> Just $ ordinal 5
|
|
|
|
"quintas" -> Just $ ordinal 5
|
|
|
|
"quintos" -> Just $ ordinal 5
|
|
|
|
"sextos" -> Just $ ordinal 6
|
|
|
|
"sexto" -> Just $ ordinal 6
|
|
|
|
"sexta" -> Just $ ordinal 6
|
|
|
|
"sextas" -> Just $ ordinal 6
|
|
|
|
"setimas" -> Just $ ordinal 7
|
2017-09-07 22:33:31 +03:00
|
|
|
"sétima" -> Just $ ordinal 7
|
2017-03-08 21:33:55 +03:00
|
|
|
"setimo" -> Just $ ordinal 7
|
|
|
|
"setimos" -> Just $ ordinal 7
|
|
|
|
"setima" -> Just $ ordinal 7
|
2017-09-07 22:33:31 +03:00
|
|
|
"sétimos" -> Just $ ordinal 7
|
|
|
|
"sétimo" -> Just $ ordinal 7
|
|
|
|
"sétimas" -> Just $ ordinal 7
|
2017-03-08 21:33:55 +03:00
|
|
|
"oitavas" -> Just $ ordinal 8
|
|
|
|
"oitava" -> Just $ ordinal 8
|
|
|
|
"oitavo" -> Just $ ordinal 8
|
|
|
|
"oitavos" -> Just $ ordinal 8
|
|
|
|
"nonos" -> Just $ ordinal 9
|
|
|
|
"nona" -> Just $ ordinal 9
|
|
|
|
"nono" -> Just $ ordinal 9
|
|
|
|
"nonas" -> Just $ ordinal 9
|
2017-09-07 22:33:31 +03:00
|
|
|
"décimos" -> Just $ ordinal 10
|
2017-03-08 21:33:55 +03:00
|
|
|
"decimo" -> Just $ ordinal 10
|
|
|
|
"decimos" -> Just $ ordinal 10
|
2017-09-07 22:33:31 +03:00
|
|
|
"décimo" -> Just $ ordinal 10
|
2017-03-08 21:33:55 +03:00
|
|
|
"decimas" -> Just $ ordinal 10
|
2017-09-07 22:33:31 +03:00
|
|
|
"décima" -> Just $ ordinal 10
|
2017-03-08 21:33:55 +03:00
|
|
|
"decima" -> Just $ ordinal 10
|
2017-09-07 22:33:31 +03:00
|
|
|
"décimas" -> Just $ ordinal 10
|
2017-03-08 21:33:55 +03:00
|
|
|
_ -> Nothing
|
|
|
|
_ -> Nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
rules :: [Rule]
|
|
|
|
rules =
|
|
|
|
[ ruleOrdinalsPrimeiro
|
|
|
|
]
|