The tagger class. More...
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. |
The tagger class.
This class provides the functionality for predicting label sequences for input sequences using a model.
StringList CRFSuite::Tagger::labels | ( | ) |
Obtain the list of labels.
std::invalid_argument | A model is not opened. |
std::runtime_error | An internal error. |
double CRFSuite::Tagger::marginal | ( | const std::string & | y, |
const int | t | ||
) |
Compute the marginal probability of the label.
y | The label. |
t | The position of the label. |
std::invalid_argument | A model is not opened. |
std::runtime_error | An internal error. |
bool CRFSuite::Tagger::open | ( | const std::string & | name | ) |
Open a model file.
name | The file name of the model file. |
true
if the model file is successfully opened, false
otherwise (e.g., when the mode file is not found). std::runtime_error | An internal error in the model. |
double CRFSuite::Tagger::probability | ( | const StringList & | yseq | ) |
Compute the probability of the label sequence.
yseq | The label sequence. |
std::invalid_argument | A model is not opened. |
std::runtime_error | An 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.
xseq | The item sequence to be tagged |
std::invalid_argument | A model is not opened. |
std::runtime_error | An 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.
xseq | The item sequence to be tagged. |
std::invalid_argument | A model is not opened. |
std::runtime_error | An internal error. |
StringList CRFSuite::Tagger::viterbi | ( | ) |
Find the Viterbi label sequence for the item sequence.
std::invalid_argument | A model is not opened. |
std::runtime_error | An internal error. |