summary refs log tree commit diff stats
path: root/generator
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-30 09:59:48 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-30 09:59:48 -0400
commit3554df2e34e63364eea3a7998e0dfb0e6be65ca4 (patch)
treee82ccb7eb257adde7d7df2b2295975ed81f137b5 /generator
parent84bae572d353b03ecb3498df83ba301a456b6c6f (diff)
downloadverbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.tar.gz
verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.tar.bz2
verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.zip
Started migrating to hkutil (does not build)
Diffstat (limited to 'generator')
-rw-r--r--generator/database.cpp173
-rw-r--r--generator/database.h73
-rw-r--r--generator/field.cpp193
-rw-r--r--generator/field.h76
-rw-r--r--generator/form.h1
-rw-r--r--generator/generator.cpp161
-rw-r--r--generator/generator.h2
-rw-r--r--generator/notion.cpp17
-rw-r--r--generator/notion.h2
9 files changed, 100 insertions, 598 deletions
diff --git a/generator/database.cpp b/generator/database.cpp deleted file mode 100644 index 188fa2a..0000000 --- a/generator/database.cpp +++ /dev/null
@@ -1,173 +0,0 @@
1#include "database.h"
2#include <sqlite3.h>
3#include <cassert>
4#include <fstream>
5#include <stdexcept>
6#include <cstdio>
7#include <sstream>
8#include "field.h"
9#include "../lib/util.h"
10
11namespace verbly {
12 namespace generator {
13
14 sqlite3_error::sqlite3_error(
15 const std::string& what,
16 const std::string& db_err) :
17 what_(what + " (" + db_err + ")"),
18 db_err_(db_err)
19 {
20 }
21
22 const char* sqlite3_error::what() const noexcept
23 {
24 return what_.c_str();
25 }
26
27 const char* sqlite3_error::db_err() const noexcept
28 {
29 return db_err_.c_str();
30 }
31
32 database::database(std::string path)
33 {
34 // If there is already a file at this path, overwrite it.
35 if (std::ifstream(path))
36 {
37 if (std::remove(path.c_str()))
38 {
39 throw std::logic_error("Could not overwrite file at path");
40 }
41 }
42
43 if (sqlite3_open_v2(path.c_str(), &ppdb_, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)
44 {
45 // We still have to free the resources allocated. In the event that
46 // allocation failed, ppdb will be null and sqlite3_close_v2 will just
47 // ignore it.
48 std::string errmsg(sqlite3_errmsg(ppdb_));
49 sqlite3_close_v2(ppdb_);
50
51 throw sqlite3_error("Could not create output datafile", errmsg);
52 }
53 }
54
55 database::database(database&& other) : database()
56 {
57 swap(*this, other);
58 }
59
60 database& database::operator=(database&& other)
61 {
62 swap(*this, other);
63
64 return *this;
65 }
66
67 void swap(database& first, database& second)
68 {
69 std::swap(first.ppdb_, second.ppdb_);
70 }
71
72 database::~database()
73 {
74 sqlite3_close_v2(ppdb_);
75 }
76
77 void database::runQuery(std::string query)
78 {
79 // This can only happen when doing bad things with move semantics.
80 assert(ppdb_ != nullptr);
81
82 sqlite3_stmt* ppstmt;
83
84 if (sqlite3_prepare_v2(ppdb_, query.c_str(), query.length(), &ppstmt, NULL) != SQLITE_OK)
85 {
86 throw sqlite3_error("Error writing to database", sqlite3_errmsg(ppdb_));
87 }
88
89 int result = sqlite3_step(ppstmt);
90 sqlite3_finalize(ppstmt);
91
92 if (result != SQLITE_DONE)
93 {
94 throw sqlite3_error("Error writing to database", sqlite3_errmsg(ppdb_));
95 }
96 }
97
98 void database::insertIntoTable(std::string table, std::list<field> fields)
99 {
100 // This can only happen when doing bad things with move semantics.
101 assert(ppdb_ != nullptr);
102
103 // This shouldn't happen.
104 assert(!fields.empty());
105
106 std::list<std::string> fieldNames;
107 std::list<std::string> qs;
108 for (field& f : fields)
109 {
110 fieldNames.push_back(f.getName());
111 qs.push_back("?");
112 }
113
114 std::ostringstream query;
115 query << "INSERT INTO ";
116 query << table;
117 query << " (";
118 query << implode(std::begin(fieldNames), std::end(fieldNames), ", ");
119 query << ") VALUES (";
120 query << implode(std::begin(qs), std::end(qs), ", ");
121 query << ")";
122
123 std::string query_str = query.str();
124
125 sqlite3_stmt* ppstmt;
126
127 if (sqlite3_prepare_v2(ppdb_, query_str.c_str(), query_str.length(), &ppstmt, NULL) != SQLITE_OK)
128 {
129 throw sqlite3_error("Error writing to database", sqlite3_errmsg(ppdb_));
130 }
131
132 int i = 1;
133 for (field& f : fields)
134 {
135 switch (f.getType())
136 {
137 case field::type::integer:
138 {
139 sqlite3_bind_int(ppstmt, i, f.getInteger());
140
141 break;
142 }
143
144 case field::type::string:
145 {
146 sqlite3_bind_text(ppstmt, i, f.getString().c_str(), f.getString().length(), SQLITE_TRANSIENT);
147
148 break;
149 }
150
151 case field::type::invalid:
152 {
153 // Fields can only be invalid when doing bad things with move semantics.
154 assert(false);
155
156 break;
157 }
158 }
159
160 i++;
161 }
162
163 int result = sqlite3_step(ppstmt);
164 sqlite3_finalize(ppstmt);
165
166 if (result != SQLITE_DONE)
167 {
168 throw sqlite3_error("Error writing to database", sqlite3_errmsg(ppdb_));
169 }
170 }
171
172 };
173};
diff --git a/generator/database.h b/generator/database.h deleted file mode 100644 index 7906304..0000000 --- a/generator/database.h +++ /dev/null
@@ -1,73 +0,0 @@
1#ifndef DATABASE_H_0B0A47D2
2#define DATABASE_H_0B0A47D2
3
4#include <string>
5#include <exception>
6#include <list>
7
8struct sqlite3;
9
10namespace verbly {
11 namespace generator {
12
13 class field;
14
15 class sqlite3_error : public std::exception {
16 public:
17
18 sqlite3_error(const std::string& what, const std::string& db_err);
19
20 const char* what() const noexcept override;
21 const char* db_err() const noexcept;
22
23 private:
24 std::string what_;
25 std::string db_err_;
26
27 };
28
29 class database {
30 public:
31
32 // Constructor
33
34 explicit database(std::string path);
35
36 // Disable copying
37
38 database(const database& other) = delete;
39 database& operator=(const database& other) = delete;
40
41 // Move constructor and move assignment
42
43 database(database&& other);
44 database& operator=(database&& other);
45
46 // Swap
47
48 friend void swap(database& first, database& second);
49
50 // Destructor
51
52 ~database();
53
54 // Actions
55
56 void runQuery(std::string query);
57
58 void insertIntoTable(std::string table, std::list<field> fields);
59
60 private:
61
62 database()
63 {
64 }
65
66 sqlite3* ppdb_ = nullptr;
67
68 };
69
70 };
71};
72
73#endif /* end of include guard: DATABASE_H_0B0A47D2 */
diff --git a/generator/field.cpp b/generator/field.cpp deleted file mode 100644 index 84b2f91..0000000 --- a/generator/field.cpp +++ /dev/null
@@ -1,193 +0,0 @@
1#include "field.h"
2#include <stdexcept>
3#include <utility>
4
5namespace verbly {
6 namespace generator {
7
8 field::field(const field& other)
9 {
10 type_ = other.type_;
11 name_ = other.name_;
12
13 switch (type_)
14 {
15 case type::integer:
16 {
17 integer_ = other.integer_;
18
19 break;
20 }
21
22 case type::string:
23 {
24 new(&string_) std::string(other.string_);
25
26 break;
27 }
28
29 case type::invalid:
30 {
31 break;
32 }
33 }
34 }
35
36 field::field(field&& other) : field()
37 {
38 swap(*this, other);
39 }
40
41 field& field::operator=(field other)
42 {
43 swap(*this, other);
44
45 return *this;
46 }
47
48 void swap(field& first, field& second)
49 {
50 using type = field::type;
51
52 type tempType = first.type_;
53 std::string tempName = std::move(first.name_);
54 int tempInteger;
55 std::string tempString;
56
57 switch (first.type_)
58 {
59 case type::integer:
60 {
61 tempInteger = first.integer_;
62
63 break;
64 }
65
66 case type::string:
67 {
68 tempString = std::move(tempString);
69
70 break;
71 }
72
73 case type::invalid:
74 {
75 break;
76 }
77 }
78
79 first.~field();
80
81 first.type_ = second.type_;
82 first.name_ = std::move(second.name_);
83
84 switch (second.type_)
85 {
86 case type::integer:
87 {
88 first.integer_ = second.integer_;
89
90 break;
91 }
92
93 case type::string:
94 {
95 new(&first.string_) std::string(std::move(second.string_));
96
97 break;
98 }
99
100 case type::invalid:
101 {
102 break;
103 }
104 }
105
106 second.~field();
107
108 second.type_ = tempType;
109 second.name_ = std::move(tempName);
110
111 switch (tempType)
112 {
113 case type::integer:
114 {
115 second.integer_ = tempInteger;
116
117 break;
118 }
119
120 case type::string:
121 {
122 new(&second.string_) std::string(std::move(tempString));
123
124 break;
125 }
126
127 case type::invalid:
128 {
129 break;
130 }
131 }
132 }
133
134 field::~field()
135 {
136 switch (type_)
137 {
138 case type::string:
139 {
140 using string_type = std::string;
141 string_.~string_type();
142
143 break;
144 }
145
146 case type::integer:
147 case type::invalid:
148 {
149 break;
150 }
151 }
152 }
153
154 field::field(
155 std::string name,
156 int arg) :
157 type_(type::integer),
158 name_(name),
159 integer_(arg)
160 {
161 }
162
163 int field::getInteger() const
164 {
165 if (type_ != type::integer)
166 {
167 throw std::domain_error("field::getInteger called on non-integer field");
168 }
169
170 return integer_;
171 }
172
173 field::field(
174 std::string name,
175 std::string arg) :
176 type_(type::string),
177 name_(name)
178 {
179 new(&string_) std::string(arg);
180 }
181
182 std::string field::getString() const
183 {
184 if (type_ != type::string)
185 {
186 throw std::domain_error("field::getString called on non-string field");
187 }
188
189 return string_;
190 }
191
192 };
193};
diff --git a/generator/field.h b/generator/field.h deleted file mode 100644 index aaca3fa..0000000 --- a/generator/field.h +++ /dev/null
@@ -1,76 +0,0 @@
1#ifndef BINDING_H_CAE0B18E
2#define BINDING_H_CAE0B18E
3
4#include <string>
5
6namespace verbly {
7 namespace generator {
8
9 class field {
10 public:
11 enum class type {
12 invalid,
13 integer,
14 string
15 };
16
17 // Copy and move constructors
18
19 field(const field& other);
20 field(field&& other);
21
22 // Assignment
23
24 field& operator=(field other);
25
26 // Swap
27
28 friend void swap(field& first, field& second);
29
30 // Destructor
31
32 ~field();
33
34 // Generic accessors
35
36 type getType() const
37 {
38 return type_;
39 }
40
41 std::string getName() const
42 {
43 return name_;
44 }
45
46 // Integer
47
48 field(std::string name, int arg);
49
50 int getInteger() const;
51
52 // String
53
54 field(std::string name, std::string arg);
55
56 std::string getString() const;
57
58 private:
59
60 field()
61 {
62 }
63
64 union {
65 int integer_;
66 std::string string_;
67 };
68
69 type type_ = type::invalid;
70 std::string name_;
71 };
72
73 };
74};
75
76#endif /* end of include guard: BINDING_H_CAE0B18E */
diff --git a/generator/form.h b/generator/form.h index 5a2de30..37fd3cc 100644 --- a/generator/form.h +++ b/generator/form.h
@@ -8,7 +8,6 @@ namespace verbly {
8 namespace generator { 8 namespace generator {
9 9
10 class pronunciation; 10 class pronunciation;
11 class database;
12 11
13 class form { 12 class form {
14 public: 13 public:
diff --git a/generator/generator.cpp b/generator/generator.cpp index d774bd9..e34ca69 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp
@@ -594,7 +594,12 @@ namespace verbly {
594 fields.emplace_back("major", DATABASE_MAJOR_VERSION); 594 fields.emplace_back("major", DATABASE_MAJOR_VERSION);
595 fields.emplace_back("minor", DATABASE_MINOR_VERSION); 595 fields.emplace_back("minor", DATABASE_MINOR_VERSION);
596 596
597 db_.insertIntoTable("version", std::move(fields)); 597 db_.insertIntoTable(
598 "version",
599 {
600 { "major", DATABASE_MAJOR_VERSION },
601 { "minor", DATABASE_MINOR_VERSION }
602 });
598 } 603 }
599 604
600 void generator::dumpObjects() 605 void generator::dumpObjects()
@@ -689,11 +694,12 @@ namespace verbly {
689 word& word1 = *wordByWnidAndWnum_.at(lookup1); 694 word& word1 = *wordByWnidAndWnum_.at(lookup1);
690 word& word2 = *wordByWnidAndWnum_.at(lookup2); 695 word& word2 = *wordByWnidAndWnum_.at(lookup2);
691 696
692 std::list<field> fields; 697 db_.insertIntoTable(
693 fields.emplace_back("antonym_1_id", word1.getId()); 698 "antonymy",
694 fields.emplace_back("antonym_2_id", word2.getId()); 699 {
695 700 { "antonym_1_id", word1.getId() },
696 db_.insertIntoTable("antonymy", std::move(fields)); 701 { "antonym_2_id", word2.getId() }
702 });
697 } 703 }
698 } 704 }
699 } 705 }
@@ -721,11 +727,12 @@ namespace verbly {
721 notion& notion1 = *notionByWnid_.at(lookup1); 727 notion& notion1 = *notionByWnid_.at(lookup1);
722 notion& notion2 = *notionByWnid_.at(lookup2); 728 notion& notion2 = *notionByWnid_.at(lookup2);
723 729
724 std::list<field> fields; 730 db_.insertIntoTable(
725 fields.emplace_back("noun_id", notion1.getId()); 731 "variation",
726 fields.emplace_back("adjective_id", notion2.getId()); 732 {
727 733 { "noun_id", notion1.getId() }
728 db_.insertIntoTable("variation", std::move(fields)); 734 { "adjective_id", notion2.getId() }
735 });
729 } 736 }
730 } 737 }
731 } 738 }
@@ -786,11 +793,12 @@ namespace verbly {
786 { 793 {
787 for (int word2 : rightJoin) 794 for (int word2 : rightJoin)
788 { 795 {
789 std::list<field> fields; 796 db_.insertIntoTable(
790 fields.emplace_back("term_id", word1); 797 table_name,
791 fields.emplace_back("domain_id", word2); 798 {
792 799 { "term_id", word1 },
793 db_.insertIntoTable(table_name, std::move(fields)); 800 { "domain_id", word2 }
801 });
794 } 802 }
795 } 803 }
796 } 804 }
@@ -819,11 +827,12 @@ namespace verbly {
819 notion& notion1 = *notionByWnid_.at(lookup1); 827 notion& notion1 = *notionByWnid_.at(lookup1);
820 notion& notion2 = *notionByWnid_.at(lookup2); 828 notion& notion2 = *notionByWnid_.at(lookup2);
821 829
822 std::list<field> fields; 830 db_.insertIntoTable(
823 fields.emplace_back("effect_id", notion1.getId()); 831 "causality",
824 fields.emplace_back("cause_id", notion2.getId()); 832 {
825 833 { "effect_id", notion1.getId() },
826 db_.insertIntoTable("causality", std::move(fields)); 834 { "cause_id", notion2.getId() }
835 });
827 } 836 }
828 } 837 }
829 } 838 }
@@ -851,11 +860,12 @@ namespace verbly {
851 notion& notion1 = *notionByWnid_.at(lookup1); 860 notion& notion1 = *notionByWnid_.at(lookup1);
852 notion& notion2 = *notionByWnid_.at(lookup2); 861 notion& notion2 = *notionByWnid_.at(lookup2);
853 862
854 std::list<field> fields; 863 db_.insertIntoTable(
855 fields.emplace_back("given_id", notion1.getId()); 864 "entailment",
856 fields.emplace_back("entailment_id", notion2.getId()); 865 {
857 866 { "given_id", notion1.getId() },
858 db_.insertIntoTable("entailment", std::move(fields)); 867 { "entailment_id", notion2.getId() }
868 });
859 } 869 }
860 } 870 }
861 } 871 }
@@ -883,11 +893,12 @@ namespace verbly {
883 notion& notion1 = *notionByWnid_.at(lookup1); 893 notion& notion1 = *notionByWnid_.at(lookup1);
884 notion& notion2 = *notionByWnid_.at(lookup2); 894 notion& notion2 = *notionByWnid_.at(lookup2);
885 895
886 std::list<field> fields; 896 db_.insertIntoTable(
887 fields.emplace_back("hyponym_id", notion1.getId()); 897 "hypernymy",
888 fields.emplace_back("hypernym_id", notion2.getId()); 898 {
889 899 { "hyponym_id", notion1.getId() },
890 db_.insertIntoTable("hypernymy", std::move(fields)); 900 { "hypernym_id", notion2.getId() }
901 });
891 } 902 }
892 } 903 }
893 } 904 }
@@ -915,11 +926,12 @@ namespace verbly {
915 notion& notion1 = *notionByWnid_.at(lookup1); 926 notion& notion1 = *notionByWnid_.at(lookup1);
916 notion& notion2 = *notionByWnid_.at(lookup2); 927 notion& notion2 = *notionByWnid_.at(lookup2);
917 928
918 std::list<field> fields; 929 db_.insertIntoTable(
919 fields.emplace_back("instance_id", notion1.getId()); 930 "instantiation",
920 fields.emplace_back("class_id", notion2.getId()); 931 {
921 932 { "instance_id", notion1.getId() },
922 db_.insertIntoTable("instantiation", std::move(fields)); 933 { "class_id", notion2.getId() }
934 });
923 } 935 }
924 } 936 }
925 } 937 }
@@ -947,11 +959,12 @@ namespace verbly {
947 notion& notion1 = *notionByWnid_.at(lookup1); 959 notion& notion1 = *notionByWnid_.at(lookup1);
948 notion& notion2 = *notionByWnid_.at(lookup2); 960 notion& notion2 = *notionByWnid_.at(lookup2);
949 961
950 std::list<field> fields; 962 db_.insertIntoTable(
951 fields.emplace_back("holonym_id", notion1.getId()); 963 "member_meronymy",
952 fields.emplace_back("meronym_id", notion2.getId()); 964 {
953 965 { "holonym_id", notion1.getId() },
954 db_.insertIntoTable("member_meronymy", std::move(fields)); 966 { "meronym_id", notion2.getId() }
967 });
955 } 968 }
956 } 969 }
957 } 970 }
@@ -979,11 +992,12 @@ namespace verbly {
979 notion& notion1 = *notionByWnid_.at(lookup1); 992 notion& notion1 = *notionByWnid_.at(lookup1);
980 notion& notion2 = *notionByWnid_.at(lookup2); 993 notion& notion2 = *notionByWnid_.at(lookup2);
981 994
982 std::list<field> fields; 995 db_.insertIntoTable(
983 fields.emplace_back("holonym_id", notion1.getId()); 996 "part_meronymy",
984 fields.emplace_back("meronym_id", notion2.getId()); 997 {
985 998 { "holonym_id", notion1.getId() },
986 db_.insertIntoTable("part_meronymy", std::move(fields)); 999 { "meronym_id", notion2.getId() }
1000 });
987 } 1001 }
988 } 1002 }
989 } 1003 }
@@ -1011,11 +1025,12 @@ namespace verbly {
1011 notion& notion1 = *notionByWnid_.at(lookup1); 1025 notion& notion1 = *notionByWnid_.at(lookup1);
1012 notion& notion2 = *notionByWnid_.at(lookup2); 1026 notion& notion2 = *notionByWnid_.at(lookup2);
1013 1027
1014 std::list<field> fields; 1028 db_.insertIntoTable(
1015 fields.emplace_back("holonym_id", notion1.getId()); 1029 "substance_meronymy",
1016 fields.emplace_back("meronym_id", notion2.getId()); 1030 {
1017 1031 { "holonym_id", notion1.getId() },
1018 db_.insertIntoTable("substance_meronymy", std::move(fields)); 1032 { "meronym_id", notion2.getId() }
1033 });
1019 } 1034 }
1020 } 1035 }
1021 } 1036 }
@@ -1045,18 +1060,20 @@ namespace verbly {
1045 1060
1046 if (word1.getNotion().getPartOfSpeech() == part_of_speech::adjective) 1061 if (word1.getNotion().getPartOfSpeech() == part_of_speech::adjective)
1047 { 1062 {
1048 std::list<field> fields; 1063 db_.insertIntoTable(
1049 fields.emplace_back("pertainym_id", word1.getId()); 1064 "pertainymy",
1050 fields.emplace_back("noun_id", word2.getId()); 1065 {
1051 1066 { "pertainym_id", word1.getId() },
1052 db_.insertIntoTable("pertainymy", std::move(fields)); 1067 { "noun_id", word2.getId() }
1068 });
1053 } else if (word1.getNotion().getPartOfSpeech() == part_of_speech::adverb) 1069 } else if (word1.getNotion().getPartOfSpeech() == part_of_speech::adverb)
1054 { 1070 {
1055 std::list<field> fields; 1071 db_.insertIntoTable(
1056 fields.emplace_back("mannernym_id", word1.getId()); 1072 "mannernymy",
1057 fields.emplace_back("adjective_id", word2.getId()); 1073 {
1058 1074 { "mannernym_id", word1.getId() },
1059 db_.insertIntoTable("mannernymy", std::move(fields)); 1075 { "adjective_id", word2.getId() }
1076 });
1060 } 1077 }
1061 } 1078 }
1062 } 1079 }
@@ -1085,11 +1102,12 @@ namespace verbly {
1085 word& word1 = *wordByWnidAndWnum_.at(lookup1); 1102 word& word1 = *wordByWnidAndWnum_.at(lookup1);
1086 word& word2 = *wordByWnidAndWnum_.at(lookup2); 1103 word& word2 = *wordByWnidAndWnum_.at(lookup2);
1087 1104
1088 std::list<field> fields; 1105 db_.insertIntoTable(
1089 fields.emplace_back("general_id", word1.getId()); 1106 "specification",
1090 fields.emplace_back("specific_id", word2.getId()); 1107 {
1091 1108 { "general_id", word1.getId() },
1092 db_.insertIntoTable("specification", std::move(fields)); 1109 { "specific_id", word2.getId() }
1110 });
1093 } 1111 }
1094 } 1112 }
1095 } 1113 }
@@ -1117,11 +1135,12 @@ namespace verbly {
1117 notion& notion1 = *notionByWnid_.at(lookup1); 1135 notion& notion1 = *notionByWnid_.at(lookup1);
1118 notion& notion2 = *notionByWnid_.at(lookup2); 1136 notion& notion2 = *notionByWnid_.at(lookup2);
1119 1137
1120 std::list<field> fields; 1138 db_.insertIntoTable(
1121 fields.emplace_back("adjective_1_id", notion1.getId()); 1139 "similarity",
1122 fields.emplace_back("adjective_2_id", notion2.getId()); 1140 {
1123 1141 { "adjective_1_id", notion1.getId() },
1124 db_.insertIntoTable("similarity", std::move(fields)); 1142 { "adjective_2_id", notion2.getId() }
1143 });
1125 } 1144 }
1126 } 1145 }
1127 } 1146 }
diff --git a/generator/generator.h b/generator/generator.h index 5458c97..52073bc 100644 --- a/generator/generator.h +++ b/generator/generator.h
@@ -120,7 +120,7 @@ namespace verbly {
120 120
121 // Output 121 // Output
122 122
123 database db_; 123 hatkirby::database db_;
124 124
125 // Data 125 // Data
126 126
diff --git a/generator/notion.cpp b/generator/notion.cpp index 1878ba9..35ba7b1 100644 --- a/generator/notion.cpp +++ b/generator/notion.cpp
@@ -46,10 +46,11 @@ namespace verbly {
46 { 46 {
47 // First, serialize the notion 47 // First, serialize the notion
48 { 48 {
49 std::list<field> fields; 49 std::list<hatkirby::column> fields;
50 50
51 fields.emplace_back("notion_id", arg.getId()); 51 fields.emplace_back("notion_id", arg.getId());
52 fields.emplace_back("part_of_speech", static_cast<int>(arg.getPartOfSpeech())); 52 fields.emplace_back("part_of_speech",
53 static_cast<int>(arg.getPartOfSpeech()));
53 54
54 if (arg.hasWnid()) 55 if (arg.hasWnid())
55 { 56 {
@@ -69,12 +70,12 @@ namespace verbly {
69 { 70 {
70 for (std::string group : arg.getPrepositionGroups()) 71 for (std::string group : arg.getPrepositionGroups())
71 { 72 {
72 std::list<field> fields; 73 db.insertIntoTable(
73 74 "is_a",
74 fields.emplace_back("notion_id", arg.getId()); 75 {
75 fields.emplace_back("groupname", group); 76 { "notion_id", arg.getId() },
76 77 { "groupname", group }
77 db.insertIntoTable("is_a", std::move(fields)); 78 });
78 } 79 }
79 } 80 }
80 81
diff --git a/generator/notion.h b/generator/notion.h index 6e38497..817e66a 100644 --- a/generator/notion.h +++ b/generator/notion.h
@@ -9,8 +9,6 @@
9namespace verbly { 9namespace verbly {
10 namespace generator { 10 namespace generator {
11 11
12 class database;
13
14 class notion { 12 class notion {
15 public: 13 public:
16 14