NAME

Treex::Tool::Parser::MSTperl::ModelBase

VERSION

version 0.07298

DESCRIPTION

TODO: outdated; some of the information should be moved to ModelUnlabelled and some should be added

This is a base class for an in-memory represenation of a parsing or labelling model. The model is represented by features and their weights.

FIELDS

config
featuresControl

METHODS

Access to feature weights

my $edge_score = $model->score_edge($edge);

Counts the score of an edge by summing up weights of all of its features.

my $score = $model->score_features(['0:být|VB', '1:pes|N1', ...]);

Counts the score of an edge or sentence by summing up weights of all of its features, which are passed as an array reference.

my $feature_weight = $model->get_feature_weight('1:pes|N1');

Returns the weight of a given feature, or 0 if the feature is not contained in the model.

$model->set_feature_weight('1:pes|N1', 0.0021);

Sets a new weight for a given feature.

$model->update_feature_weight('1:pes|N1', 0.0042);

Adds the update value to current feature weight - eg. if the weight of the feature '1:pes|N1' is currently 0.0021, it will be 0.0063 after the call. The update can also be negative - then the weight of the feature decreases.

Loading and storing

$model->load('modelfile.model');

Loads model (= loads feature weights) from file in Data::Dumper format:

$VAR1 = {
    '0:být|VB' => '0.0042',
    '1:pes|N1' => '0.0021',
    ...
};

The feature codes are represented by their indexes in all_feature_codes.

$model->load_tsv('modelfile.tsv');

Loads model from file in TSV (tab separated values) format:

L|T:být|VB [tab] 0.0042
l|t:pes|N1 [tab] 0.0021
...

The feature codes are written as text.

$model->store('modelfile.model');

Stores model into file in Data::Dumper format.

$model->store_tsv('modelfile.tsv');

Stores model into file in TSV format:

AUTHORS

Rudolf Rosa <rosa@ufal.mff.cuni.cz>

Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz>

COPYRIGHT AND LICENSE

Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.