summary refs log tree commit diff stats
path: root/lib/form.cpp
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/form.cpp
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/form.cpp')
-rw-r--r--lib/form.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/form.cpp b/lib/form.cpp index 4548582..2f9509f 100644 --- a/lib/form.cpp +++ b/lib/form.cpp
@@ -17,9 +17,13 @@ namespace verbly {
17 const field form::complexity = field::integerField(object::form, "complexity"); 17 const field form::complexity = field::integerField(object::form, "complexity");
18 const field form::proper = field::booleanField(object::form, "proper"); 18 const field form::proper = field::booleanField(object::form, "proper");
19 19
20 const field form::lemmas = field::joinField(object::form, "form_id", object::lemma);
21 const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); 20 const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id");
22 21
22 field form::words(inflection category)
23 {
24 return field::joinThroughWhere(object::form, "form_id", object::word, "lemmas_forms", "lemma_id", "category", static_cast<int>(category));
25 }
26
23 form::form(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true) 27 form::form(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true)
24 { 28 {
25 id_ = sqlite3_column_int(row, 0); 29 id_ = sqlite3_column_int(row, 0);