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
PLearn::SymbolNode Class Reference

#include <SymbolNode.h>

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

List of all members.

Public Member Functions

 SymbolNode ()
 Default constructor.
 SymbolNode (int symbol_)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SymbolNodedeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
PP< SymbolNodeadd (int child_)
 Adds a child to this node.
void incr ()
 Increments the node's frequency (normalization factor)
void incr (int symbol)
 Increments the given symbol's frequency in frequencies map.
int freq ()
 Gives frequency of the node (normalization factor)
int freq (int symbol)
 Gives frequence of a given symbol at that node.
int n_children ()
 Gives the number of children.
int n_freq ()
 Gives the number of different symbol in frequencies map.
map< int, int > * freqs ()
 Gives a pointer to the frequencies map.
PP< SymbolNodechild (int child_)
 Gives the corresponding SymbolNode child, or 0 if nonexistant.
TVec< PP< SymbolNode > > getChildren ()
 Gives all children of current node.

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

int symbol

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Protected Attributes

int frequence
 Normalisation factor.
map< int, PP< SymbolNode > > children
 Children and their frequences.
map< int, intfrequencies

Private Types

typedef Object inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 53 of file SymbolNode.h.


Member Typedef Documentation

Reimplemented from PLearn::Object.

Definition at line 58 of file SymbolNode.h.


Constructor & Destructor Documentation

PLearn::SymbolNode::SymbolNode ( )

Default constructor.

Definition at line 49 of file SymbolNode.cc.

{
    frequence = 0;
    symbol = -1;
}
PLearn::SymbolNode::SymbolNode ( int  symbol_)

Definition at line 56 of file SymbolNode.cc.

{
    frequence = 0;
    symbol = symbol_;
}

Member Function Documentation

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

PP< SymbolNode > PLearn::SymbolNode::add ( int  child_)

Adds a child to this node.

Definition at line 100 of file SymbolNode.cc.

{
    PP<SymbolNode> cn;
    map<int,PP<SymbolNode> >::iterator it = children.find(child_);
    if(it == children.end())
    {
        cn = new SymbolNode(child_);
        children[child_] = cn;
    }
    else
    {
        cn = it->second;
    }
    return cn;
}
void PLearn::SymbolNode::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::Object.

Definition at line 85 of file SymbolNode.cc.

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

This does the actual building.

Reimplemented from PLearn::Object.

Definition at line 82 of file SymbolNode.cc.

{}
PP< SymbolNode > PLearn::SymbolNode::child ( int  child_)

Gives the corresponding SymbolNode child, or 0 if nonexistant.

Definition at line 116 of file SymbolNode.cc.

{
    if(children.find(child_) == children.end())
        return 0;

    return children.find(child_)->second;
}
string PLearn::SymbolNode::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Declares this class' options.

Reimplemented from PLearn::Object.

Definition at line 68 of file SymbolNode.cc.

References PLearn::OptionBase::buildoption, children, PLearn::declareOption(), frequence, frequencies, PLearn::OptionBase::learntoption, and symbol.

{
    declareOption(ol, "frequence", &SymbolNode::frequence, OptionBase::learntoption,
                  "Frequence associated to this node");
    declareOption(ol, "frequencies", &SymbolNode::frequencies, OptionBase::learntoption,
                  "Frequencies associated to a symbol at this node");
    declareOption(ol, "symbol", &SymbolNode::symbol, OptionBase::buildoption,
                  "Symbol associated to this node");
    declareOption(ol, "children", &SymbolNode::children, OptionBase::buildoption,
                  "Children of this node");

    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 103 of file SymbolNode.h.

{frequence++;}
SymbolNode * PLearn::SymbolNode::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

int PLearn::SymbolNode::freq ( int  symbol)

Gives frequence of a given symbol at that node.

Definition at line 133 of file SymbolNode.cc.

{
    map<int,int>::iterator it = frequencies.find(symbol);
    if(it == frequencies.end())
        return 0;
    else
        return it->second;
}
int PLearn::SymbolNode::freq ( ) [inline]

Gives frequency of the node (normalization factor)

Definition at line 121 of file SymbolNode.h.

{return frequence;}
map<int,int>* PLearn::SymbolNode::freqs ( ) [inline]

Gives a pointer to the frequencies map.

Definition at line 133 of file SymbolNode.h.

{ return &frequencies;}
TVec< PP< SymbolNode > > PLearn::SymbolNode::getChildren ( )

Gives all children of current node.

Definition at line 124 of file SymbolNode.cc.

References i.

{
    TVec<PP<SymbolNode> > ret(children.size());
    int i=0;
    for(map<int,PP<SymbolNode> >::iterator it = children.begin(); it != children.end(); it++)
        ret[i++] = it->second;
    return ret;
}
OptionList & PLearn::SymbolNode::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

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

Reimplemented from PLearn::Object.

Definition at line 66 of file SymbolNode.cc.

void PLearn::SymbolNode::incr ( int  symbol)

Increments the given symbol's frequency in frequencies map.

Definition at line 142 of file SymbolNode.cc.

{
    incr();
    map<int,int>::iterator it = frequencies.find(symbol);
    if(it == frequencies.end())
        frequencies[symbol] = 1;
    else
    {
        int temp = it->second;
        frequencies[symbol] = temp+1;
    }
}
void PLearn::SymbolNode::incr ( ) [inline]

Increments the node's frequency (normalization factor)

Definition at line 115 of file SymbolNode.h.

{frequence++;}
void PLearn::SymbolNode::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Object.

Definition at line 91 of file SymbolNode.cc.

References PLearn::deepCopyField().

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    deepCopyField(children, copies);
    deepCopyField(frequencies, copies);
    //PLERROR("SymbolNode::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

int PLearn::SymbolNode::n_children ( ) [inline]

Gives the number of children.

Definition at line 127 of file SymbolNode.h.

{return children.size();}
int PLearn::SymbolNode::n_freq ( ) [inline]

Gives the number of different symbol in frequencies map.

Definition at line 130 of file SymbolNode.h.

{return frequencies.size();}

Member Data Documentation

Reimplemented from PLearn::Object.

Definition at line 103 of file SymbolNode.h.

Children and their frequences.

Definition at line 69 of file SymbolNode.h.

Referenced by declareOptions().

Normalisation factor.

Definition at line 66 of file SymbolNode.h.

Referenced by declareOptions().

Definition at line 70 of file SymbolNode.h.

Referenced by declareOptions().

Definition at line 78 of file SymbolNode.h.

Referenced by declareOptions().


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