PLearn 0.1
|
PLearn command that fills a FeatureSet with the features instantiated in a VMat. More...
#include <FillFeatureSetCommand.h>
Public Member Functions | |
FillFeatureSetCommand () | |
virtual void | run (const std::vector< std::string > &args) |
The actual implementation of the 'FillFeatureSetCommand' command. | |
Static Protected Attributes | |
static PLearnCommandRegistry | reg_ |
This allows to register the 'FillFeatureSetCommand' command in the command registry. | |
Private Types | |
typedef PLearnCommand | inherited |
PLearn command that fills a FeatureSet with the features instantiated in a VMat.
A .plearn file for the FeatureSet and a .vmat file for the VMatrix need to be provided. Only the features of the input fields of the VMatrix are are inserted. A path for the saved FeatureSet needs also to be provided
Definition at line 54 of file FillFeatureSetCommand.h.
typedef PLearnCommand PLearn::FillFeatureSetCommand::inherited [private] |
Definition at line 56 of file FillFeatureSetCommand.h.
PLearn::FillFeatureSetCommand::FillFeatureSetCommand | ( | ) |
Definition at line 53 of file FillFeatureSetCommand.cc.
: PLearnCommand( "fill-feat-set", "PLearn command that fills a FeatureSet with the features instantiated in a VMat", "Usage: fill-feat-set <dataset> <feat_set> <filled_feat_set> [min_freq] [col]\n" " Will fill the FeatureSet instantiated from <feat_set> \n" " from the input tokens found in the <dataset> VMat.\n" " The filled FeatureSet will be saved in file <filled_feat_set>.\n" " A minimum frequency can be specified for the features to be\n" " included in the FeatureSet. The FeatureSet can be filled by\n" " the features of the tokens found in a particular column of\n" " <dataset>. If not specified, then the tokens found in all the\n" " input columns are used.\n" ) {}
void PLearn::FillFeatureSetCommand::run | ( | const std::vector< std::string > & | args | ) | [virtual] |
The actual implementation of the 'FillFeatureSetCommand' command.
Implements PLearn::PLearnCommand.
Definition at line 70 of file FillFeatureSetCommand.cc.
References PLearn::endl(), PLearn::getDataSet(), PLearn::PLearnCommand::helpmsg, PLearn::VMat::length(), PLearn::load(), PLearn::save(), and PLearn::toint().
{ if(args.size() != 3 && args.size() != 4 && args.size() != 5) { cerr << helpmsg << endl; return; } string vmat_file = args[0]; string feat_file = args[1]; string filled_feat_file = args[2]; int min_freq = -1; int col = -1; if(args.size() >= 4) min_freq = toint(args[3]); if(args.size() >=5) col = toint(args[4]); VMat vmat = getDataSet(vmat_file); VMat get_input_vmat; if(col < 0) get_input_vmat = new SubVMatrix(vmat,0,0,vmat->length(), vmat->inputsize()); else get_input_vmat = new SubVMatrix(vmat,0,col,vmat->length(), 1); PP<FeatureSet> feat; load(feat_file,feat); feat->addFeatures(get_input_vmat,min_freq); save(filled_feat_file,feat); }
PLearnCommandRegistry PLearn::FillFeatureSetCommand::reg_ [static, protected] |
This allows to register the 'FillFeatureSetCommand' command in the command registry.
Definition at line 63 of file FillFeatureSetCommand.h.