PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions
PLearn::ProcessingVMatrix Class Reference

#include <ProcessingVMatrix.h>

Inheritance diagram for PLearn::ProcessingVMatrix:
Inheritance graph
[legend]
Collaboration diagram for PLearn::ProcessingVMatrix:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ProcessingVMatrix ()
 ProcessingVMatrix (VMat the_source, const string &program_string)
 ProcessingVMatrix (VMat the_source, const string &inputprg, const string &targetprg, const string &weightprg="", const string &extraprg="")
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ProcessingVMatrixdeepCopy (CopiesMap &copies) const

Static Public Member Functions

static string _classname_ ()
 Declares name and deepCopy methods.
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

string prg
string input_prg
string target_prg
string weight_prg
string extra_prg

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

virtual void getNewRow (int i, const Vec &v) const
 This is the only method requiring implementation.

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares this class' options.

Protected Attributes

Vec sourcevec
VMatLanguage program
VMatLanguage input_prg_
VMatLanguage target_prg_
VMatLanguage weight_prg_
VMatLanguage extra_prg_

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 53 of file ProcessingVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 55 of file ProcessingVMatrix.h.


Constructor & Destructor Documentation

PLearn::ProcessingVMatrix::ProcessingVMatrix ( )

Definition at line 50 of file ProcessingVMatrix.cc.

    :inherited()
{
}
PLearn::ProcessingVMatrix::ProcessingVMatrix ( VMat  the_source,
const string &  program_string 
) [inline]

Definition at line 86 of file ProcessingVMatrix.h.

        :SourceVMatrix(the_source),prg(program_string)
    { build_(); }
PLearn::ProcessingVMatrix::ProcessingVMatrix ( VMat  the_source,
const string &  inputprg,
const string &  targetprg,
const string &  weightprg = "",
const string &  extraprg = "" 
) [inline]

Definition at line 90 of file ProcessingVMatrix.h.

        :SourceVMatrix(the_source),
         input_prg(inputprg),
         target_prg(targetprg),
         weight_prg(weightprg),
         extra_prg(extraprg)
    { build_(); }

Member Function Documentation

string PLearn::ProcessingVMatrix::_classname_ ( ) [static]

Declares name and deepCopy methods.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

OptionList & PLearn::ProcessingVMatrix::_getOptionList_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

RemoteMethodMap & PLearn::ProcessingVMatrix::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

bool PLearn::ProcessingVMatrix::_isa_ ( const Object o) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

Object * PLearn::ProcessingVMatrix::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

StaticInitializer ProcessingVMatrix::_static_initializer_ & PLearn::ProcessingVMatrix::_static_initialize_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

void PLearn::ProcessingVMatrix::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::SourceVMatrix.

Definition at line 218 of file ProcessingVMatrix.cc.

References PLearn::SourceVMatrix::build(), and build_().

Here is the call graph for this function:

void PLearn::ProcessingVMatrix::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 131 of file ProcessingVMatrix.cc.

References PLearn::TVec< T >::append(), PLearn::VMatLanguage::compileString(), PLearn::VMatrix::declareFieldNames(), extra_prg, extra_prg_, PLearn::VMatrix::extrasize_, input_prg, input_prg_, PLearn::VMatrix::inputsize_, PLearn::TVec< T >::length(), PLearn::VMat::length(), PLearn::VMatrix::length_, PLearn::max(), PLCHECK_MSG, prg, program, PLearn::TVec< T >::resize(), PLearn::SourceVMatrix::setMetaInfoFromSource(), PLearn::VMatLanguage::setSource(), PLearn::TVec< T >::size(), PLearn::SourceVMatrix::source, sourcevec, target_prg, target_prg_, PLearn::VMatrix::targetsize_, PLearn::VMatrix::updateMtime(), weight_prg, weight_prg_, PLearn::VMatrix::weightsize_, PLearn::VMat::width(), and PLearn::VMatrix::width_.

Referenced by build().

{
    // Do not do anything until we get the source VMat.
    if (!source)
        return;

    updateMtime(source);
    length_ = source->length();

    TVec<string> fieldnames;
    if(!prg.empty()) // ignore the *_prg
    {
        program.setSource(source);
        program.compileString(prg,fieldnames); 
        int nfields = fieldnames.size();
        width_ = nfields;

        declareFieldNames(fieldnames);
        setMetaInfoFromSource();

        if(inputsize_<0)
            inputsize_ = nfields;
        if(targetsize_<0)
            targetsize_ = width_ - inputsize_ - max(0, weightsize_)
                                              - max(0, extrasize_);
        if(weightsize_<0)
            weightsize_ = width_ - inputsize_ - targetsize_
                                              - max(0, extrasize_);
        if(extrasize_<0)
            extrasize_ = width_ - inputsize_ - targetsize_ - weightsize_;

        PLCHECK_MSG(
                width_ ==  inputsize_ + targetsize_ + weightsize_ + extrasize_,
                "Width does not match sizes!");
    }
    else // use the *_prg
    {
        
        TVec<string> addfieldnames;
        if(!input_prg.empty())
        {
            input_prg_.setSource(source);
            input_prg_.compileString(input_prg, addfieldnames);
            inputsize_ = addfieldnames.length();
            fieldnames.append(addfieldnames);
        }
        else
            inputsize_ = 0;

        if(!target_prg.empty())
        {
            target_prg_.setSource(source);
            target_prg_.compileString(target_prg, addfieldnames);
            targetsize_ = addfieldnames.length();
            fieldnames.append(addfieldnames);
        }
        else
            targetsize_ = 0;

        if(!weight_prg.empty())
        {
            weight_prg_.setSource(source);
            weight_prg_.compileString(weight_prg, addfieldnames);
            weightsize_ = addfieldnames.length();
            fieldnames.append(addfieldnames);
        }
        else
            weightsize_ = 0;

        if(!extra_prg.empty())
        {
            extra_prg_.setSource(source);
            extra_prg_.compileString(extra_prg, addfieldnames);
            extrasize_ = addfieldnames.length();
            fieldnames.append(addfieldnames);
        }
        else
            extrasize_ = 0;
        
        width_ = inputsize_+targetsize_+weightsize_+extrasize_;
        declareFieldNames(fieldnames);
        setMetaInfoFromSource();
    }

    sourcevec.resize(source->width());
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::ProcessingVMatrix::classname ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

void PLearn::ProcessingVMatrix::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 94 of file ProcessingVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), extra_prg, input_prg, prg, target_prg, and weight_prg.

{
    declareOption(ol, "prg", &ProcessingVMatrix::prg, OptionBase::buildoption,
                  "The VPL code to be applied to each row of the vmat\n"
                  "You can either specify prg and inputsie, targetsize, weightsize, extrasize\n"
                  "OR ALTERNATIVELY leave prg empty, and specify one or several of \n"
                  "input_prg, target_prg, weight_prg, extra_prg. In this latter case,\n"
                  "the sizes will be set from the corresponding program's number of output fieldnames \n");

    declareOption(ol, "input_prg", &ProcessingVMatrix::input_prg, OptionBase::buildoption,
                  "This option is considered only if prg is the empty string\n"
                  "Program string in VPL language to be applied to each raw input \n"
                  "to generate the new preprocessed input.\n"
                  "Note that names must be given to the generated values with :fieldname VPL syntax.\n");

    declareOption(ol, "target_prg", &ProcessingVMatrix::target_prg, OptionBase::buildoption,
                  "This option is considered only if prg is the empty string\n"
                  "Program string in VPL language to be applied to a dataset row\n"
                  "to generate a proper target for the underlying learner.\n"
                  "Note that names must be given to the generated values with :fieldname VPL syntax.\n");
  
    declareOption(ol, "weight_prg", &ProcessingVMatrix::weight_prg, OptionBase::buildoption,
                  "This option is considered only if prg is the empty string\n"
                  "Program string in VPL language to be applied to a dataset row\n"
                  "to generate a proper weight for the underlying learner.\n"
                  "Note that names must be given to the generated values with :fieldname VPL syntax.\n");

    declareOption(ol, "extra_prg", &ProcessingVMatrix::extra_prg, OptionBase::buildoption,
                  "This option is considered only if prg is the empty string\n"
                  "Program string in VPL language to be applied to a dataset row\n"
                  "to generate proper extra fields for the underlying learner.\n"
                  "Note that names must be given to the generated values with :fieldname VPL syntax.\n");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

static const PPath& PLearn::ProcessingVMatrix::declaringFile ( ) [inline, static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 123 of file ProcessingVMatrix.h.

ProcessingVMatrix * PLearn::ProcessingVMatrix::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

void PLearn::ProcessingVMatrix::getNewRow ( int  i,
const Vec v 
) const [protected, virtual]

This is the only method requiring implementation.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 77 of file ProcessingVMatrix.cc.

References extra_prg, extra_prg_, PLearn::VMatrix::extrasize_, input_prg, input_prg_, PLearn::VMatrix::inputsize_, prg, program, PLearn::VMatLanguage::run(), PLearn::TVec< T >::subVec(), target_prg, target_prg_, PLearn::VMatrix::targetsize_, weight_prg, weight_prg_, and PLearn::VMatrix::weightsize_.

{
    if(!prg.empty()) // we'll use prg rather than the *_prg
        program.run(i,v);
    else // we'll use the *_prg
    {
        if(!input_prg.empty())
            input_prg_.run(i, v.subVec(0, inputsize_));
        if(!target_prg.empty())
            target_prg_.run(i, v.subVec(inputsize_, targetsize_));
        if(!weight_prg.empty())
            weight_prg_.run(i, v.subVec(inputsize_+targetsize_, weightsize_));
        if(!extra_prg.empty())
            extra_prg_.run(i, v.subVec(inputsize_+targetsize_+weightsize_, extrasize_));
    }
}

Here is the call graph for this function:

OptionList & PLearn::ProcessingVMatrix::getOptionList ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

OptionMap & PLearn::ProcessingVMatrix::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

RemoteMethodMap & PLearn::ProcessingVMatrix::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file ProcessingVMatrix.cc.

void PLearn::ProcessingVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 224 of file ProcessingVMatrix.cc.

References PLearn::deepCopyField(), PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy(), and sourcevec.

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 123 of file ProcessingVMatrix.h.

Definition at line 76 of file ProcessingVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 64 of file ProcessingVMatrix.h.

Referenced by build_(), and getNewRow().

Definition at line 73 of file ProcessingVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 61 of file ProcessingVMatrix.h.

Referenced by build_(), and getNewRow().

Definition at line 71 of file ProcessingVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 59 of file ProcessingVMatrix.h.

Referenced by build_(), and getNewRow().

Definition at line 58 of file ProcessingVMatrix.h.

Referenced by build_(), and makeDeepCopyFromShallowCopy().

Definition at line 74 of file ProcessingVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 62 of file ProcessingVMatrix.h.

Referenced by build_(), and getNewRow().

Definition at line 75 of file ProcessingVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 63 of file ProcessingVMatrix.h.

Referenced by build_(), and getNewRow().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines