summary refs log tree commit diff stats
path: root/lib/filter.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/filter.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/filter.cpp')
-rw-r--r--lib/filter.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/filter.cpp b/lib/filter.cpp index ceb9327..ab46df2 100644 --- a/lib/filter.cpp +++ b/lib/filter.cpp
@@ -3,8 +3,8 @@
3#include <map> 3#include <map>
4#include "notion.h" 4#include "notion.h"
5#include "word.h" 5#include "word.h"
6#include "group.h"
7#include "frame.h" 6#include "frame.h"
7#include "part.h"
8#include "lemma.h" 8#include "lemma.h"
9#include "form.h" 9#include "form.h"
10#include "pronunciation.h" 10#include "pronunciation.h"
@@ -594,6 +594,7 @@ namespace verbly {
594 switch (joinOn.getType()) 594 switch (joinOn.getType())
595 { 595 {
596 case field::type::join: 596 case field::type::join:
597 case field::type::join_where:
597 case field::type::join_through: 598 case field::type::join_through:
598 { 599 {
599 switch (filterType) 600 switch (filterType)
@@ -1108,8 +1109,8 @@ namespace verbly {
1108 } 1109 }
1109 1110
1110 case object::word: 1111 case object::word:
1111 case object::group:
1112 case object::frame: 1112 case object::frame:
1113 case object::part:
1113 case object::lemma: 1114 case object::lemma:
1114 case object::form: 1115 case object::form:
1115 case object::pronunciation: 1116 case object::pronunciation:
@@ -1134,10 +1135,10 @@ namespace verbly {
1134 return *this; 1135 return *this;
1135 } 1136 }
1136 1137
1137 case object::group:
1138 case object::frame: 1138 case object::frame:
1139 case object::part:
1139 { 1140 {
1140 return (verbly::word::group %= *this); 1141 return (verbly::word::frame %= *this);
1141 } 1142 }
1142 1143
1143 case object::lemma: 1144 case object::lemma:
@@ -1148,12 +1149,12 @@ namespace verbly {
1148 } 1149 }
1149 } 1150 }
1150 1151
1151 case object::group: 1152 case object::frame:
1152 { 1153 {
1153 switch (singleton_.filterField.getObject()) 1154 switch (singleton_.filterField.getObject())
1154 { 1155 {
1155 case object::undefined: 1156 case object::undefined:
1156 case object::group: 1157 case object::frame:
1157 { 1158 {
1158 return *this; 1159 return *this;
1159 } 1160 }
@@ -1164,34 +1165,34 @@ namespace verbly {
1164 case object::form: 1165 case object::form:
1165 case object::pronunciation: 1166 case object::pronunciation:
1166 { 1167 {
1167 return (verbly::group::word %= *this); 1168 return (verbly::frame::word %= *this);
1168 } 1169 }
1169 1170
1170 case object::frame: 1171 case object::part:
1171 { 1172 {
1172 return (verbly::group::frame %= *this); 1173 return (verbly::frame::part() %= *this);
1173 } 1174 }
1174 } 1175 }
1175 } 1176 }
1176 1177
1177 case object::frame: 1178 case object::part:
1178 { 1179 {
1179 switch (singleton_.filterField.getObject()) 1180 switch (singleton_.filterField.getObject())
1180 { 1181 {
1181 case object::undefined: 1182 case object::undefined:
1182 case object::frame: 1183 case object::part:
1183 { 1184 {
1184 return *this; 1185 return *this;
1185 } 1186 }
1186 1187
1187 case object::notion: 1188 case object::notion:
1188 case object::word: 1189 case object::word:
1189 case object::group: 1190 case object::frame:
1190 case object::lemma: 1191 case object::lemma:
1191 case object::form: 1192 case object::form:
1192 case object::pronunciation: 1193 case object::pronunciation:
1193 { 1194 {
1194 return (verbly::frame::group %= *this); 1195 return (verbly::part::frame %= *this);
1195 } 1196 }
1196 } 1197 }
1197 } 1198 }
@@ -1202,8 +1203,8 @@ namespace verbly {
1202 { 1203 {
1203 case object::notion: 1204 case object::notion:
1204 case object::word: 1205 case object::word:
1205 case object::group:
1206 case object::frame: 1206 case object::frame:
1207 case object::part:
1207 { 1208 {
1208 return verbly::lemma::word %= *this; 1209 return verbly::lemma::word %= *this;
1209 } 1210 }
@@ -1228,11 +1229,11 @@ namespace verbly {
1228 { 1229 {
1229 case object::notion: 1230 case object::notion:
1230 case object::word: 1231 case object::word:
1231 case object::group:
1232 case object::frame: 1232 case object::frame:
1233 case object::part:
1233 case object::lemma: 1234 case object::lemma:
1234 { 1235 {
1235 return verbly::form::lemma(inflection::base) %= *this; 1236 return verbly::form::lemma %= *this;
1236 } 1237 }
1237 1238
1238 case object::undefined: 1239 case object::undefined:
@@ -1254,8 +1255,8 @@ namespace verbly {
1254 { 1255 {
1255 case object::notion: 1256 case object::notion:
1256 case object::word: 1257 case object::word:
1257 case object::group:
1258 case object::frame: 1258 case object::frame:
1259 case object::part:
1259 case object::lemma: 1260 case object::lemma:
1260 case object::form: 1261 case object::form:
1261 { 1262 {