PLearn 0.1
|
FeatureSet with features from WordNet. More...
#include <WordNetFeatureSet.h>
Public Member Functions | |
WordNetFeatureSet () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual WordNetFeatureSet * | deepCopy (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 PPath & | declaringFile () |
Public Attributes | |
bool | stem_token |
Indication that the input token should be stemmed. | |
bool | use_wordnet_hierarchy |
Indication that features should include information from the WordNet hierarchy, not just the token's possible senses. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef HashMapFeatureSet | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
Private Attributes | |
TVec< string > | f_str |
Temporary computations vectors. | |
TVec< string > | s_str |
TVec< string > | stems |
TVec< TVec< string > > | anc_str |
TVec< int > | tagcnts |
FeatureSet with features from WordNet.
The feature of a token (word) corresponds to the set of its possible WordNet senses or synsets. The hierarchy of WordNet can also be used to obtain the synset ancestors of these senses and use them as additional features. The input token can also be stemmed before doing the WordNet searches.
Definition at line 55 of file WordNetFeatureSet.h.
typedef HashMapFeatureSet PLearn::WordNetFeatureSet::inherited [private] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 57 of file WordNetFeatureSet.h.
PLearn::WordNetFeatureSet::WordNetFeatureSet | ( | ) |
Default constructor.
Definition at line 56 of file WordNetFeatureSet.cc.
References PLERROR.
: stem_token(true), use_wordnet_hierarchy(true) { if(wninit()<0) PLERROR("In WordNetFeatureSet(): could not open WordNet database files"); }
string PLearn::WordNetFeatureSet::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 54 of file WordNetFeatureSet.cc.
OptionList & PLearn::WordNetFeatureSet::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 54 of file WordNetFeatureSet.cc.
RemoteMethodMap & PLearn::WordNetFeatureSet::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 54 of file WordNetFeatureSet.cc.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 54 of file WordNetFeatureSet.cc.
Object * PLearn::WordNetFeatureSet::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 54 of file WordNetFeatureSet.cc.
StaticInitializer WordNetFeatureSet::_static_initializer_ & PLearn::WordNetFeatureSet::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 54 of file WordNetFeatureSet.cc.
void PLearn::WordNetFeatureSet::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 64 of file WordNetFeatureSet.cc.
References PLearn::HashMapFeatureSet::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::WordNetFeatureSet::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 90 of file WordNetFeatureSet.cc.
Referenced by build().
{}
string PLearn::WordNetFeatureSet::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file WordNetFeatureSet.cc.
void PLearn::WordNetFeatureSet::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 76 of file WordNetFeatureSet.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::HashMapFeatureSet::declareOptions(), stem_token, and use_wordnet_hierarchy.
{ declareOption(ol, "stem_token", &WordNetFeatureSet::stem_token, OptionBase::buildoption, "Indication that the input token should be stemmed"); declareOption(ol, "use_wordnet_hierarchy", &WordNetFeatureSet::use_wordnet_hierarchy, OptionBase::buildoption, "Indication that features should include information from the\n" "WordNet hierarchy, not just the token's possible senses.\n"); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::WordNetFeatureSet::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 77 of file WordNetFeatureSet.h.
:
//##### Protected Options ###############################################
WordNetFeatureSet * PLearn::WordNetFeatureSet::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 54 of file WordNetFeatureSet.cc.
void PLearn::WordNetFeatureSet::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 93 of file WordNetFeatureSet.cc.
References anc_str, PLearn::TVec< T >::appendIfNotThereAlready(), PLearn::extractSenses(), i, PLearn::TVec< T >::length(), PLearn::TVec< T >::resize(), s_str, stem_token, stems, PLearn::stemsOfWord(), tagcnts, and use_wordnet_hierarchy.
{ feats_str.resize(0); s_str.resize(0); anc_str.resize(0); // Extract senses for all possible POS // NOUN extractSenses(token,NOUN,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); if(stem_token) { stemsOfWord(token,NOUN,stems); for(int i=0; i<stems.length(); i++) { if(token != stems[i]) extractSenses(stems[i],NOUN,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); } } // VERB extractSenses(token,VERB,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); if(stem_token) { stemsOfWord(token,VERB,stems); for(int i=0; i<stems.length(); i++) if(token != stems[i]) extractSenses(stems[i],VERB,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); } // ADJ extractSenses(token,ADJ,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); if(stem_token) { stemsOfWord(token,ADJ,stems); for(int i=0; i<stems.length(); i++) if(token != stems[i]) extractSenses(stems[i],ADJ,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); } // ADV extractSenses(token,ADV,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); if(stem_token) { stemsOfWord(token,ADV,stems); for(int i=0; i<stems.length(); i++) if(token != stems[i]) extractSenses(stems[i],ADV,"synset_key",s_str, tagcnts, anc_str, use_wordnet_hierarchy); } if(use_wordnet_hierarchy) for(int t=0; t<anc_str.length(); t++) for(int s=0; s<anc_str[t].length(); s++) feats_str.appendIfNotThereAlready(anc_str[t][s]); else for(int t=0; t<s_str.length(); t++) feats_str.appendIfNotThereAlready(s_str[t]); }
OptionList & PLearn::WordNetFeatureSet::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file WordNetFeatureSet.cc.
OptionMap & PLearn::WordNetFeatureSet::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file WordNetFeatureSet.cc.
RemoteMethodMap & PLearn::WordNetFeatureSet::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file WordNetFeatureSet.cc.
void PLearn::WordNetFeatureSet::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 70 of file WordNetFeatureSet.cc.
References PLearn::HashMapFeatureSet::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); //PLERROR("WordNetFeatureSet::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 77 of file WordNetFeatureSet.h.
TVec<TVec<string> > PLearn::WordNetFeatureSet::anc_str [private] |
Definition at line 108 of file WordNetFeatureSet.h.
Referenced by getNewFeaturesString().
TVec<string> PLearn::WordNetFeatureSet::f_str [private] |
Temporary computations vectors.
Reimplemented from PLearn::HashMapFeatureSet.
Definition at line 107 of file WordNetFeatureSet.h.
TVec<string> PLearn::WordNetFeatureSet::s_str [private] |
Definition at line 107 of file WordNetFeatureSet.h.
Referenced by getNewFeaturesString().
Indication that the input token should be stemmed.
Definition at line 63 of file WordNetFeatureSet.h.
Referenced by declareOptions(), and getNewFeaturesString().
TVec<string> PLearn::WordNetFeatureSet::stems [private] |
Definition at line 107 of file WordNetFeatureSet.h.
Referenced by getNewFeaturesString().
TVec<int> PLearn::WordNetFeatureSet::tagcnts [private] |
Definition at line 109 of file WordNetFeatureSet.h.
Referenced by getNewFeaturesString().
Indication that features should include information from the WordNet hierarchy, not just the token's possible senses.
Definition at line 66 of file WordNetFeatureSet.h.
Referenced by declareOptions(), and getNewFeaturesString().