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

Safe HaskellNone

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 

Fields

unFeatIx :: Int
 

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 

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.

valueL :: Model -> FeatIx -> LogFloatSource

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

featToIx :: Model -> Feature -> Maybe FeatIxSource

Determine index for the given feature.

featToJustIx :: Model -> Feature -> FeatIxSource

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

featToJustInt :: Model -> Feature -> IntSource

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 -> LogFloatSource

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.