#include <LingDef.h>
Public Types | |
typedef std::map< const Feature *, Pos::FeatureList * > | ConflictMap |
Public Member Functions | |
LingDef (const std::string &isoLanguageCode) | |
~LingDef () | |
LingDef (const LingDef &) | |
Copy constructor. | |
LingDef & | operator= (const LingDef &) |
const std::string & | getIsoLanguageCode () const |
Returns the ISO 639-1 code for the language for which this definition is intended. | |
Tree & | createTree (const std::string &name) |
Creates a tree with a given name and adds it to the definition. | |
const Tree * | getTree (const std::string &name) const |
Returns the tree with a certain name in the definition. | |
Pos & | createPos (const std::string &name) |
Creates a pos for this definition. | |
Pos & | createVirtualPos () |
Creates a virtual pos for this definition. | |
const Pos * | getPos (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::FeatureList * | getConflicts (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... |
These features can be of type
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.
typedef std::map<const Feature *, Pos::FeatureList *> LinguisticDefinition::LingDef::ConflictMap |
LinguisticDefinition::LingDef::LingDef | ( | const std::string & | isoLanguageCode | ) |
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().
Definition at line 442 of file LingDef.cc.
Referenced by LinguisticDefinition::LingDef::Feature::addConflict().
Pos& LinguisticDefinition::LingDef::createPos | ( | const std::string & | name | ) |
Tree& LinguisticDefinition::LingDef::createTree | ( | const std::string & | name | ) |
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 |
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.