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

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.

Constructors

 FeatIx FieldsunFeatIx :: Int

Instances

 Eq FeatIx Ord FeatIx Show FeatIx Binary FeatIx Unbox FeatIx Vector Vector FeatIx MVector MVector FeatIx

data Model Source

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

Constructors

 Model Fieldsvalues :: Vector DoubleValue (potential) of the model for feature index. ixMap :: Map Feature FeatIxA map from features to feature indices r0 :: AVec LbDefault set of potential labels. sgIxsV :: Vector FeatIxSingular 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

mkModel :: Ob -> Lb -> [Feature] -> ModelSource

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.

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

Determine index for the given feature.

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

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

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 LbIxSource

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 LbIxSource

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 LbIxSource

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