summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--generator/frame.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/generator/frame.cpp b/generator/frame.cpp index 9f0653f..f75e3ba 100644 --- a/generator/frame.cpp +++ b/generator/frame.cpp
@@ -4,29 +4,29 @@
4 4
5namespace verbly { 5namespace verbly {
6 namespace generator { 6 namespace generator {
7 7
8 int frame::nextId_ = 0; 8 int frame::nextId_ = 0;
9 9
10 frame::frame() : id_(nextId_++) 10 frame::frame() : id_(nextId_++)
11 { 11 {
12 } 12 }
13 13
14 void frame::push_back(part fp) 14 void frame::push_back(part fp)
15 { 15 {
16 parts_.push_back(std::move(fp)); 16 parts_.push_back(std::move(fp));
17 } 17 }
18 18
19 database& operator<<(database& db, const frame& arg) 19 database& operator<<(database& db, const frame& arg)
20 { 20 {
21 std::list<field> fields; 21 std::list<field> fields;
22 fields.emplace_back("frame_id", arg.getId()); 22 fields.emplace_back("frame_id", arg.getId());
23 23
24 nlohmann::json jsonParts; 24 nlohmann::json jsonParts;
25 for (const part& p : arg) 25 for (const part& p : arg)
26 { 26 {
27 nlohmann::json jsonPart; 27 nlohmann::json jsonPart;
28 jsonPart["type"] = static_cast<int>(p.getType()); 28 jsonPart["type"] = static_cast<int>(p.getType());
29 29
30 switch (p.getType()) 30 switch (p.getType())
31 { 31 {
32 case part::type::noun_phrase: 32 case part::type::noun_phrase:
@@ -34,50 +34,50 @@ namespace verbly {
34 jsonPart["role"] = p.getNounRole(); 34 jsonPart["role"] = p.getNounRole();
35 jsonPart["selrestrs"] = p.getNounSelrestrs().toJson(); 35 jsonPart["selrestrs"] = p.getNounSelrestrs().toJson();
36 jsonPart["synrestrs"] = p.getNounSynrestrs(); 36 jsonPart["synrestrs"] = p.getNounSynrestrs();
37 37
38 break; 38 break;
39 } 39 }
40 40
41 case part::type::preposition: 41 case part::type::preposition:
42 { 42 {
43 jsonPart["choices"] = p.getPrepositionChoices(); 43 jsonPart["choices"] = p.getPrepositionChoices();
44 jsonPart["literal"] = p.isPrepositionLiteral(); 44 jsonPart["literal"] = p.isPrepositionLiteral();
45 45
46 break; 46 break;
47 } 47 }
48 48
49 case part::type::literal: 49 case part::type::literal:
50 { 50 {
51 jsonPart["value"] = p.getLiteralValue(); 51 jsonPart["value"] = p.getLiteralValue();
52 52
53 break; 53 break;
54 } 54 }
55 55
56 case part::type::verb: 56 case part::type::verb:
57 case part::type::adjective: 57 case part::type::adjective:
58 case part::type::adverb: 58 case part::type::adverb:
59 { 59 {
60 break; 60 break;
61 } 61 }
62 62
63 case part::type::invalid: 63 case part::type::invalid:
64 { 64 {
65 // Invalid parts should not be serialized. 65 // Invalid parts should not be serialized.
66 assert(false); 66 assert(false);
67 67
68 break; 68 break;
69 } 69 }
70 } 70 }
71 71
72 jsonParts.emplace_back(std::move(jsonPart)); 72 jsonParts.push_back(std::move(jsonPart));
73 } 73 }
74 74
75 fields.emplace_back("data", jsonParts.dump()); 75 fields.emplace_back("data", jsonParts.dump());
76 76
77 db.insertIntoTable("frames", std::move(fields)); 77 db.insertIntoTable("frames", std::move(fields));
78 78
79 return db; 79 return db;
80 } 80 }
81 81
82 }; 82 };
83}; 83};