PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <AddBagInformationVMatrix.h>
Public Member Functions | |
AddBagInformationVMatrix () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual AddBagInformationVMatrix * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
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 PPath & | declaringFile () |
Public Attributes | |
string | bag_info_column |
bool | remove_bag_info_column |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
virtual void | getNewRow (int i, const Vec &v) const |
Fill the vector 'v' with the content of the i-th row. | |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Protected Attributes | |
int | bag_info_idx |
The index of 'bag_info_column' in the source VMat. | |
Private Types | |
typedef SourceVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 57 of file AddBagInformationVMatrix.h.
typedef SourceVMatrix PLearn::AddBagInformationVMatrix::inherited [private] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 59 of file AddBagInformationVMatrix.h.
PLearn::AddBagInformationVMatrix::AddBagInformationVMatrix | ( | ) |
Default constructor.
Definition at line 62 of file AddBagInformationVMatrix.cc.
: remove_bag_info_column(false), bag_info_idx(-1) { }
string PLearn::AddBagInformationVMatrix::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
OptionList & PLearn::AddBagInformationVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
RemoteMethodMap & PLearn::AddBagInformationVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
Object * PLearn::AddBagInformationVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
StaticInitializer AddBagInformationVMatrix::_static_initializer_ & PLearn::AddBagInformationVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
void PLearn::AddBagInformationVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::SourceVMatrix.
Definition at line 92 of file AddBagInformationVMatrix.cc.
References PLearn::SourceVMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::AddBagInformationVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 101 of file AddBagInformationVMatrix.cc.
References PLearn::TVec< T >::append(), bag_info_column, bag_info_idx, PLearn::VMat::getFieldIndex(), i, PLearn::VMatrix::inputsize_, PLearn::TVec< T >::length(), remove_bag_info_column, PLearn::TVec< T >::resize(), PLearn::VMatrix::setFieldInfos(), PLearn::SourceVMatrix::setMetaInfoFromSource(), PLearn::SourceVMatrix::source, PLearn::SourceVMatrix::sourcerow, PLearn::VMatrix::targetsize_, PLearn::VMatrix::updateMtime(), PLearn::VMat::width(), and PLearn::VMatrix::width_.
Referenced by build().
{ if (source) { updateMtime(source); bag_info_idx = source->getFieldIndex(bag_info_column); sourcerow.resize(source->width()); int st = source->targetsize(); if (st >= 0) targetsize_ = st + 1; // Set field infos. Array<VMField> fields = source->getFieldInfos().copy(); fields.append(VMField("bag_info")); width_ = source->width() + 1; inputsize_ = source->inputsize(); if (remove_bag_info_column) { // We need to remove a column from the source VMat. width_--; if( bag_info_idx < inputsize_ ) inputsize_--; Array<VMField> new_fields; for (int i = 0; i < fields.length(); i++) if (i != bag_info_idx) new_fields.append(fields[i]); fields = new_fields; } setFieldInfos(fields); setMetaInfoFromSource(); } }
string PLearn::AddBagInformationVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
void PLearn::AddBagInformationVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 71 of file AddBagInformationVMatrix.cc.
References bag_info_column, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), and remove_bag_info_column.
{ declareOption(ol, "bag_info_column", &AddBagInformationVMatrix::bag_info_column, OptionBase::buildoption, "The source's column that is used to find bags in the data. It can\n" "be either a number or a column's name."); declareOption(ol, "remove_bag_info_column", &AddBagInformationVMatrix::remove_bag_info_column, OptionBase::buildoption, "If true, then the source's column given by bag_info_column is\n" "removed from the resulting data."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::AddBagInformationVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 81 of file AddBagInformationVMatrix.h.
:
AddBagInformationVMatrix * PLearn::AddBagInformationVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
void PLearn::AddBagInformationVMatrix::getNewRow | ( | int | i, |
const Vec & | v | ||
) | const [protected, virtual] |
Fill the vector 'v' with the content of the i-th row.
v is assumed to be the right size. ### This function must be overridden in your class
Reimplemented from PLearn::SourceVMatrix.
Definition at line 138 of file AddBagInformationVMatrix.cc.
References bag_info_idx, PLearn::is_equal(), PLearn::TVec< T >::lastElement(), PLearn::TVec< T >::length(), PLearn::VMatrix::length_, remove_bag_info_column, PLearn::SourceVMatrix::source, PLearn::SourceVMatrix::sourcerow, and PLearn::TVec< T >::subVec().
{ bool is_beg = false; bool is_end = false; // Obtain current bag information. source->getRow(i, sourcerow); real cur = sourcerow[bag_info_idx]; if (i == 0) is_beg = true; else { // Compare with previous sample. real prev = source->get(i - 1, bag_info_idx); if (!is_equal(cur, prev)) is_beg = true; } if (i == length_ - 1) is_end = true; else { // Compare with next sample. real next = source->get(i + 1, bag_info_idx); if (!is_equal(cur, next)) is_end = true; } real bag_info = is_beg ? is_end ? 3 : 1 : is_end ? 2 : 0; if (remove_bag_info_column) { v.subVec(0, bag_info_idx) << sourcerow.subVec(0, bag_info_idx); int n_left = sourcerow.length() - bag_info_idx - 1; v.subVec(bag_info_idx, n_left) << sourcerow.subVec(bag_info_idx + 1, n_left); } else v.subVec(0, sourcerow.length()) << sourcerow; v.lastElement() = bag_info; }
OptionList & PLearn::AddBagInformationVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
OptionMap & PLearn::AddBagInformationVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
RemoteMethodMap & PLearn::AddBagInformationVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddBagInformationVMatrix.cc.
void PLearn::AddBagInformationVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 178 of file AddBagInformationVMatrix.cc.
References PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); }
Reimplemented from PLearn::SourceVMatrix.
Definition at line 81 of file AddBagInformationVMatrix.h.
Definition at line 64 of file AddBagInformationVMatrix.h.
Referenced by build_(), and declareOptions().
int PLearn::AddBagInformationVMatrix::bag_info_idx [protected] |
The index of 'bag_info_column' in the source VMat.
Definition at line 93 of file AddBagInformationVMatrix.h.
Referenced by build_(), and getNewRow().
Definition at line 65 of file AddBagInformationVMatrix.h.
Referenced by build_(), declareOptions(), and getNewRow().