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

FeatureSet with features being defined using a python script. More...

#include <PythonFeatureSet.h>

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

List of all members.

Public Member Functions

 PythonFeatureSet ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual PythonFeatureSetdeepCopy (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 PPathdeclaringFile ()

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< PythonCodeSnippetpython
 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.

Detailed Description

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.


Member Typedef Documentation

Reimplemented from PLearn::HashMapFeatureSet.

Definition at line 55 of file PythonFeatureSet.h.


Constructor & Destructor Documentation

PLearn::PythonFeatureSet::PythonFeatureSet ( )

Default constructor.

Definition at line 52 of file PythonFeatureSet.cc.

    : python()
{}

Member Function Documentation

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.

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

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_().

Here is the call graph for this function:

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().

{
    if (code != "")
    {
        python = new PythonCodeSnippet(code);
        PLASSERT( python );
        python->build();
    }

}

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

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!");
}

Here is the call graph for this function:


Member Data Documentation

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().

Temporary computations vectors.

Reimplemented from PLearn::HashMapFeatureSet.

Definition at line 105 of file PythonFeatureSet.h.

Referenced by getNewFeaturesString().

Python code snippet.

Definition at line 87 of file PythonFeatureSet.h.

Referenced by build_(), and getNewFeaturesString().


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