summary refs log tree commit diff stats
path: root/lib/part.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-01-23 11:49:51 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-01-23 11:49:51 -0500
commit9bd863c9002b525b7827f9158d9136143393be5c (patch)
tree6b210e9d55286c93a0f3ddd55d2b10d1efa88e99 /lib/part.h
parent9e36dbbe74fd9541f0431b7715d3f97895384d28 (diff)
downloadverbly-9bd863c9002b525b7827f9158d9136143393be5c.tar.gz
verbly-9bd863c9002b525b7827f9158d9136143393be5c.tar.bz2
verbly-9bd863c9002b525b7827f9158d9136143393be5c.zip
Added verb frame parsing
Diffstat (limited to 'lib/part.h')
-rw-r--r--lib/part.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/lib/part.h b/lib/part.h new file mode 100644 index 0000000..3a15638 --- /dev/null +++ b/lib/part.h
@@ -0,0 +1,117 @@
1#ifndef PART_H_C8F0661B
2#define PART_H_C8F0661B
3
4#include <string>
5#include <vector>
6#include <set>
7#include "selrestr.h"
8
9namespace verbly {
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::vector<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 // Default constructor
38
39 part()
40 {
41 }
42
43 // Copy and move constructors
44
45 part(const part& other);
46
47 part(part&& other);
48
49 // Assignment
50
51 part& operator=(part other);
52
53 // Swap
54
55 friend void swap(part& first, part& second);
56
57 // Destructor
58
59 ~part();
60
61 // General accessors
62
63 type getType() const
64 {
65 return type_;
66 }
67
68 // Noun phrase accessors
69
70 std::string getNounRole() const;
71
72 selrestr getNounSelrestrs() const;
73
74 std::set<std::string> getNounSynrestrs() const;
75
76 bool nounHasSynrestr(std::string synrestr) const;
77
78 // Preposition accessors
79
80 std::vector<std::string> getPrepositionChoices() const;
81
82 bool isPrepositionLiteral() const;
83
84 // Literal accessors
85
86 std::string getLiteralValue() const;
87
88 private:
89
90 // Private constructors
91
92 part(type t) : type_(t)
93 {
94 }
95
96 // Data
97
98 union {
99 struct {
100 std::string role;
101 selrestr selrestrs;
102 std::set<std::string> synrestrs;
103 } noun_phrase_;
104 struct {
105 std::vector<std::string> choices;
106 bool literal;
107 } preposition_;
108 std::string literal_;
109 };
110
111 type type_ = type::invalid;
112
113 };
114
115};
116
117#endif /* end of include guard: PART_H_C8F0661B */