summary refs log tree commit diff stats
path: root/generator/part.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 /generator/part.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 'generator/part.h')
-rw-r--r--generator/part.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/generator/part.h b/generator/part.h new file mode 100644 index 0000000..d044630 --- /dev/null +++ b/generator/part.h
@@ -0,0 +1,114 @@
1#ifndef PART_H_FB54F361
2#define PART_H_FB54F361
3
4#include <string>
5#include <set>
6#include "selrestr.h"
7
8namespace verbly {
9 namespace generator {
10
11 class part {
12 public:
13 enum class type {
14 invalid = -1,
15 noun_phrase = 0,
16 verb = 1,
17 preposition = 2,
18 adjective = 3,
19 adverb = 4,
20 literal = 5
21 };
22
23 // Static factories
24
25 static part createNounPhrase(std::string role, selrestr selrestrs, std::set<std::string> synrestrs);
26
27 static part createVerb();
28
29 static part createPreposition(std::set<std::string> choices, bool literal);
30
31 static part createAdjective();
32
33 static part createAdverb();
34
35 static part createLiteral(std::string value);
36
37 // Copy and move constructors
38
39 part(const part& other);
40
41 part(part&& other);
42
43 // Assignment
44
45 part& operator=(part other);
46
47 // Swap
48
49 friend void swap(part& first, part& second);
50
51 // Destructor
52
53 ~part();
54
55 // General accessors
56
57 type getType() const
58 {
59 return type_;
60 }
61
62 // Noun phrase accessors
63
64 std::string getNounRole() const;
65
66 selrestr getNounSelrestrs() const;
67
68 std::set<std::string> getNounSynrestrs() const;
69
70 // Preposition accessors
71
72 std::set<std::string> getPrepositionChoices() const;
73
74 bool isPrepositionLiteral() const;
75
76 // Literal accessors
77
78 std::string getLiteralValue() const;
79
80 private:
81
82 // Private constructors
83
84 part()
85 {
86 }
87
88 part(type t) : type_(t)
89 {
90 }
91
92 // Data
93
94 union {
95 struct {
96 std::string role;
97 selrestr selrestrs;
98 std::set<std::string> synrestrs;
99 } noun_phrase_;
100 struct {
101 std::set<std::string> choices;
102 bool literal;
103 } preposition_;
104 std::string literal_;
105 };
106
107 type type_ = type::invalid;
108
109 };
110
111 };
112};
113
114#endif /* end of include guard: PART_H_FB54F361 */