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

FeatureSet with features from WordNet. More...

#include <WordNetFeatureSet.h>

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

List of all members.

Public Member Functions

 WordNetFeatureSet ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual WordNetFeatureSetdeepCopy (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 PPathdeclaringFile ()

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< inttagcnts

Detailed Description

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.


Member Typedef Documentation

Reimplemented from PLearn::HashMapFeatureSet.

Definition at line 57 of file WordNetFeatureSet.h.


Constructor & Destructor Documentation

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

Member Function Documentation

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.

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

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

Here is the call graph for this function:

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

{}

Here is the caller graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::HashMapFeatureSet.

Definition at line 77 of file WordNetFeatureSet.h.

Definition at line 108 of file WordNetFeatureSet.h.

Referenced by getNewFeaturesString().

Temporary computations vectors.

Reimplemented from PLearn::HashMapFeatureSet.

Definition at line 107 of file WordNetFeatureSet.h.

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

Definition at line 107 of file WordNetFeatureSet.h.

Referenced by getNewFeaturesString().

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


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