ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Private Member Functions | Private Attributes | List of all members
meta::sequence::crf::scorer Class Reference

Internal class that holds scoring information for sequences under the current model. More...

#include <scorer.h>

Public Member Functions

void score (const crf &model, const sequence &seq)
 Finds both transition and state scores, in logarithm and exponential domains. More...
 
void transition_scores (const crf &model)
 Finds only the transition scores. More...
 
void state_scores (const crf &model, const sequence &seq)
 Finds only the state scores. More...
 
void forward ()
 Computes the forward trellis.
 
void backward ()
 Computes the backward trellis.
 
void marginals ()
 Computes the marginal probabilities of states and transitions by using the forward-backward algorithm results.
 
double state (uint64_t time, label_id lbl) const
 
double state_exp (uint64_t time, label_id lbl) const
 
double trans (label_id from, label_id to) const
 
double trans_exp (label_id from, label_id to) const
 
double forward (uint64_t time, label_id lbl) const
 
double backward (uint64_t time, label_id lbl) const
 
double state_marginal (uint64_t time, label_id lbl) const
 
double trans_marginal (label_id from, label_id to) const
 
double loss (const sequence &seq) const
 Computes the loss function for a given sequence. More...
 

Private Member Functions

void transition_marginals ()
 Computes the transition marginals.
 
void state_marginals ()
 Computes the state marginals.
 

Private Attributes

double_matrix state_
 Stores the state scores in log-domain.
 
double_matrix state_exp_
 Stores the state scores.
 
double_matrix trans_
 Stores the transition scores in log-domain.
 
double_matrix trans_exp_
 Stores the transition scores.
 
util::optional< forward_trellisfwd_
 Stores the forward trellis, if computed.
 
util::optional< trellisbwd_
 Stores the backward trellis, if computed.
 
util::optional< double_matrixstate_mrg_
 Stores the state marginals, if computed.
 
util::optional< double_matrixtrans_mrg_
 Stores the transition marginals, if computed.
 

Detailed Description

Internal class that holds scoring information for sequences under the current model.

Member Function Documentation

void meta::sequence::crf::scorer::score ( const crf model,
const sequence seq 
)

Finds both transition and state scores, in logarithm and exponential domains.

Parameters
modelThe model to score with
seqThe sequence to score
void meta::sequence::crf::scorer::transition_scores ( const crf model)

Finds only the transition scores.

Parameters
modelThe model to score with
void meta::sequence::crf::scorer::state_scores ( const crf model,
const sequence seq 
)

Finds only the state scores.

Parameters
modelThe model to score with
seqThe sequence to score
double meta::sequence::crf::scorer::state ( uint64_t  time,
label_id  lbl 
) const
Parameters
timeThe time step
lblThe state
Returns
the log-domain score for being in this state at the given time
double meta::sequence::crf::scorer::state_exp ( uint64_t  time,
label_id  lbl 
) const
Parameters
timeThe time step
lblThe state
Returns
the score for being in this state at the given time
double meta::sequence::crf::scorer::trans ( label_id  from,
label_id  to 
) const
Parameters
fromThe origin state
toThe destination state
Returns
the log-domain score for the given transition
double meta::sequence::crf::scorer::trans_exp ( label_id  from,
label_id  to 
) const
Parameters
fromThe origin state
toThe destination state
Returns
the score for the given transition
double meta::sequence::crf::scorer::forward ( uint64_t  time,
label_id  lbl 
) const
Parameters
timeThe time step
lblThe state
Returns
the forward score for the given state at the given time
double meta::sequence::crf::scorer::backward ( uint64_t  time,
label_id  lbl 
) const
Parameters
timeThe time step
lblThe state
Returns
the backward score for the given state at the given time
double meta::sequence::crf::scorer::state_marginal ( uint64_t  time,
label_id  lbl 
) const
Parameters
timeThe time step
lblThe state
Returns
the marginal probability of being in the given state at the given time
double meta::sequence::crf::scorer::trans_marginal ( label_id  from,
label_id  to 
) const
Parameters
fromThe origin state
toThe destination state
Returns
the marginal probability of transitioning from the origin state to the destination state
double meta::sequence::crf::scorer::loss ( const sequence seq) const

Computes the loss function for a given sequence.

Parameters
seqThe reference sequence
Returns
the value of the loss function with respect to this sequence

The documentation for this class was generated from the following files: