Safe Haskell | None |
---|---|
Language | Haskell98 |
Internal implementation of the CRF model.
Synopsis
- newtype FeatIx = FeatIx {}
- data Model = Model {}
- mkModel :: Ob -> Lb -> [Feature] -> Model
- valueL :: Model -> FeatIx -> LogFloat
- featToIx :: Model -> Feature -> Maybe FeatIx
- featToJustIx :: Model -> Feature -> FeatIx
- featToJustInt :: Model -> Feature -> Int
- sgValue :: Model -> Lb -> LogFloat
- sgIxs :: Model -> [LbIx]
- obIxs :: Model -> Ob -> AVec LbIx
- nextIxs :: Model -> Lb -> AVec LbIx
- prevIxs :: Model -> Lb -> AVec LbIx
Documentation
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.
Instances
The model is actually a map from features to their respective potentials, but for the sake of efficiency the internal representation is more complex.
Model | |
|
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.
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.