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

Safe HaskellNone

Data.CRF.Chain1.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 realy a map from features to 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

lbNum :: Int

Number of labels. The label set is of the {0, 1, .., lbNum - 1} form, which is guaranteed by the codec.

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 (Vector LbIx)

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

prevIxsV :: Vector (Vector 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 (Vector LbIx)

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

Instances

mkModel :: [Feature] -> ModelSource

Construct the model from the list of features. All parameters will be set to 0. There may be repetitions in the input list.

lbSet :: Model -> [Lb]Source

List of labels [0 .. lbNum - 1].

valueL :: Model -> FeatIx -> LogFloatSource

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

featToIx :: Model -> Feature -> FeatIxSource

Determine the index for the given feature.

featToInt :: Model -> Feature -> IntSource

Same as featToIx but immediately unwrap the feature index to integer value.

sgValue :: Model -> Lb -> LogFloatSource

Potential value (in log domain) of the singular feature with the given label. The value defaults to 0 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 -> [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 -> [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 -> [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.