diff options
Diffstat (limited to 'generator/group.cpp')
| -rw-r--r-- | generator/group.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
| diff --git a/generator/group.cpp b/generator/group.cpp index aa28d42..5b23578 100644 --- a/generator/group.cpp +++ b/generator/group.cpp | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | #include "group.h" | 1 | #include "group.h" |
| 2 | #include <stdexcept> | 2 | #include <stdexcept> |
| 3 | #include <list> | 3 | #include <list> |
| 4 | #include <json.hpp> | ||
| 5 | #include "database.h" | 4 | #include "database.h" |
| 6 | #include "field.h" | 5 | #include "field.h" |
| 7 | #include "frame.h" | 6 | #include "frame.h" |
| 7 | #include "../lib/util.h" | ||
| 8 | 8 | ||
| 9 | namespace verbly { | 9 | namespace verbly { |
| 10 | namespace generator { | 10 | namespace generator { |
| @@ -83,16 +83,22 @@ namespace verbly { | |||
| 83 | { | 83 | { |
| 84 | fields.emplace_back("role", p.getNounRole()); | 84 | fields.emplace_back("role", p.getNounRole()); |
| 85 | 85 | ||
| 86 | selrestr partSelrestr; | 86 | // Short interlude to serialize the selrestrs |
| 87 | if (p.getNounSelrestrs().getType() != selrestr::type::empty) | 87 | std::set<std::string> partSelrestrs = p.getNounSelrestrs(); |
| 88 | if (partSelrestrs.empty() && arg.hasRole(p.getNounRole())) | ||
| 88 | { | 89 | { |
| 89 | partSelrestr = p.getNounSelrestrs(); | 90 | partSelrestrs = arg.getRole(p.getNounRole()).getSelrestrs(); |
| 90 | } else if (arg.hasRole(p.getNounRole())) | ||
| 91 | { | ||
| 92 | partSelrestr = arg.getRole(p.getNounRole()).getSelrestrs(); | ||
| 93 | } | 91 | } |
| 94 | 92 | ||
| 95 | fields.emplace_back("selrestrs", partSelrestr.toJson().dump()); | 93 | for (const std::string& s : partSelrestrs) |
| 94 | { | ||
| 95 | std::list<field> selrestrFields; | ||
| 96 | |||
| 97 | selrestrFields.emplace_back("part_id", p.getId()); | ||
| 98 | selrestrFields.emplace_back("selrestr", s); | ||
| 99 | |||
| 100 | db.insertIntoTable("selrestrs", std::move(selrestrFields)); | ||
| 101 | } | ||
| 96 | 102 | ||
| 97 | // Short interlude to serialize the synrestrs | 103 | // Short interlude to serialize the synrestrs |
| 98 | for (const std::string& s : p.getNounSynrestrs()) | 104 | for (const std::string& s : p.getNounSynrestrs()) |
| @@ -110,7 +116,10 @@ namespace verbly { | |||
| 110 | 116 | ||
| 111 | case part::type::preposition: | 117 | case part::type::preposition: |
| 112 | { | 118 | { |
| 113 | fields.emplace_back("prepositions", nlohmann::json(p.getPrepositionChoices()).dump()); | 119 | std::set<std::string> setChoices = p.getPrepositionChoices(); |
| 120 | std::string serializedChoices = implode(std::begin(setChoices), std::end(setChoices), ","); | ||
| 121 | |||
| 122 | fields.emplace_back("prepositions", std::move(serializedChoices)); | ||
| 114 | fields.emplace_back("preposition_literality", p.isPrepositionLiteral() ? 1 : 0); | 123 | fields.emplace_back("preposition_literality", p.isPrepositionLiteral() ? 1 : 0); |
| 115 | 124 | ||
| 116 | break; | 125 | break; |
