summary refs log tree commit diff stats
path: root/generator/part.cpp
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 /generator/part.cpp
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 'generator/part.cpp')
-rw-r--r--generator/part.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/generator/part.cpp b/generator/part.cpp index 07618a8..d3e6656 100644 --- a/generator/part.cpp +++ b/generator/part.cpp
@@ -6,12 +6,12 @@ namespace verbly {
6 6
7 int part::nextId_ = 0; 7 int part::nextId_ = 0;
8 8
9 part part::createNounPhrase(std::string role, selrestr selrestrs, std::set<std::string> synrestrs) 9 part part::createNounPhrase(std::string role, std::set<std::string> selrestrs, std::set<std::string> synrestrs)
10 { 10 {
11 part p(type::noun_phrase); 11 part p(type::noun_phrase);
12 12
13 new(&p.noun_phrase_.role) std::string(std::move(role)); 13 new(&p.noun_phrase_.role) std::string(std::move(role));
14 new(&p.noun_phrase_.selrestrs) selrestr(std::move(selrestrs)); 14 new(&p.noun_phrase_.selrestrs) std::set<std::string>(std::move(selrestrs));
15 new(&p.noun_phrase_.synrestrs) std::set<std::string>(std::move(synrestrs)); 15 new(&p.noun_phrase_.synrestrs) std::set<std::string>(std::move(synrestrs));
16 16
17 return p; 17 return p;
@@ -60,7 +60,7 @@ namespace verbly {
60 case type::noun_phrase: 60 case type::noun_phrase:
61 { 61 {
62 new(&result.noun_phrase_.role) std::string(other.noun_phrase_.role); 62 new(&result.noun_phrase_.role) std::string(other.noun_phrase_.role);
63 new(&result.noun_phrase_.selrestrs) selrestr(other.noun_phrase_.selrestrs); 63 new(&result.noun_phrase_.selrestrs) std::set<std::string>(other.noun_phrase_.selrestrs);
64 new(&result.noun_phrase_.synrestrs) std::set<std::string>(other.noun_phrase_.synrestrs); 64 new(&result.noun_phrase_.synrestrs) std::set<std::string>(other.noun_phrase_.synrestrs);
65 65
66 break; 66 break;
@@ -103,7 +103,7 @@ namespace verbly {
103 case type::noun_phrase: 103 case type::noun_phrase:
104 { 104 {
105 new(&noun_phrase_.role) std::string(other.noun_phrase_.role); 105 new(&noun_phrase_.role) std::string(other.noun_phrase_.role);
106 new(&noun_phrase_.selrestrs) selrestr(other.noun_phrase_.selrestrs); 106 new(&noun_phrase_.selrestrs) std::set<std::string>(other.noun_phrase_.selrestrs);
107 new(&noun_phrase_.synrestrs) std::set<std::string>(other.noun_phrase_.synrestrs); 107 new(&noun_phrase_.synrestrs) std::set<std::string>(other.noun_phrase_.synrestrs);
108 108
109 break; 109 break;
@@ -153,7 +153,7 @@ namespace verbly {
153 type tempType = first.type_; 153 type tempType = first.type_;
154 int tempId = first.id_; 154 int tempId = first.id_;
155 std::string tempRole; 155 std::string tempRole;
156 selrestr tempSelrestrs; 156 std::set<std::string> tempSelrestrs;
157 std::set<std::string> tempSynrestrs; 157 std::set<std::string> tempSynrestrs;
158 std::set<std::string> tempChoices; 158 std::set<std::string> tempChoices;
159 bool tempPrepLiteral; 159 bool tempPrepLiteral;
@@ -204,7 +204,7 @@ namespace verbly {
204 case type::noun_phrase: 204 case type::noun_phrase:
205 { 205 {
206 new(&first.noun_phrase_.role) std::string(std::move(second.noun_phrase_.role)); 206 new(&first.noun_phrase_.role) std::string(std::move(second.noun_phrase_.role));
207 new(&first.noun_phrase_.selrestrs) selrestr(std::move(second.noun_phrase_.selrestrs)); 207 new(&first.noun_phrase_.selrestrs) std::set<std::string>(std::move(second.noun_phrase_.selrestrs));
208 new(&first.noun_phrase_.synrestrs) std::set<std::string>(std::move(second.noun_phrase_.synrestrs)); 208 new(&first.noun_phrase_.synrestrs) std::set<std::string>(std::move(second.noun_phrase_.synrestrs));
209 209
210 break; 210 break;
@@ -244,7 +244,7 @@ namespace verbly {
244 case type::noun_phrase: 244 case type::noun_phrase:
245 { 245 {
246 new(&second.noun_phrase_.role) std::string(std::move(tempRole)); 246 new(&second.noun_phrase_.role) std::string(std::move(tempRole));
247 new(&second.noun_phrase_.selrestrs) selrestr(std::move(tempSelrestrs)); 247 new(&second.noun_phrase_.selrestrs) std::set<std::string>(std::move(tempSelrestrs));
248 new(&second.noun_phrase_.synrestrs) std::set<std::string>(std::move(tempSynrestrs)); 248 new(&second.noun_phrase_.synrestrs) std::set<std::string>(std::move(tempSynrestrs));
249 249
250 break; 250 break;
@@ -285,7 +285,7 @@ namespace verbly {
285 using set_type = std::set<std::string>; 285 using set_type = std::set<std::string>;
286 286
287 noun_phrase_.role.~string_type(); 287 noun_phrase_.role.~string_type();
288 noun_phrase_.selrestrs.~selrestr(); 288 noun_phrase_.selrestrs.~set_type();
289 noun_phrase_.synrestrs.~set_type(); 289 noun_phrase_.synrestrs.~set_type();
290 290
291 break; 291 break;
@@ -329,7 +329,7 @@ namespace verbly {
329 } 329 }
330 } 330 }
331 331
332 selrestr part::getNounSelrestrs() const 332 std::set<std::string> part::getNounSelrestrs() const
333 { 333 {
334 if (type_ == type::noun_phrase) 334 if (type_ == type::noun_phrase)
335 { 335 {