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

Feature set that is the concatenation of disjoint feature sets. More...

#include <ConcatDisjointFeatureSet.h>

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

List of all members.

Public Member Functions

 ConcatDisjointFeatureSet ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ConcatDisjointFeatureSetdeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual void getFeatures (string token, TVec< int > &feats)
 Gives features of token in index form.
virtual string getStringFeature (int index)
 Gives string form of a feature in index form.
virtual int getIndexFeature (string str)
 Gives index form of a feature in string form.
virtual int size ()
 Gives the number of features in the set.
virtual void addFeatures (string token)
 Adds the features for a given token in the set.
virtual void addFeatures (VMat tokens, int min_freq=-1)
 Adds the features for the tokens contained in the set.
virtual void clear ()
 Clears all features from the feature set.
virtual void getNewFeaturesString (string token, TVec< string > &feats_str)
 Gives the possibly new features in string form for a token.

Static Public Member Functions

static string _classname_ ()
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

TVec< PP< FeatureSet > > feature_sets
 Feature sets to concatenate.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Private Types

typedef FeatureSet inherited

Private Member Functions

void build_ ()
 This does the actual building.

Private Attributes

TVec< string > f_str
 Temporary computations variables.
TVec< intsubfeats
string s

Detailed Description

Feature set that is the concatenation of disjoint feature sets.

This class concatenates different feature sets but forces them to be disjoint. This means that, even though two feature sets to concatenate contain the same feature, a distinction will be made between the feature coming from the first and second set.

Definition at line 55 of file ConcatDisjointFeatureSet.h.


Member Typedef Documentation

Reimplemented from PLearn::FeatureSet.

Definition at line 57 of file ConcatDisjointFeatureSet.h.


Constructor & Destructor Documentation

PLearn::ConcatDisjointFeatureSet::ConcatDisjointFeatureSet ( )

Default constructor.

Definition at line 55 of file ConcatDisjointFeatureSet.cc.

{}

Member Function Documentation

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

Reimplemented from PLearn::FeatureSet.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::FeatureSet.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::FeatureSet.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::FeatureSet.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::FeatureSet.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

void PLearn::ConcatDisjointFeatureSet::addFeatures ( string  token) [virtual]

Adds the features for a given token in the set.

Implements PLearn::FeatureSet.

Definition at line 149 of file ConcatDisjointFeatureSet.cc.

References i.

{
    for(int i=0; i<feature_sets.length(); i++)
        feature_sets[i]->addFeatures(token);
}
void PLearn::ConcatDisjointFeatureSet::addFeatures ( VMat  tokens,
int  min_freq = -1 
) [virtual]

Adds the features for the tokens contained in the set.

Features with frequency smaller than min_freq are not added.

Implements PLearn::FeatureSet.

Definition at line 155 of file ConcatDisjointFeatureSet.cc.

References i.

{
    for(int i=0; i<feature_sets.length(); i++)
        feature_sets[i]->addFeatures(tokens, min_freq);
}
void PLearn::ConcatDisjointFeatureSet::build ( ) [virtual]

Post-constructor.

The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::FeatureSet.

Definition at line 59 of file ConcatDisjointFeatureSet.cc.

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

This does the actual building.

Reimplemented from PLearn::FeatureSet.

Definition at line 82 of file ConcatDisjointFeatureSet.cc.

{
    // Making sure subfeats has a non-null storage
    subfeats.resize(1);
    subfeats.resize(0);
}
string PLearn::ConcatDisjointFeatureSet::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

void PLearn::ConcatDisjointFeatureSet::clear ( ) [virtual]

Clears all features from the feature set.

Implements PLearn::FeatureSet.

Definition at line 161 of file ConcatDisjointFeatureSet.cc.

References PLearn::clear(), and i.

{
    for(int i=0; i<feature_sets.length(); i++)
        feature_sets[i]->clear();
}

Here is the call graph for this function:

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

Declares the class options.

Reimplemented from PLearn::FeatureSet.

Definition at line 72 of file ConcatDisjointFeatureSet.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), and feature_sets.

{
    // Now call the parent class' declareOptions
    declareOption(ol, "feature_sets", &ConcatDisjointFeatureSet::feature_sets,
                  OptionBase::buildoption,
                  "Feature sets to concatenate");

    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::FeatureSet.

Definition at line 74 of file ConcatDisjointFeatureSet.h.

:
    //#####  Protected Options  ###############################################
ConcatDisjointFeatureSet * PLearn::ConcatDisjointFeatureSet::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::FeatureSet.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

void PLearn::ConcatDisjointFeatureSet::getFeatures ( string  token,
TVec< int > &  feats 
) [virtual]

Gives features of token in index form.

Implements PLearn::FeatureSet.

Definition at line 89 of file ConcatDisjointFeatureSet.cc.

References PLearn::TVec< T >::append(), i, and PLearn::TVec< T >::resize().

{
    feats.resize(0);
    int s = 0;
    for(int i=0; i<feature_sets.length(); i++)
    {
        feature_sets[i]->getFeatures(token,subfeats);
        subfeats += s;
        feats.append(subfeats);
        s += feature_sets[i]->size();
    }
}

Here is the call graph for this function:

int PLearn::ConcatDisjointFeatureSet::getIndexFeature ( string  str) [virtual]

Gives index form of a feature in string form.

Implements PLearn::FeatureSet.

Definition at line 129 of file ConcatDisjointFeatureSet.cc.

References i, PLERROR, PLearn::toint(), and PLearn::tostring().

{
    int fi = toint(tostring(str[1]));
    int s = 0;
#ifdef BOUNDCHECK
    if(fi >= feature_sets.length()) PLERROR("In ConcatDisjointFeatureSet::getIndexFeature(): string prefix %s of feature is invalid", str.substr(0,3).c_str());
#endif
    for(int i=0; i<fi; i++)
        s += feature_sets[i]->size();
    return feature_sets[fi]->getIndexFeature(str.substr(3,str.length()-3))+s;
}

Here is the call graph for this function:

void PLearn::ConcatDisjointFeatureSet::getNewFeaturesString ( string  token,
TVec< string > &  feats_str 
) [virtual]

Gives the possibly new features in string form for a token.

Implements PLearn::FeatureSet.

Definition at line 102 of file ConcatDisjointFeatureSet.cc.

References PLearn::TVec< T >::append(), i, j, PLearn::TVec< T >::resize(), and PLearn::tostring().

{
    feats_str.resize(0);
    for(int i=0; i<feature_sets.length(); i++)
    {
        feature_sets[i]->getNewFeaturesString(token, f_str);
        for(int j=0; j<f_str.length(); j++)
            f_str[j] = "f" + tostring(i) + ":" + f_str[j];
        feats_str.append(f_str);
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConcatDisjointFeatureSet.cc.

string PLearn::ConcatDisjointFeatureSet::getStringFeature ( int  index) [virtual]

Gives string form of a feature in index form.

Implements PLearn::FeatureSet.

Definition at line 114 of file ConcatDisjointFeatureSet.cc.

References i, PLERROR, and PLearn::tostring().

{
#ifdef BOUNDCHECK
    if(index<0 || index >= size()) PLERROR("In ConcatDisjointFeatureSet::getStringFeature(): index %d is an invalid feature index", index);
#endif
    int sub_index = index;
    for(int i=0; i<feature_sets.length(); i++)
    {
        if(sub_index<feature_sets[i]->size()) return "f" + tostring(i) + ":" + feature_sets[i]->getStringFeature(sub_index);
        else sub_index -= feature_sets[i]->size();
    }
    PLERROR("In ConcatDisjointFeatureSet::getStringFeature(): index %d is an invalid feature index", index);
    return "";
}

Here is the call graph for this function:

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::FeatureSet.

Definition at line 65 of file ConcatDisjointFeatureSet.cc.

References PLearn::deepCopyField().

{
    inherited::makeDeepCopyFromShallowCopy(copies);
    deepCopyField(feature_sets, copies);
    //PLERROR("ConcatDisjointFeatureSet::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

int PLearn::ConcatDisjointFeatureSet::size ( ) [virtual]

Gives the number of features in the set.

Implements PLearn::FeatureSet.

Definition at line 141 of file ConcatDisjointFeatureSet.cc.

References i.

{
    int ret = 0;
    for(int i=0; i<feature_sets.length(); i++)
        ret += feature_sets[i]->size();
    return ret;
}

Member Data Documentation

Reimplemented from PLearn::FeatureSet.

Definition at line 74 of file ConcatDisjointFeatureSet.h.

Temporary computations variables.

Definition at line 126 of file ConcatDisjointFeatureSet.h.

Feature sets to concatenate.

Definition at line 63 of file ConcatDisjointFeatureSet.h.

Referenced by declareOptions().

Definition at line 128 of file ConcatDisjointFeatureSet.h.

Definition at line 127 of file ConcatDisjointFeatureSet.h.


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