LingFeatures.h

Go to the documentation of this file.
00001 #ifndef _LINGUISTICDEFINITION_LINGFEATURES_H_
00002 #define _LINGUISTICDEFINITION_LINGFEATURES_H_
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <map>
00007 #include <set>
00008 #include <sstream>
00009 #include <iostream>
00010 
00011 #include "LingDef.h"
00012 
00013 //TODO: replace 'reference' with 'int value'/'string value'?
00014 //TODO: reference class?
00015 //TODO: "internal" references (for derivation information, for example)
00016 
00017 namespace LinguisticDefinition {
00018 
00054   class LingFeatures {
00055     friend class LingDef;
00056   public:
00057 
00063     LingFeatures(const LingDef::Pos &posDef);
00064 
00068     ~LingFeatures();
00069 
00074     LingFeatures(const LingDef &lingDef);
00075 
00079     class Exception {
00080     public:
00081 
00085       Exception(const std::string &);
00086 
00090       const std::string &getMessage() const;
00091 
00092     private:
00093       std::string d_message;
00094     };
00095 
00099     const LingDef *getLingDef() const;
00100 
00107     const LingDef::Pos *getPosDef() const;
00108 
00114     void setPosDef(const LingDef::Pos &);
00115 
00119     const std::string &getLemma() const;
00120 
00124     void setLemma(const std::string &);
00125 
00129     const std::string &getForm() const;
00130 
00134     void setForm(const std::string &);
00135 
00147     void set(const std::string &feature);
00148 
00152     void setNegative(const std::string &feature);
00153 
00159     void unset(const std::string &feature);
00160 
00166     bool has(const std::string &feature) const;
00167 
00171     bool hasNegative(const std::string &feature) const;
00172 
00176     bool isDefined(const std::string &feature) const;
00177 
00182     void set(const LingDef::Feature &);
00183 
00187     void setNegative(const LingDef::Feature &);
00188 
00193     void unset(const LingDef::Feature &);
00194 
00199     bool has(const LingDef::Feature &) const;
00200 
00205     bool hasNegative(const LingDef::Feature &) const;
00206 
00210     bool isDefined(const LingDef::Feature &) const;
00211 
00215     const LingFeatures &operator+=(const std::string &);
00216 
00220     const LingFeatures &operator+=(const LingDef::Feature &);
00221 
00225     const LingFeatures &operator-=(const std::string &);
00226 
00230     const LingFeatures &operator-=(const LingDef::Feature &);
00231 
00240     void setReference(const std::string &feature, int);
00241 
00250     int getReference(const std::string &feature) const;
00251 
00257     void getReferenceList(const std::string &feature,
00258                           std::vector<int> &) const;
00259 
00270     bool hasReference(const std::string &feature, int referenceValue) const;
00271 
00275     void setReference(const LingDef::Feature &, int);
00276 
00280     int getReference(const LingDef::Feature &) const;
00281 
00285     void getReferenceList(const LingDef::Feature &, std::vector<int> &) const;
00286 
00290     bool hasReference(const LingDef::Feature &, int) const;
00291 
00295     void setEnum(const std::string &enumFeature,
00296                  const std::string &valueFeature);
00297 
00301     void setEnum(const LingDef::Feature &enumFeature,
00302                  const LingDef::Feature &valueFeature);
00303 
00307     const LingDef::Feature *getEnumValue(const std::string &) const;
00308 
00312     const LingDef::Feature *getEnumValue(const LingDef::Feature &) const;
00313 
00317     void getEnumValues(const std::string &,
00318                        std::set<const LingDef::Feature *> &) const;
00319 
00323     void getEnumValues(const LingDef::Feature &,
00324                        std::set<const LingDef::Feature *> &) const;
00325 
00329     int hasEnumValue(const std::string &enumValueName) const;
00330 
00334     int hasEnumValue(const LingDef::Feature &enumValueFeature) const;
00335 
00359     bool covers(const LingFeatures &) const;
00360 
00378     void execute(const std::string &); //TODO: does this belong in this class?
00379 
00383     void setDefaults();
00384 
00388     void setDefaultForEnum(const LingDef::Feature &enumFeature);
00389 
00393     typedef std::set<const LingDef::Feature *> FeaturesList;
00394 
00398     typedef FeaturesList::const_iterator FeatureIterator;
00399 
00403     FeatureIterator featuresBegin() const;
00404 
00408     FeatureIterator featuresEnd() const;
00409 
00413     typedef std::multimap<const LingDef::Feature *,
00414                           const LingDef::Feature *> EnumMap;
00415 
00419     typedef std::multimap<const LingDef::Feature *, int> ReferenceMap;
00420 
00421   protected:
00422 
00426     LingFeatures();
00427 
00428   private:
00429 
00433     LingFeatures(const LingDef &, const std::string &expression);
00434 
00438     void setSub(const LingDef::Feature &);
00439 
00443     void unsetSub(const LingDef::Feature &);
00444 
00445   private:
00446     const LingDef *d_lingDef;
00447     const LingDef::Pos *d_posDef;
00448     FeaturesList d_features;
00449     FeaturesList d_negativeFeatures;
00450     EnumMap d_enums;
00451     ReferenceMap d_references;
00452 
00453     std::string d_lemma;
00454     std::string d_form;
00455   };
00456 
00457 }
00458 
00459 #endif //_LINGUISTICDEFINITION_LINGFEATURES_H_

Generated on Fri Jun 23 14:03:14 2006 for LinguisticDefinition by  doxygen 1.4.7