crf-chain1-constrained-0.4.0: First-order, constrained, linear-chain conditional random fields

Safe HaskellNone
LanguageHaskell98

Data.CRF.Chain1.Constrained.Model

Description

Internal implementation of the CRF model.

Synopsis

Documentation

newtype FeatIx Source #

A feature index. To every model feature a unique index is assigned. It is equall to -1 if there is no corresponding feature in the model.

Constructors

FeatIx 

Fields

Instances
Eq FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

Methods

(==) :: FeatIx -> FeatIx -> Bool #

(/=) :: FeatIx -> FeatIx -> Bool #

Ord FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

Show FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

Binary FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

Methods

put :: FeatIx -> Put #

get :: Get FeatIx #

putList :: [FeatIx] -> Put #

Unbox FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

Vector Vector FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

MVector MVector FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

data Vector FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

data MVector s FeatIx Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

data Model Source #

The model is actually a map from features to their respective potentials, but for the sake of efficiency the internal representation is more complex.

Constructors

Model 

Fields

  • values :: Vector Double

    Value (potential) of the model for feature index.

  • ixMap :: Map Feature FeatIx

    A map from features to feature indices

  • r0 :: AVec Lb

    A default set of labels. It is used on sentence positions for which no constraints are assigned.

  • sgIxsV :: Vector FeatIx

    Singular feature index for the given label. Index is equall to -1 if feature is not present in the model.

  • obIxsV :: Vector (AVec LbIx)

    Set of labels for the given observation which, together with the observation, constitute an observation feature of the model.

  • prevIxsV :: Vector (AVec LbIx)

    Set of ,,previous'' labels for the value of the ,,current'' label. Both labels constitute a transition feature present in the the model.

  • nextIxsV :: Vector (AVec LbIx)

    Set of ,,next'' labels for the value of the ,,current'' label. Both labels constitute a transition feature present in the the model.

Instances
Binary Model Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.Model

Methods

put :: Model -> Put #

get :: Get Model #

putList :: [Model] -> Put #

mkModel :: Ob -> Lb -> [Feature] -> Model Source #

Construct the model from the list of features. All parameters will be set to 0. There can be repetitions in the input list. We assume that the set of labels is of the {0, 1, .. lbMax} form and, similarly, the set of observations is of the {0, 1, .. obMax} form.

valueL :: Model -> FeatIx -> LogFloat Source #

Model potential defined for the given feature interpreted as a number in logarithmic domain.

featToIx :: Model -> Feature -> Maybe FeatIx Source #

Determine index for the given feature.

featToJustIx :: Model -> Feature -> FeatIx Source #

Determine index for the given feature. Throw error when the feature is not a member of the model.

featToJustInt :: Model -> Feature -> Int Source #

Determine index for the given feature and return it as an integer. Throw error when the feature is not a member of the model.

sgValue :: Model -> Lb -> LogFloat Source #

Potential value (in log domain) of the singular feature with the given label. The value defaults to 1 (0 in log domain) when the feature is not a member of the model.

sgIxs :: Model -> [LbIx] Source #

List of labels which can be located on the first position of a sentence together with feature indices determined by them.

obIxs :: Model -> Ob -> AVec LbIx Source #

List of labels which constitute a valid feature in combination with the given observation accompanied by feature indices determined by these labels.

nextIxs :: Model -> Lb -> AVec LbIx Source #

List of ,,next'' labels which constitute a valid feature in combination with the ,,current'' label accompanied by feature indices determined by ,,next'' labels.

prevIxs :: Model -> Lb -> AVec LbIx Source #

List of ,,previous'' labels which constitute a valid feature in combination with the ,,current'' label accompanied by feature indices determined by ,,previous'' labels.