summary refs log tree commit diff stats
path: root/lib/form.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-01-28 12:59:42 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-01-28 12:59:42 -0500
commita7645346293ed6a912c26d0c50b6f7943f1f3072 (patch)
treed4d144e03a5e2dfcebbad2692fa71e790719d8fd /lib/form.cpp
parent6ba8989bbbd497f949a3e8b17abed1d0bd048347 (diff)
downloadverbly-a7645346293ed6a912c26d0c50b6f7943f1f3072.tar.gz
verbly-a7645346293ed6a912c26d0c50b6f7943f1f3072.tar.bz2
verbly-a7645346293ed6a912c26d0c50b6f7943f1f3072.zip
Restructured verb frame schema to be more queryable
Groups are much less significant now, and they no longer have a database
table, nor are they considered a top level object anymore. Instead of
containing their own role data, that data is folded into the frames so
that it's easier to query; as a result, each group has its own copy of
the frames that it contains. Additionally, parts are considered top
level objects now, and you can query for frames based on attributes of
their indexed parts. Synrestrs are also contained in their own table
now, so that parts can be filtered against their synrestrs; they are
however not considered top level objects.

Created a new type of field, the "join where" or "condition join" field,
which is a normal join field that has a built in condition on a
specified field. This is used to allow creating multiple distinct join
fields from one object to another. This is required for the lemma::form
and frame::part joins, because filters for forms of separate inflections
should not be coalesced; similarly, filters on differently indexed frame
parts should not be coalesced.

Queries can now be ordered, ascending or descending, by a field, in
addition to randomly as before. This is necessary for accessing the
parts of a verb frame in the correct order, but may be useful to an end
user as well.

Fixed a bug with statement generation in that condition groups were not
being surrounded in parentheses, which made mixing OR groups and AND
groups generate inaccurate statements. This has been fixed;
additionally, parentheses are not placed around the top level condition,
and nested condition groups with the same logic type are coalesced, to
make query strings as easy to read as possible.

Also simplified the form::lemma field; it no longer conditions on the
inflection of the form like the lemma::form field does.

Also added a debug flag to statement::getQueryString that makes it
return a query string with all of the bindings filled in, for debug use
only.
Diffstat (limited to 'lib/form.cpp')
-rw-r--r--lib/form.cpp16
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/form.cpp b/lib/form.cpp index 5d4c343..4811f14 100644 --- a/lib/form.cpp +++ b/lib/form.cpp
@@ -16,11 +16,9 @@ namespace verbly {
16 const field form::complexity = field::integerField(object::form, "complexity"); 16 const field form::complexity = field::integerField(object::form, "complexity");
17 const field form::proper = field::booleanField(object::form, "proper"); 17 const field form::proper = field::booleanField(object::form, "proper");
18 18
19 const field form::lemma = field::joinField(object::form, "form_id", object::lemma);
19 const field form::pronunciation = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); 20 const field form::pronunciation = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id");
20 21
21 const field form::lemmaJoin = field::joinField(object::form, "form_id", object::lemma);
22 const field form::inflectionCategory = field::integerField("lemmas_forms", "category");
23
24 form::form(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true) 22 form::form(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true)
25 { 23 {
26 id_ = sqlite3_column_int(row, 0); 24 id_ = sqlite3_column_int(row, 0);
@@ -29,16 +27,6 @@ namespace verbly {
29 proper_ = (sqlite3_column_int(row, 3) == 1); 27 proper_ = (sqlite3_column_int(row, 3) == 1);
30 } 28 }
31 29
32 filter operator%=(form::inflection_field check, filter joinCondition)
33 {
34 return (form::lemmaJoin %= (joinCondition && (form::inflectionCategory == check.getCategory())));
35 }
36
37 form::inflection_field::operator filter() const
38 {
39 return (form::lemmaJoin %= (form::inflectionCategory == category_));
40 }
41
42 const std::vector<pronunciation>& form::getPronunciations() const 30 const std::vector<pronunciation>& form::getPronunciations() const
43 { 31 {
44 if (!valid_) 32 if (!valid_)
@@ -48,7 +36,7 @@ namespace verbly {
48 36
49 if (!initializedPronunciations_) 37 if (!initializedPronunciations_)
50 { 38 {
51 pronunciations_ = db_->pronunciations(pronunciation::form %= *this, false, -1).all(); 39 pronunciations_ = db_->pronunciations(pronunciation::form %= *this, verbly::pronunciation::id, -1).all();
52 initializedPronunciations_ = true; 40 initializedPronunciations_ = true;
53 } 41 }
54 42