| 
    PLearn 0.1 
   | 
 
#include <SymbolNode.h>


Public Member Functions | |
| SymbolNode () | |
| Default constructor.   | |
| SymbolNode (int symbol_) | |
| virtual string | classname () const | 
| virtual OptionList & | getOptionList () const | 
| virtual OptionMap & | getOptionMap () const | 
| virtual RemoteMethodMap & | getRemoteMethodMap () const | 
| virtual SymbolNode * | deepCopy (CopiesMap &copies) const | 
| virtual void | build () | 
| Post-constructor.   | |
| virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) | 
| Transforms a shallow copy into a deep copy.   | |
| PP< SymbolNode > | add (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< SymbolNode > | child (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 PPath & | declaringFile () | 
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, int > | frequencies | 
Private Types | |
| typedef Object | inherited | 
Private Member Functions | |
| void | build_ () | 
| This does the actual building.   | |
Definition at line 53 of file SymbolNode.h.
typedef Object PLearn::SymbolNode::inherited [private] | 
        
Reimplemented from PLearn::Object.
Definition at line 58 of file SymbolNode.h.
| PLearn::SymbolNode::SymbolNode | ( | ) | 
| PLearn::SymbolNode::SymbolNode | ( | int | symbol_ | ) | 
Definition at line 56 of file SymbolNode.cc.
| 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.
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.
{
    inherited::build();
    build_();
}
| 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.
| 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);
}

| static const PPath& PLearn::SymbolNode::declaringFile | ( | ) |  [inline, static] | 
        
| SymbolNode * PLearn::SymbolNode::deepCopy | ( | CopiesMap & | copies | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 66 of file SymbolNode.cc.
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;}
Gives a pointer to the frequencies map.
Definition at line 133 of file SymbolNode.h.
{ return &frequencies;}
| TVec< PP< SymbolNode > > PLearn::SymbolNode::getChildren | ( | ) | 
| 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!");
}

| 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();}
Reimplemented from PLearn::Object.
Definition at line 103 of file SymbolNode.h.
map<int,PP<SymbolNode> > PLearn::SymbolNode::children [protected] | 
        
Children and their frequences.
Definition at line 69 of file SymbolNode.h.
Referenced by declareOptions().
int PLearn::SymbolNode::frequence [protected] | 
        
map<int,int> PLearn::SymbolNode::frequencies [protected] | 
        
Definition at line 70 of file SymbolNode.h.
Referenced by declareOptions().
Definition at line 78 of file SymbolNode.h.
Referenced by declareOptions().
 1.7.4