| 
    PLearn 0.1 
   | 
 
FeatureSet with features being defined using a python script. More...
#include <PythonFeatureSet.h>


Public Member Functions | |
| PythonFeatureSet () | |
| Default constructor.   | |
| virtual string | classname () const | 
| virtual OptionList & | getOptionList () const | 
| virtual OptionMap & | getOptionMap () const | 
| virtual RemoteMethodMap & | getRemoteMethodMap () const | 
| virtual PythonFeatureSet * | deepCopy (CopiesMap &copies) const | 
| virtual void | build () | 
| Post-constructor.   | |
| virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) | 
| Transforms a shallow copy into a deep copy.   | |
| 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 PPath & | declaringFile () | 
Public Attributes | |
| string | code | 
| Snippet of python code that outputs the features.   | |
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ | 
Static Protected Member Functions | |
| static void | declareOptions (OptionList &ol) | 
| Declares the class options.   | |
Protected Attributes | |
| PP< PythonCodeSnippet > | python | 
| Python code snippet.   | |
Private Types | |
| typedef HashMapFeatureSet | inherited | 
Private Member Functions | |
| void | build_ () | 
| This does the actual building.   | |
Private Attributes | |
| TVec< string > | f_str | 
| Temporary computations vectors.   | |
FeatureSet with features being defined using a python script.
The python script should define a getNewFeaturesString function which has to output a vector of string features for the input token
Definition at line 53 of file PythonFeatureSet.h.
typedef HashMapFeatureSet PLearn::PythonFeatureSet::inherited [private] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 55 of file PythonFeatureSet.h.
| PLearn::PythonFeatureSet::PythonFeatureSet | ( | ) | 
| string PLearn::PythonFeatureSet::_classname_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 50 of file PythonFeatureSet.cc.
| OptionList & PLearn::PythonFeatureSet::_getOptionList_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 50 of file PythonFeatureSet.cc.
| RemoteMethodMap & PLearn::PythonFeatureSet::_getRemoteMethodMap_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 50 of file PythonFeatureSet.cc.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 50 of file PythonFeatureSet.cc.
| Object * PLearn::PythonFeatureSet::_new_instance_for_typemap_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::Object.
Definition at line 50 of file PythonFeatureSet.cc.
| StaticInitializer PythonFeatureSet::_static_initializer_ & PLearn::PythonFeatureSet::_static_initialize_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 50 of file PythonFeatureSet.cc.
| void PLearn::PythonFeatureSet::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::HashMapFeatureSet.
Definition at line 57 of file PythonFeatureSet.cc.
References PLearn::HashMapFeatureSet::build(), and build_().
{
    inherited::build();
    build_();
}

| void PLearn::PythonFeatureSet::build_ | ( | ) |  [private] | 
        
This does the actual building.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 80 of file PythonFeatureSet.cc.
References code, PLASSERT, and python.
Referenced by build(), and getNewFeaturesString().

| string PLearn::PythonFeatureSet::classname | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 50 of file PythonFeatureSet.cc.
| void PLearn::PythonFeatureSet::declareOptions | ( | OptionList & | ol | ) |  [static, protected] | 
        
Declares the class options.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 70 of file PythonFeatureSet.cc.
References PLearn::OptionBase::buildoption, code, PLearn::declareOption(), and PLearn::HashMapFeatureSet::declareOptions().
{
    declareOption(ol, "code", &PythonFeatureSet::code,
                  OptionBase::buildoption,
                  "Snippet of python code that outputs the features");
    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

| static const PPath& PLearn::PythonFeatureSet::declaringFile | ( | ) |  [inline, static] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 72 of file PythonFeatureSet.h.
:
    //#####  Protected Options  ###############################################
| PythonFeatureSet * PLearn::PythonFeatureSet::deepCopy | ( | CopiesMap & | copies | ) |  const [virtual] | 
        
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 50 of file PythonFeatureSet.cc.
| void PLearn::PythonFeatureSet::getNewFeaturesString | ( | string | token, | 
| TVec< string > & | feats_str | ||
| ) |  [virtual] | 
        
Gives the possibly new features in string form for a token.
Implements PLearn::HashMapFeatureSet.
Definition at line 91 of file PythonFeatureSet.cc.
References build_(), f_str, PLearn::TVec< T >::length(), python, and PLearn::TVec< T >::resize().
{
    f_str.resize(1);
    f_str[0] = token;
    if(!python) build_();
    f_str = python->invoke("getNewFeaturesString",f_str).as<TVec<string> >();
    feats_str.resize(f_str.length());
    feats_str << f_str;
}

| OptionList & PLearn::PythonFeatureSet::getOptionList | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 50 of file PythonFeatureSet.cc.
| OptionMap & PLearn::PythonFeatureSet::getOptionMap | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 50 of file PythonFeatureSet.cc.
| RemoteMethodMap & PLearn::PythonFeatureSet::getRemoteMethodMap | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 50 of file PythonFeatureSet.cc.
| void PLearn::PythonFeatureSet::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) |  [virtual] | 
        
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 63 of file PythonFeatureSet.cc.
References PLearn::HashMapFeatureSet::makeDeepCopyFromShallowCopy().
{
    inherited::makeDeepCopyFromShallowCopy(copies);
    //deepCopyField(python, copies);
    //PLERROR("PythonFeatureSet::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 72 of file PythonFeatureSet.h.
Snippet of python code that outputs the features.
Definition at line 61 of file PythonFeatureSet.h.
Referenced by build_(), and declareOptions().
TVec<string> PLearn::PythonFeatureSet::f_str [private] | 
        
Temporary computations vectors.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 105 of file PythonFeatureSet.h.
Referenced by getNewFeaturesString().
PP<PythonCodeSnippet> PLearn::PythonFeatureSet::python [protected] | 
        
Python code snippet.
Definition at line 87 of file PythonFeatureSet.h.
Referenced by build_(), and getNewFeaturesString().
 1.7.4