summary refs log tree commit diff stats
path: root/lib/word.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-02-06 20:58:37 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-02-06 20:58:37 -0500
commitf1f67e62cebb4144f0599196263cd93b41fa972e (patch)
tree5d0f8fceeec63f47fb85846f5568bcb36f4a975f /lib/word.h
parent6cc23ba387d0813b801ba094709673a61bac889c (diff)
downloadverbly-f1f67e62cebb4144f0599196263cd93b41fa972e.tar.gz
verbly-f1f67e62cebb4144f0599196263cd93b41fa972e.tar.bz2
verbly-f1f67e62cebb4144f0599196263cd93b41fa972e.zip
Made pronunciation::rhymes join dynamic
This involved adding a new type of filter; one that compares (currently
only equality and inequality) a field with another field located in an
enclosing join context.

In the process, it was discovered that simplifying the lemma::forms join
field earlier actually made some queries return inaccurate results
because the inflection of the form was being ignored and anything in the
lemma would be used because of the inner join. Because the existing
condition join did not allow for the condition field to be on the from
side of the join, two things were done: a condition version of
joinThrough was made, and lemma was finally eliminated as a top-level
object, replaced instead with a condition join between word and form
through lemmas_forms.

Queries are also now grouped by the first select field (assumed to be
the primary ID) of the top table, in order to eliminate duplicates
created by inner joins, so that there is a uniform distribution between
results for random queries.

Created a database index on pronunciations(rhyme) which decreases query
time for rhyming filters. The new database version is
backwards-compatible because no data or structure changed.
Diffstat (limited to 'lib/word.h')
-rw-r--r--lib/word.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/word.h b/lib/word.h index 864cee1..a16319d 100644 --- a/lib/word.h +++ b/lib/word.h
@@ -6,8 +6,8 @@
6#include "field.h" 6#include "field.h"
7#include "filter.h" 7#include "filter.h"
8#include "notion.h" 8#include "notion.h"
9#include "lemma.h"
10#include "frame.h" 9#include "frame.h"
10#include "form.h"
11 11
12struct sqlite3_stmt; 12struct sqlite3_stmt;
13 13
@@ -95,17 +95,17 @@ namespace verbly {
95 95
96 const notion& getNotion() const; 96 const notion& getNotion() const;
97 97
98 const lemma& getLemma() const;
99
100 bool hasFrames() const; 98 bool hasFrames() const;
101 99
102 const std::vector<frame>& getFrames() const; 100 const std::vector<frame>& getFrames() const;
103 101
104 // Convenience accessors 102 const form& getBaseForm() const;
103
104 bool hasInflection(inflection category) const;
105
106 const std::vector<form>& getInflections(inflection category) const;
105 107
106 std::string getBaseForm() const;
107 108
108 std::vector<std::string> getInflections(inflection infl) const;
109 109
110 // Type info 110 // Type info
111 111
@@ -127,9 +127,10 @@ namespace verbly {
127 // Relationships with other objects 127 // Relationships with other objects
128 128
129 static const field notions; 129 static const field notions;
130 static const field lemmas;
131 static const field frames; 130 static const field frames;
132 131
132 static field forms(inflection category);
133
133 // Relationships with self 134 // Relationships with self
134 135
135 static const field antonyms; 136 static const field antonyms;
@@ -154,6 +155,7 @@ namespace verbly {
154 155
155 private: 156 private:
156 157
158 void initializeForm(inflection category) const;
157 void initializeFrames() const; 159 void initializeFrames() const;
158 160
159 bool valid_ = false; 161 bool valid_ = false;
@@ -170,10 +172,9 @@ namespace verbly {
170 const database* db_; 172 const database* db_;
171 173
172 mutable notion notion_; 174 mutable notion notion_;
173 mutable lemma lemma_;
174
175 mutable bool initializedFrames_ = false; 175 mutable bool initializedFrames_ = false;
176 mutable std::vector<frame> frames_; 176 mutable std::vector<frame> frames_;
177 mutable std::map<inflection, std::vector<form>> forms_;
177 178
178 }; 179 };
179 180