summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/word.cpp20
-rw-r--r--lib/word.h12
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/word.cpp b/lib/word.cpp index e4de187..dc269c9 100644 --- a/lib/word.cpp +++ b/lib/word.cpp
@@ -38,6 +38,8 @@ namespace verbly {
38 const field word::regionalTerms = field::selfJoin(object::word, "word_id", "regionality", "domain_id", "term_id"); 38 const field word::regionalTerms = field::selfJoin(object::word, "word_id", "regionality", "domain_id", "term_id");
39 const field word::regionalDomains = field::selfJoin(object::word, "word_id", "regionality", "term_id", "domain_id"); 39 const field word::regionalDomains = field::selfJoin(object::word, "word_id", "regionality", "term_id", "domain_id");
40 40
41 const word::synonyms_field word::synonyms = {};
42
41 field word::forms(inflection category) 43 field word::forms(inflection category)
42 { 44 {
43 return field::joinThroughWhere(object::word, "lemma_id", object::form, "lemmas_forms", "form_id", "category", static_cast<int>(category)); 45 return field::joinThroughWhere(object::word, "lemma_id", object::form, "lemmas_forms", "form_id", "category", static_cast<int>(category));
@@ -168,4 +170,22 @@ namespace verbly {
168 forms_[infl] = db_->forms(form::words(infl) %= *this, verbly::form::id, -1).all(); 170 forms_[infl] = db_->forms(form::words(infl) %= *this, verbly::form::id, -1).all();
169 } 171 }
170 172
173 filter word::synonyms_field::operator%=(filter joinCondition) const
174 {
175 return (verbly::notion::words %= (
176 std::move(joinCondition)
177 && (filter(
178 verbly::word::id,
179 filter::comparison::field_does_not_equal,
180 verbly::word::id))));
181 }
182
183 word::synonyms_field::operator filter() const
184 {
185 return (verbly::notion::words %= filter(
186 verbly::word::id,
187 filter::comparison::field_does_not_equal,
188 verbly::word::id));
189 }
190
171}; 191};
diff --git a/lib/word.h b/lib/word.h index e866f09..8c8de51 100644 --- a/lib/word.h +++ b/lib/word.h
@@ -166,6 +166,18 @@ namespace verbly {
166 static const field regionalTerms; 166 static const field regionalTerms;
167 static const field regionalDomains; 167 static const field regionalDomains;
168 168
169 // Synonymy relationship
170
171 class synonyms_field {
172 public:
173
174 filter operator%=(filter joinCondition) const;
175
176 operator filter() const;
177 };
178
179 static const synonyms_field synonyms;
180
169 private: 181 private:
170 182
171 void initializeForm(inflection category) const; 183 void initializeForm(inflection category) const;