summary refs log tree commit diff stats
path: root/lib/form.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-01-16 18:02:50 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-01-16 18:02:50 -0500
commit6746da6edd7d9d50efe374eabbb79a3cac882d81 (patch)
treeff20917e08b08d36b9541c1371106596e7bec442 /lib/form.h
parent4af7e55733098ca42f75a4ffaca1b0f6bab4dd36 (diff)
downloadverbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.tar.gz
verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.tar.bz2
verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.zip
Started structural rewrite
The new object structure was designed to build on the existing WordNet
structure, while also adding in all of the data that we get from other sources.
More information about this can be found on the project wiki.

The generator has already been completely rewritten to generate a
datafile that uses the new structure. In addition, a number of indexes
are created, which does double the size of the datafile, but also allows
for much faster lookups. Finally, the new generator is written modularly
and is a lot more readable than the old one.

The verbly interface to the new object structure has mostly been
completed, but has not been tested fully. There is a completely new
search API which utilizes a lot of operator overloading; documentation
on how to use it should go up at some point.

Token processing and verb frames are currently unimplemented. Source for
these have been left in the repository for now.
Diffstat (limited to 'lib/form.h')
-rw-r--r--lib/form.h149
1 files changed, 149 insertions, 0 deletions
diff --git a/lib/form.h b/lib/form.h new file mode 100644 index 0000000..c6a1353 --- /dev/null +++ b/lib/form.h
@@ -0,0 +1,149 @@
1#ifndef FORM_H_3A6C962C
2#define FORM_H_3A6C962C
3
4#include <list>
5#include <vector>
6#include <string>
7#include <stdexcept>
8#include "field.h"
9#include "filter.h"
10
11struct sqlite3_stmt;
12
13namespace verbly {
14
15 class pronunciation;
16 class database;
17
18 class form {
19 public:
20
21 // Default constructor
22
23 form() = default;
24
25 // Construct from database
26
27 form(const database& db, sqlite3_stmt* row);
28
29 // Accessors
30
31 operator bool() const
32 {
33 return valid_;
34 }
35
36 int getId() const
37 {
38 if (!valid_)
39 {
40 throw std::domain_error("Bad access to uninitialized form");
41 }
42
43 return id_;
44 }
45
46 std::string getText() const
47 {
48 if (!valid_)
49 {
50 throw std::domain_error("Bad access to uninitialized form");
51 }
52
53 return text_;
54 }
55
56 int getComplexity() const
57 {
58 if (!valid_)
59 {
60 throw std::domain_error("Bad access to uninitialized form");
61 }
62
63 return complexity_;
64 }
65
66 bool isProper() const
67 {
68 if (!valid_)
69 {
70 throw std::domain_error("Bad access to uninitialized form");
71 }
72
73 return proper_;
74 }
75
76 const std::vector<pronunciation>& getPronunciations() const;
77
78 // Type info
79
80 static const object objectType;
81
82 static const std::list<std::string> select;
83
84 // Query fields
85
86 static const field id;
87 static const field text;
88 static const field complexity;
89 static const field proper;
90
91 operator filter() const
92 {
93 if (!valid_)
94 {
95 throw std::domain_error("Bad access to uninitialized form");
96 }
97
98 return (id == id_);
99 }
100
101 // Relationships to other objects
102
103 static const field pronunciation;
104
105 class inflection_field {
106 public:
107
108 inflection_field(inflection category) : category_(category)
109 {
110 }
111
112 const inflection getCategory() const
113 {
114 return category_;
115 }
116
117 private:
118
119 const inflection category_;
120 };
121
122 static const inflection_field lemma(inflection category)
123 {
124 return inflection_field(category);
125 }
126
127 friend filter operator%=(form::inflection_field check, filter joinCondition);
128
129 private:
130 bool valid_ = false;
131
132 int id_;
133 std::string text_;
134 int complexity_ ;
135 bool proper_;
136
137 const database* db_;
138
139 mutable bool initializedPronunciations_ = false;
140 mutable std::vector<class pronunciation> pronunciations_;
141
142 static const field lemmaJoin;
143 static const field inflectionCategory;
144
145 };
146
147};
148
149#endif /* end of include guard: FORM_H_3A6C962C */