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

Data.CRF.Chain1.Constrained.DAG

Contents

Description

The module provides first-order, linear-chain conditional random fields (CRFs) with position-wide constraints over label values.

Synopsis

# Data types

data Word a b Source #

A Word is represented by a set of observations and a set of potential interpretation labels. When the set of potential labels is empty the word is considered to be unknown and the default potential set is used in its place.

Constructors

 Word Fieldsobs :: Set aThe set of observationslbs :: Set bThe set of potential interpretations.
Instances
 (Eq a, Eq b) => Eq (Word a b) Source # Instance details Methods(==) :: Word a b -> Word a b -> Bool #(/=) :: Word a b -> Word a b -> Bool # (Ord a, Ord b) => Ord (Word a b) Source # Instance details Methodscompare :: Word a b -> Word a b -> Ordering #(<) :: Word a b -> Word a b -> Bool #(<=) :: Word a b -> Word a b -> Bool #(>) :: Word a b -> Word a b -> Bool #(>=) :: Word a b -> Word a b -> Bool #max :: Word a b -> Word a b -> Word a b #min :: Word a b -> Word a b -> Word a b # (Show a, Show b) => Show (Word a b) Source # Instance details MethodsshowsPrec :: Int -> Word a b -> ShowS #show :: Word a b -> String #showList :: [Word a b] -> ShowS #

unknown :: Word a b -> Bool Source #

The word is considered to be unknown when the set of potential labels is empty.

type Sent a b = DAG () (Word a b) Source #

A sentence (DAG) of words.

data Prob a Source #

A probability distribution defined over elements of type a. All elements not included in the map have probability equal to 0.

Instances
 Eq a => Eq (Prob a) Source # Instance details Methods(==) :: Prob a -> Prob a -> Bool #(/=) :: Prob a -> Prob a -> Bool # Ord a => Ord (Prob a) Source # Instance details Methodscompare :: Prob a -> Prob a -> Ordering #(<) :: Prob a -> Prob a -> Bool #(<=) :: Prob a -> Prob a -> Bool #(>) :: Prob a -> Prob a -> Bool #(>=) :: Prob a -> Prob a -> Bool #max :: Prob a -> Prob a -> Prob a #min :: Prob a -> Prob a -> Prob a # Show a => Show (Prob a) Source # Instance details MethodsshowsPrec :: Int -> Prob a -> ShowS #show :: Prob a -> String #showList :: [Prob a] -> ShowS #

mkProb :: Ord a => [(a, Double)] -> Prob a Source #

Construct the probability distribution.

Normalization is not performed because, when working with DAGs, the probability of a specific DAG edge can be lower than 1 (in particular, it can be 0).

Elements with probability 0 cab be filtered out since information that a given label is a potential interpretation of the given word/edge is preserved at the level of the Word

data WordL a b Source #

A WordL is a labeled word, i.e. a word with probability distribution defined over labels. We assume that every label from the distribution domain is a member of the set of potential labels corresponding to the word. Use the mkWordL smart constructor to build WordL.

mkWordL :: Ord b => Word a b -> Prob b -> WordL a b Source #

Ensure, that every label from the distribution domain is a member of the set of potential labels corresponding to the word.

type SentL a b = DAG () (WordL a b) Source #

A sentence (DAG) of labeled words.

## Tagging

data Config a Source #

Tagging configuration.

Constructors

 Config FieldsblackSet :: Set aBlacklisted tags

tag :: (Ord a, Ord b) => Config b -> CRF a b -> Sent a b -> DAG () b Source #

Determine the most probable label sequence within the context of the given sentence using the model provided by the CRF.

marginals :: (Ord a, Ord b) => Config b -> CRF a b -> Sent a b -> SentL a b Source #

Tag with marginal probabilities. For known words (i.e., with lbs non-empty), their known potential interpretations are assigned some probabilities (other interpretations are not considered. For unknown words (i.e., with empty lbs), all interpretations are considered (up to the way the set of all interpretations is constructed). In particular, if no interpretation with probability > 0 is found for an unknown word, its set of chosen labels will remain empty.