ULAPI  8.0
ulinflectionrule.h
1 
7 #ifndef ULINFLECTIONRULE_H
8 #define ULINFLECTIONRULE_H
9 
10 #include "ulstring.h"
11 #include "ulfeature.h"
12 #include "ulpartofspeech.h"
13 #include "ulinflectionruletransform.h"
14 
15 class ULDerivation;
16 
24 {
26 
27 public:
29  ULInflectionRule(const ULInflectionRule& other);
31 
33  bool operator==(const ULInflectionRule& other) const;
34  bool operator!=(const ULInflectionRule& other) const;
35  void clear();
36 
37  uluint32 getGroup() const;
38  void setGroup(uluint32 newGroup);
39  uluint32 getPriority() const;
40  void setPriority(uluint32 newPriority);
41  bool isLookupRequired() const;
42  void setLookupRequired(bool required);
43  bool isInitial() const;
44  void setInitial(bool newIsInitial);
45  bool isTerminal() const;
46  void setTerminal(bool newIsTerminal);
47 
48  void addConstraint(const ULFeatureType& featureType, int value);
49  void addConstraint(const ULFeature& constraint);
50  void addStringConstraint(const ULFeatureType& featureType, const ULString& stringValue);
51  bool hasConstraint(const ULFeatureType& featureType) const;
52  bool getFeature(const ULFeatureType& featureType, ULFeature& constraint) const;
53  const ULList<ULFeature>& getConstraintList() const;
54 
55  const ULString& getSourceAffix() const;
56  void setSourceAffix(const ULString& newAffix);
57  const ULString& getTargetAffix() const;
58  void setTargetAffix(const ULString& newAffix);
60  void setSourcePartOfSpeech(const ULPartOfSpeech& newPartOfSpeech);
62  void setTargetPartOfSpeech(const ULPartOfSpeech& newPartOfSpeech);
63 
66 
67  bool isFullWordRule() const;
68  bool constraintsMatchForInflection(const ULDerivation& derivation) const;
69  bool affixesMatchForInflection(const ULDerivation& derivation) const;
70  bool affixesMatchForDissection(const ULDerivation& derivation) const;
71  bool partsOfSpeechMatchForDissection(const ULDerivation& derivation) const;
72  bool partsOfSpeechMatchForInflection(const ULDerivation& derivation) const;
73 
74  bool applyForInflection(ULDerivation& derivation) const;
75  bool applyForDissection(ULDerivation& derivation) const;
76 
77  ULString toString() const;
78 
79  static bool satisfies(const ULPartOfSpeech& posp, const ULPartOfSpeech& desiredPOSP);
80  static bool affixMatches(const ULString& affix, const ULString& s, const ULLanguage& language, bool ignoreCase=false, bool ignoreAccents=false);
81  static void removeAffix(const ULString& affix, ULString& s);
82  static bool applyAffix(const ULString& affix, const ULLanguage& language, ULString& s);
83 
84 private:
85  uluint32 group;
86  uluint32 priority;
87  bool lookupRequired;
88  bool initial;
89  bool terminal;
90  ULList<ULFeature> constraints;
92  ULString sourceAffix;
93  ULPartOfSpeech sourcePartOfSpeech;
94  ULString targetAffix;
95  ULPartOfSpeech targetPartOfSpeech;
96  ULList<uluint32> successorOffsets;
97  ULList<uluint32> predecessorOffsets;
98 
99  static bool charMatchesEscape(ulchar ch, ulchar escape, const ULLanguage& language);
100  bool applyTransformForInflection(const ULInflectionRuleTransform& transform, ULString& root, ULString& affix) const;
101  bool applyTransformForDissection(const ULInflectionRuleTransform& transform, ULString& root, ULString& affix) const;
102 
103  enum {
104  VerbClassPrefix = 253,
105  VerbClassReflexive = 252,
106  VerbClassToBe = 1,
107 
108  CyrillicSmallBe = 0x0431,
109  CyrillicSmallVe = 0x0432,
110  CyrillicSmallDe = 0x0434,
111  CyrillicSmallIe = 0x0435,
112  CyrillicSmallZhe = 0x0436,
113  CyrillicSmallZe = 0x0437,
114  CyrillicSmallI = 0x0438,
115  CyrillicSmallShortI = 0x0439,
116  CyrillicSmallEl = 0x043B,
117  CyrillicSmallEm = 0x043C,
118  CyrillicSmallPe = 0x043F,
119  CyrillicSmallEr = 0x0440,
120  CyrillicSmallEs = 0x0441,
121  CyrillicSmallTe = 0x0442,
122  CyrillicSmallU = 0x0443,
123  CyrillicSmallChe = 0x0447,
124  CyrillicSmallSha = 0x0448,
125  CyrillicSmallShcha = 0x0449,
126  CyrillicSmallSoftSign = 0x044C,
127  CyrillicSmallYu = 0x044E,
128  CyrillicSmallIo = 0x0451,
129  };
130 
131 };
132 
133 #endif
134