summary refs log tree commit diff stats
path: root/lib/selrestr.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-02-05 08:56:39 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-02-05 08:56:39 -0500
commite4fa0cb86d97c23c24cd7bdd62c23f03eed312da (patch)
tree70a20fdf684b1724659196a7de8d21a4a6ca194f /lib/selrestr.h
parentbea3673ae1b3d19585dec56e96dbcd8a56b96e6d (diff)
downloadverbly-e4fa0cb86d97c23c24cd7bdd62c23f03eed312da.tar.gz
verbly-e4fa0cb86d97c23c24cd7bdd62c23f03eed312da.tar.bz2
verbly-e4fa0cb86d97c23c24cd7bdd62c23f03eed312da.zip
Flattened selrestrs
Now, selrestrs are, instead of logically being a tree of
positive/negative restrictions that are ANDed/ORed together, they are a
flat set of positive restrictions that are ORed together. They are
stored as strings in a table called selrestrs, just like synrestrs,
which makes them a lot more queryable now as well. This change required
some changes to the VerbNet data, because we needed to consolidate any
ANDed clauses into single selrestrs, as well as convert any negative
selrestrs into positive ones. The changes made are detailed on the wiki.

Preposition choices are now encoded as comma-separated lists instead of
using JSON. This change, along with the selrestrs one, allows us to
remove verbly's dependency on nlohmann::json.
Diffstat (limited to 'lib/selrestr.h')
-rw-r--r--lib/selrestr.h90
1 files changed, 0 insertions, 90 deletions
diff --git a/lib/selrestr.h b/lib/selrestr.h deleted file mode 100644 index a7cde0a..0000000 --- a/lib/selrestr.h +++ /dev/null
@@ -1,90 +0,0 @@
1#ifndef SELRESTR_H_50652FB7
2#define SELRESTR_H_50652FB7
3
4#include <list>
5#include <string>
6#include "../vendor/json/json.hpp"
7
8namespace verbly {
9
10 class selrestr {
11 public:
12 enum class type {
13 empty,
14 singleton,
15 group
16 };
17
18 // Construct from json
19
20 explicit selrestr(nlohmann::json json);
21
22 // Copy and move constructors
23
24 selrestr(const selrestr& other);
25 selrestr(selrestr&& other);
26
27 // Assignment
28
29 selrestr& operator=(selrestr other);
30
31 // Swap
32
33 friend void swap(selrestr& first, selrestr& second);
34
35 // Destructor
36
37 ~selrestr();
38
39 // Generic accessors
40
41 type getType() const
42 {
43 return type_;
44 }
45
46 // Empty
47
48 selrestr();
49
50 // Singleton
51
52 selrestr(std::string restriction, bool pos);
53
54 std::string getRestriction() const;
55
56 bool getPos() const;
57
58 // Group
59
60 selrestr(std::list<selrestr> children, bool orlogic);
61
62 std::list<selrestr> getChildren() const;
63
64 std::list<selrestr>::const_iterator begin() const;
65
66 std::list<selrestr>::const_iterator end() const;
67
68 bool getOrlogic() const;
69
70 // Helpers
71
72 nlohmann::json toJson() const;
73
74 private:
75 union {
76 struct {
77 bool pos;
78 std::string restriction;
79 } singleton_;
80 struct {
81 std::list<selrestr> children;
82 bool orlogic;
83 } group_;
84 };
85 type type_;
86 };
87
88};
89
90#endif /* end of include guard: SELRESTR_H_50652FB7 */