Public Member Functions
CRFSuite::Tagger Class Reference

The tagger class. More...

List of all members.

Public Member Functions

 Tagger ()
 Construct a tagger.
virtual ~Tagger ()
 Destruct a tagger.
bool open (const std::string &name)
 Open a model file.
void close ()
 Close the model.
StringList labels ()
 Obtain the list of labels.
StringList tag (const ItemSequence &xseq)
 Predict the label sequence for the item sequence.
void set (const ItemSequence &xseq)
 Set an item sequence.
StringList viterbi ()
 Find the Viterbi label sequence for the item sequence.
double probability (const StringList &yseq)
 Compute the probability of the label sequence.
double marginal (const std::string &y, const int t)
 Compute the marginal probability of the label.

Detailed Description

The tagger class.

This class provides the functionality for predicting label sequences for input sequences using a model.


Member Function Documentation

StringList CRFSuite::Tagger::labels ( )

Obtain the list of labels.

Returns:
StringList The list of labels in the model.
Exceptions:
std::invalid_argumentA model is not opened.
std::runtime_errorAn internal error.
double CRFSuite::Tagger::marginal ( const std::string &  y,
const int  t 
)

Compute the marginal probability of the label.

Parameters:
yThe label.
tThe position of the label.
Exceptions:
std::invalid_argumentA model is not opened.
std::runtime_errorAn internal error.
bool CRFSuite::Tagger::open ( const std::string &  name)

Open a model file.

Parameters:
nameThe file name of the model file.
Returns:
bool true if the model file is successfully opened, false otherwise (e.g., when the mode file is not found).
Exceptions:
std::runtime_errorAn internal error in the model.
double CRFSuite::Tagger::probability ( const StringList yseq)

Compute the probability of the label sequence.

Parameters:
yseqThe label sequence.
Exceptions:
std::invalid_argumentA model is not opened.
std::runtime_errorAn internal error.
void CRFSuite::Tagger::set ( const ItemSequence xseq)

Set an item sequence.

This function sets an item sequence for future calls for viterbi(), probability(), and marginal() functions.

Parameters:
xseqThe item sequence to be tagged
Exceptions:
std::invalid_argumentA model is not opened.
std::runtime_errorAn internal error.
StringList CRFSuite::Tagger::tag ( const ItemSequence xseq)

Predict the label sequence for the item sequence.

This function calls set() and viterbi() functions to obtain the label sequence predicted for the item sequence.

Parameters:
xseqThe item sequence to be tagged.
Returns:
StringList The label sequence predicted.
Exceptions:
std::invalid_argumentA model is not opened.
std::runtime_errorAn internal error.
StringList CRFSuite::Tagger::viterbi ( )

Find the Viterbi label sequence for the item sequence.

Returns:
StringList The label sequence predicted.
Exceptions:
std::invalid_argumentA model is not opened.
std::runtime_errorAn internal error.

Copyright (c) 2002-2011 by Naoaki Okazaki
Thu Aug 11 2011 12:37:07