summary refs log tree commit diff stats
path: root/lib/form.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/form.h')
-rw-r--r--lib/form.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/form.h b/lib/form.h index 39f53aa..fb6b733 100644 --- a/lib/form.h +++ b/lib/form.h
@@ -82,6 +82,31 @@ namespace verbly {
82 return length_; 82 return length_;
83 } 83 }
84 84
85 bool hasFrequency() const
86 {
87 if (!valid_)
88 {
89 throw std::domain_error("Bad access to uninitialized form");
90 }
91
92 return hasFreq_;
93 }
94
95 bool getFrequency() const
96 {
97 if (!valid_)
98 {
99 throw std::domain_error("Bad access to uninitialized form");
100 }
101
102 if (!hasFreq_)
103 {
104 throw std::domain_error("Form does not have a frequency");
105 }
106
107 return frequency_;
108 }
109
85 const std::vector<pronunciation>& getPronunciations() const 110 const std::vector<pronunciation>& getPronunciations() const
86 { 111 {
87 if (!valid_) 112 if (!valid_)
@@ -109,6 +134,7 @@ namespace verbly {
109 static const field complexity; 134 static const field complexity;
110 static const field proper; 135 static const field proper;
111 static const field length; 136 static const field length;
137 static const field frequency;
112 138
113 operator filter() const 139 operator filter() const
114 { 140 {
@@ -149,6 +175,8 @@ namespace verbly {
149 int complexity_; 175 int complexity_;
150 bool proper_; 176 bool proper_;
151 int length_; 177 int length_;
178 bool hasFreq_ = false;
179 int frequency_;
152 std::vector<pronunciation> pronunciations_; 180 std::vector<pronunciation> pronunciations_;
153 }; 181 };
154 182