LinguisticDefinition::LingDef Class Reference

Represents a definition of linguistic features. More...

#include <LingDef.h>

List of all members.

Public Types

typedef std::map< const Feature *,
Pos::FeatureList * > 
ConflictMap

Public Member Functions

 LingDef (const std::string &isoLanguageCode)
 ~LingDef ()
 LingDef (const LingDef &)
 Copy constructor.
LingDefoperator= (const LingDef &)
const std::string & getIsoLanguageCode () const
 Returns the ISO 639-1 code for the language for which this definition is intended.
TreecreateTree (const std::string &name)
 Creates a tree with a given name and adds it to the definition.
const TreegetTree (const std::string &name) const
 Returns the tree with a certain name in the definition.
PoscreatePos (const std::string &name)
 Creates a pos for this definition.
PoscreateVirtualPos ()
 Creates a virtual pos for this definition.
const PosgetPos (const std::string &id) const
 Returns a pos definition for this definition with a certain name.
void addConflict (const Feature &featureA, const Feature &featureB)
const Pos::FeatureListgetConflicts (const Feature &) const
 May be NULL.

Classes

class  Feature
 Represents a feature in the definition. More...
class  Pos
 Represents a part-of-speech (pos) in the definition. More...
class  Tree
 Defines a hierarchical property structure. More...


Detailed Description

Represents a definition of linguistic features.

These features can be of type

Boolean
A simple true or false
Enumeration
A grouping of boolean features, for which only one may be true
Reference
A feature that has an integer value
Virtual tree
A tree structure grouping of boolean features

With the definitions contained in a LingDef object, instances of LingFeatures objects are created.

Using the information contained in the definition, features can be referred to by simply using strings for their names.

The features are grouped by parts-of-speech (pos). Each pos in the definition class is represented by the class LingDef::Pos. In this class, the available features are represented by the class LingDef::Feature.

The scope of a feature name is the pos. The name of a boolean feature may for example not be reused in an enumeration in the same pos, or an inheriting pos. However, the feature 'active' may for example very well be an enumeration for verbs, and a boolean for nouns.

Example of how to set up the definition:


   LingDef::Pos &nounDef = lingDef.createPos("NOUN");
   {
     // Create enumeration 'number', with values 'singular' and 'plural'
     LingDef::Feature &numberDef =
       lingDef.createFeature("number",
                             LingDef::Feature::MISC,
                             LingDef::Feature::ENUM);

     LingDef::Feature &singularDef =
       numberDef.createEnumValueFeature("singular");

     LingDef::Feature &singularDef =
       numberDef.createEnumValueFeature("plural");
   }
 

Sub classes of LingDefFormatter may do this for you, using an external source of some sort.

Example of how to retrieve information in the definition:


   const LingDef::Pos *nounDef = lingDef.getPos("NOUN");
   const LingDef::Feature *pluralDef = nounDef->getFeature("plural");
 

This is however something that is mostly interesting for the class LingFeatures.

The poses allow inhertiance. For example, if we want a common super pos for both nouns and pronouns:


   // Create a virtual base pos
   LingDef::Pos &superNounDef = lingDef.createVirtualPos();

   // Create 'NOUN' as a sub pos
   LingDef::Pos &nounDef = superNounDef.createSubPos("NOUN");

   // Create 'PRON' as a sub pos
   LingDef::Pos &pronounDef = superNounDef.createSubPos("PRON");

   // Let both pronouns and nouns have the 'hello' boolean
   LingDef::Feature *pluralDef =
     superNounDef.createFeature("hello",
                                LingDef::Feature::MISC,
                                LingDef::Feature::BOOLEAN);
 

Definition at line 116 of file LingDef.h.


Member Typedef Documentation

typedef std::map<const Feature *, Pos::FeatureList *> LinguisticDefinition::LingDef::ConflictMap

Definition at line 680 of file LingDef.h.


Constructor & Destructor Documentation

LinguisticDefinition::LingDef::LingDef ( const std::string &  isoLanguageCode  ) 

Parameters:
isoLanguageCode The ISO 639-1 code for the language for which this definition is intended. It may be used during data collection to determine whether a certain piece of information should be taken into account given this language.

LingDef::~LingDef (  ) 

Definition at line 16 of file LingDef.cc.

LingDef::LingDef ( const LingDef  ) 

Copy constructor.

Note that features belonging to one LingDef object may not be used with LingFeatures objects that are created with another LingDef object.

Definition at line 36 of file LingDef.cc.

References d_conflicts, LinguisticDefinition::LingDef::Pos::d_featureDefs, LinguisticDefinition::LingDef::Pos::d_lingDef, d_posDefs, d_treeDefs, LinguisticDefinition::LingDef::Pos::getFeature(), and LinguisticDefinition::LingDef::Tree::getNode().


Member Function Documentation

void LingDef::addConflict ( const Feature featureA,
const Feature featureB 
)

Definition at line 442 of file LingDef.cc.

Referenced by LinguisticDefinition::LingDef::Feature::addConflict().

Pos& LinguisticDefinition::LingDef::createPos ( const std::string &  name  ) 

Creates a pos for this definition.

Referenced by createVirtualPos(), and main().

Tree& LinguisticDefinition::LingDef::createTree ( const std::string &  name  ) 

Creates a tree with a given name and adds it to the definition.

Referenced by main().

LingDef::Pos::Pos & LingDef::createVirtualPos (  ) 

Creates a virtual pos for this definition.

A virtual pos is a pos that is not directly referenceable by it name. It does not even have a name.

Definition at line 164 of file LingDef.cc.

References createPos().

Referenced by main().

const LingDef::Pos::FeatureList * LingDef::getConflicts ( const Feature  )  const

May be NULL.

Definition at line 476 of file LingDef.cc.

const string & LingDef::getIsoLanguageCode (  )  const

Returns the ISO 639-1 code for the language for which this definition is intended.

Definition at line 139 of file LingDef.cc.

const Pos* LinguisticDefinition::LingDef::getPos ( const std::string &  id  )  const

Returns a pos definition for this definition with a certain name.

If no pos of that name is available, NULL is returned.

Referenced by main(), LinguisticDefinition::XmlLingFeaturesFormatter::populateLingFeatures(), and testQuery().

const Tree* LinguisticDefinition::LingDef::getTree ( const std::string &  name  )  const

Returns the tree with a certain name in the definition.

If no tree exists with that name, NULL is returned.

LingDef & LingDef::operator= ( const LingDef  ) 

Definition at line 116 of file LingDef.cc.

References d_isoLanguageCode, and d_posDefs.


The documentation for this class was generated from the following files:
Generated on Fri Jun 23 14:03:15 2006 for LinguisticDefinition by  doxygen 1.4.7