PLearn 0.1
|
VMatrix the reindexes the target fields of a source VMatrix, according to the getValues(row,target_col) function, where row contains the values of a row of the source VMatrix, and target_col is the column index of (one of ) the target field. More...
#include <ReIndexedTargetVMatrix.h>
Public Member Functions | |
ReIndexedTargetVMatrix () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ReIndexedTargetVMatrix * | 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 | |
bool | ignore_oov_tag |
Indication that the OOV_TAG must be ignored in the possible values. | |
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. | |
Private Types | |
typedef SourceVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
Private Attributes | |
Vec | values |
Vector of possible values. | |
int | t |
getNewRow temporary values | |
int | index |
int | oov_index |
VMatrix the reindexes the target fields of a source VMatrix, according to the getValues(row,target_col) function, where row contains the values of a row of the source VMatrix, and target_col is the column index of (one of ) the target field.
This is useful when the possible target values change from one row to another. This way, target values will range from 0 to getValues(row,target_col).length()-1. The source VMatrix must be able to fournish the Dictionary objects for the target fields.
Definition at line 61 of file ReIndexedTargetVMatrix.h.
typedef SourceVMatrix PLearn::ReIndexedTargetVMatrix::inherited [private] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 63 of file ReIndexedTargetVMatrix.h.
PLearn::ReIndexedTargetVMatrix::ReIndexedTargetVMatrix | ( | ) |
Default constructor.
Definition at line 59 of file ReIndexedTargetVMatrix.cc.
: ignore_oov_tag(false) {}
string PLearn::ReIndexedTargetVMatrix::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
OptionList & PLearn::ReIndexedTargetVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
RemoteMethodMap & PLearn::ReIndexedTargetVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
Object * PLearn::ReIndexedTargetVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
StaticInitializer ReIndexedTargetVMatrix::_static_initializer_ & PLearn::ReIndexedTargetVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
void PLearn::ReIndexedTargetVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::SourceVMatrix.
Definition at line 77 of file ReIndexedTargetVMatrix.cc.
References PLearn::SourceVMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ReIndexedTargetVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 86 of file ReIndexedTargetVMatrix.cc.
References PLearn::SourceVMatrix::setMetaInfoFromSource().
Referenced by build().
{ setMetaInfoFromSource(); }
string PLearn::ReIndexedTargetVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
void PLearn::ReIndexedTargetVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 66 of file ReIndexedTargetVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), and ignore_oov_tag.
{ declareOption(ol, "ignore_oov_tag", &ReIndexedTargetVMatrix::ignore_oov_tag, OptionBase::buildoption, "Indication that the OOV_TAG must be ignored in the possible values.\n"); inherited::declareOptions(ol); }
static const PPath& PLearn::ReIndexedTargetVMatrix::declaringFile | ( | ) | [inline, static] |
ReIndexedTargetVMatrix * PLearn::ReIndexedTargetVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
Fill the vector 'v' with the content of the i-th row.
v is assumed to be the right size.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 94 of file ReIndexedTargetVMatrix.cc.
References PLearn::TVec< T >::find(), ignore_oov_tag, index, PLearn::VMatrix::inputsize_, PLearn::TVec< T >::length(), oov_index, OOV_TAG, PLERROR, PLearn::SourceVMatrix::source, t, PLearn::VMatrix::targetsize_, and values.
{ source->getRow(i,v); for(t=inputsize_; t<targetsize_+inputsize_; t++) { source->getValues(i,t,values); oov_index = -1; if(ignore_oov_tag) { oov_index = source->getDictionary()->getId(OOV_TAG); oov_index = values.find(oov_index); } if(oov_index < 0) oov_index = values.length(); index = values.find(v[t]); if(index < 0) PLERROR("In ReIndexedTargetVMatrix::getNewRow(): target (%d) isn't a possible value", v[t]); if(index == oov_index) PLERROR("In ReIndexedTargetVMatrix::getNewRow(): target (%d) is OOV_TAG, but OOV_TAG ignored", v[t]); v[t] = index<oov_index?index:index-1; } }
OptionList & PLearn::ReIndexedTargetVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
OptionMap & PLearn::ReIndexedTargetVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
RemoteMethodMap & PLearn::ReIndexedTargetVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 54 of file ReIndexedTargetVMatrix.cc.
void PLearn::ReIndexedTargetVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 119 of file ReIndexedTargetVMatrix.cc.
References PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); }
Reimplemented from PLearn::SourceVMatrix.
Definition at line 76 of file ReIndexedTargetVMatrix.h.
Indication that the OOV_TAG must be ignored in the possible values.
Definition at line 68 of file ReIndexedTargetVMatrix.h.
Referenced by declareOptions(), and getNewRow().
int PLearn::ReIndexedTargetVMatrix::index [private] |
Definition at line 105 of file ReIndexedTargetVMatrix.h.
Referenced by getNewRow().
int PLearn::ReIndexedTargetVMatrix::oov_index [private] |
Definition at line 105 of file ReIndexedTargetVMatrix.h.
Referenced by getNewRow().
int PLearn::ReIndexedTargetVMatrix::t [private] |
getNewRow temporary values
Definition at line 105 of file ReIndexedTargetVMatrix.h.
Referenced by getNewRow().
Vec PLearn::ReIndexedTargetVMatrix::values [private] |
Vector of possible values.
Definition at line 102 of file ReIndexedTargetVMatrix.h.
Referenced by getNewRow().