summary refs log tree commit diff stats
path: root/generator/part.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/part.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/part.h')
-rw-r--r--generator/part.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/generator/part.h b/generator/part.h index b010f62..39ba1e7 100644 --- a/generator/part.h +++ b/generator/part.h
@@ -4,21 +4,16 @@
4#include <string> 4#include <string>
5#include <set> 5#include <set>
6#include "../lib/selrestr.h" 6#include "../lib/selrestr.h"
7#include "../lib/enums.h"
7 8
8namespace verbly { 9namespace verbly {
10
9 namespace generator { 11 namespace generator {
10 12
11 class part { 13 class part {
12 public: 14 public:
13 enum class type { 15
14 invalid = -1, 16 using type = part_type;
15 noun_phrase = 0,
16 verb = 1,
17 preposition = 2,
18 adjective = 3,
19 adverb = 4,
20 literal = 5
21 };
22 17
23 // Static factories 18 // Static factories
24 19
@@ -34,6 +29,10 @@ namespace verbly {
34 29
35 static part createLiteral(std::string value); 30 static part createLiteral(std::string value);
36 31
32 // Duplication
33
34 static part duplicate(const part& other);
35
37 // Copy and move constructors 36 // Copy and move constructors
38 37
39 part(const part& other); 38 part(const part& other);
@@ -54,6 +53,11 @@ namespace verbly {
54 53
55 // General accessors 54 // General accessors
56 55
56 int getId() const
57 {
58 return id_;
59 }
60
57 type getType() const 61 type getType() const
58 { 62 {
59 return type_; 63 return type_;
@@ -79,13 +83,19 @@ namespace verbly {
79 83
80 private: 84 private:
81 85
86 static int nextId_;
87
88 int id_;
89
82 // Private constructors 90 // Private constructors
83 91
84 part() 92 part()
85 { 93 {
86 } 94 }
87 95
88 part(type t) : type_(t) 96 part(type t) :
97 id_(nextId_++),
98 type_(t)
89 { 99 {
90 } 100 }
91 101