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

#include <FileDictionary.h>

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

List of all members.

Public Member Functions

 FileDictionary ()
 Default constructor.
 FileDictionary (string file_name, bool up_mode=NO_UPDATE)
 Constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual FileDictionarydeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

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 file_name_dict
 file_name of dictionary

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Private Types

typedef Dictionary inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

This class implements a Dictionary instantiated from a file. Each line of the file should be a symbol to be inserted in the dictionary. Blanks are removed at the beginning and end of every line

Definition at line 56 of file FileDictionary.h.


Member Typedef Documentation

Reimplemented from PLearn::Dictionary.

Definition at line 61 of file FileDictionary.h.


Constructor & Destructor Documentation

PLearn::FileDictionary::FileDictionary ( )

Default constructor.

Definition at line 49 of file FileDictionary.cc.

:inherited(){}
PLearn::FileDictionary::FileDictionary ( string  file_name,
bool  up_mode = NO_UPDATE 
)

Constructor.

Parameters:
file_namefile containing the symbols of the dictionary
up_modeupdate mode

Definition at line 51 of file FileDictionary.cc.

References build_(), file_name_dict, and PLearn::Dictionary::setUpdateMode().

{
    setUpdateMode(up_mode);
    file_name_dict=file_name;
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

void PLearn::FileDictionary::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::Dictionary.

Definition at line 97 of file FileDictionary.cc.

References PLearn::Dictionary::build(), and build_().

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::Dictionary.

Definition at line 73 of file FileDictionary.cc.

References file_name_dict, PLearn::Dictionary::getId(), PLERROR, PLearn::removeblanks(), PLearn::Dictionary::size(), UPDATE, and PLearn::Dictionary::update_mode.

Referenced by build(), and FileDictionary().

{
    //initial building
    if(size() == 0) // Verifying if dictionary is new
    {
        // save update mode for later
        int saved_up_mode=update_mode;
        // set the dictionary in update mode to insert the words
        update_mode =  UPDATE;
        string line;
        ifstream ifs(file_name_dict.c_str());
        if (!ifs) PLERROR("Cannot open file %s", file_name_dict.c_str());
        while(!ifs.eof()){
            getline(ifs, line, '\n');
            if(line == "") continue;
            getId(removeblanks(line));
        }
        ifs.close();
        // restore update mode;
        update_mode=saved_up_mode;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::FileDictionary::classname ( ) const [virtual]

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Declares this class' options.

Reimplemented from PLearn::Dictionary.

Definition at line 64 of file FileDictionary.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Dictionary::declareOptions(), and file_name_dict.

{
    declareOption(ol, "file_name_dict", 
                  &FileDictionary::file_name_dict, 
                  OptionBase::buildoption, 
                  "File name for the dictionary");
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Dictionary.

Definition at line 107 of file FileDictionary.h.

FileDictionary * PLearn::FileDictionary::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Reimplemented from PLearn::Dictionary.

Definition at line 62 of file FileDictionary.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Dictionary.

Definition at line 103 of file FileDictionary.cc.

References PLearn::Dictionary::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Dictionary.

Definition at line 107 of file FileDictionary.h.

file_name of dictionary

Definition at line 74 of file FileDictionary.h.

Referenced by build_(), declareOptions(), and FileDictionary().


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