duckling/Duckling/Ranking/Types.hs
Julien Odent bf89e34365 Relicense to BSD3
Reviewed By: JoelMarcey

Differential Revision: D15439223

fbshipit-source-id: c5af3cb06318748142fe503945b38beffadfc28a
2019-05-22 10:46:39 -07:00

58 lines
1.1 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.
{-# 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