summary refs log tree commit diff stats
path: root/lib/pronunciation.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/pronunciation.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/pronunciation.h')
-rw-r--r--lib/pronunciation.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/pronunciation.h b/lib/pronunciation.h index e171fe8..1162360 100644 --- a/lib/pronunciation.h +++ b/lib/pronunciation.h
@@ -12,7 +12,6 @@ struct sqlite3_stmt;
12namespace verbly { 12namespace verbly {
13 13
14 class form; 14 class form;
15 class lemma;
16 class word; 15 class word;
17 class database; 16 class database;
18 17
@@ -131,14 +130,26 @@ namespace verbly {
131 return (id == id_); 130 return (id == id_);
132 } 131 }
133 132
134 static filter rhymesWith(const pronunciation& arg);
135 static filter rhymesWith(const class form& arg);
136 static filter rhymesWith(const lemma& arg);
137 static filter rhymesWith(const word& arg);
138
139 // Relationships to other objects 133 // Relationships to other objects
140 134
141 static const field forms; 135 static const field forms;
136
137 // Rhyming relationship
138
139 class rhymes_field {
140 public:
141
142 filter operator%=(filter joinCondition) const;
143
144 operator filter() const;
145
146 private:
147
148 static const field rhymeJoin;
149
150 };
151
152 static const rhymes_field rhymes;
142 153
143 private: 154 private:
144 bool valid_ = false; 155 bool valid_ = false;