summary refs log tree commit diff stats
path: root/generator/group.h
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 /generator/group.h
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 'generator/group.h')
-rw-r--r--generator/group.h30
1 files changed, 12 insertions, 18 deletions
diff --git a/generator/group.h b/generator/group.h index 83f40c2..5486fbe 100644 --- a/generator/group.h +++ b/generator/group.h
@@ -5,7 +5,7 @@
5#include <set> 5#include <set>
6#include <string> 6#include <string>
7#include <cassert> 7#include <cassert>
8#include "../lib/role.h" 8#include "role.h"
9 9
10namespace verbly { 10namespace verbly {
11 namespace generator { 11 namespace generator {
@@ -20,13 +20,13 @@ namespace verbly {
20 20
21 group(); 21 group();
22 22
23 // Mutators 23 explicit group(const group& parent);
24 24
25 void setParent(const group& parent); 25 // Mutators
26 26
27 void addRole(role r); 27 void addRole(role r);
28 28
29 void addFrame(const frame& f); 29 void addFrame(frame f);
30 30
31 // Accessors 31 // Accessors
32 32
@@ -35,24 +35,19 @@ namespace verbly {
35 return id_; 35 return id_;
36 } 36 }
37 37
38 bool hasParent() const 38 const std::set<std::string>& getRoles() const
39 {
40 return (parent_ != nullptr);
41 }
42
43 const group& getParent() const
44 { 39 {
45 // Calling code should always call hasParent first 40 return roleNames_;
46 assert(parent_ != nullptr);
47
48 return *parent_;
49 } 41 }
50 42
51 std::set<std::string> getRoles() const; 43 bool hasRole(std::string name) const;
52 44
53 const role& getRole(std::string name) const; 45 const role& getRole(std::string name) const;
54 46
55 std::set<const frame*> getFrames() const; 47 const std::list<frame>& getFrames() const
48 {
49 return frames_;
50 }
56 51
57 private: 52 private:
58 53
@@ -60,9 +55,8 @@ namespace verbly {
60 55
61 const int id_; 56 const int id_;
62 57
63 const group* parent_ = nullptr;
64 std::map<std::string, role> roles_; 58 std::map<std::string, role> roles_;
65 std::set<const frame*> frames_; 59 std::list<frame> frames_;
66 60
67 // Caches 61 // Caches
68 62