duckling/Duckling/Ranking/Types.hs
Julien Odent bef7a44fa8 Remove redundant brackets and language pragmas
Summary: .

Reviewed By: JonCoens

Differential Revision: D6838082

fbshipit-source-id: 94757bdb80c6d3c29a7a6554429940a1b7403108
2018-01-29 16:45:28 -08:00

59 lines
1.2 KiB
Haskell

-- 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 NoRebindableSyntax #-}
module Duckling.Ranking.Types
( Feature
, BagOfFeatures
, Class
, Datum
, Dataset
, Classifier(..)
, Classifiers
, ClassData(..)
, infinity
) where
import Data.HashMap.Strict (HashMap)
import Data.Text (Text)
import Prelude
-- -----------------------------------------------------------------
-- Aliases
type Feature = Text
type BagOfFeatures = HashMap Feature Int
type Class = Bool
type Datum = (BagOfFeatures, Class)
type Dataset = HashMap Text [Datum]
-- -----------------------------------------------------------------
-- Classification
data Classifier = Classifier
{ okData :: ClassData
, koData :: ClassData
}
deriving (Eq, Show)
type Classifiers = HashMap Text Classifier
data ClassData = ClassData
{ prior :: Double
, unseen :: Double
, likelihoods :: HashMap Feature Double
, n :: Int
}
deriving (Eq, Show)
infinity :: Double
infinity = 1 / 0