|
PLearn 0.1
|
#include <FileDictionary.h>


Public Member Functions | |
| FileDictionary () | |
| Default constructor. | |
| FileDictionary (string file_name, bool up_mode=NO_UPDATE) | |
| Constructor. | |
| virtual string | classname () const |
| virtual OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual FileDictionary * | deepCopy (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 PPath & | declaringFile () |
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. | |
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.
typedef Dictionary PLearn::FileDictionary::inherited [private] |
Reimplemented from PLearn::Dictionary.
Definition at line 61 of file FileDictionary.h.
| PLearn::FileDictionary::FileDictionary | ( | ) |
| PLearn::FileDictionary::FileDictionary | ( | string | file_name, |
| bool | up_mode = NO_UPDATE |
||
| ) |
Constructor.
| file_name | file containing the symbols of the dictionary |
| up_mode | update 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_();
}

| 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.
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_().
{
inherited::build();
build_();
}

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


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

| 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().
{
inherited::makeDeepCopyFromShallowCopy(copies);
}

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