From 9bd863c9002b525b7827f9158d9136143393be5c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 23 Jan 2017 11:49:51 -0500 Subject: Added verb frame parsing --- lib/part.h | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 lib/part.h (limited to 'lib/part.h') 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 @@ +#ifndef PART_H_C8F0661B +#define PART_H_C8F0661B + +#include +#include +#include +#include "selrestr.h" + +namespace verbly { + + class part { + public: + enum class type { + invalid = -1, + noun_phrase = 0, + verb = 1, + preposition = 2, + adjective = 3, + adverb = 4, + literal = 5 + }; + + // Static factories + + static part createNounPhrase(std::string role, selrestr selrestrs, std::set synrestrs); + + static part createVerb(); + + static part createPreposition(std::vector choices, bool literal); + + static part createAdjective(); + + static part createAdverb(); + + static part createLiteral(std::string value); + + // Default constructor + + part() + { + } + + // Copy and move constructors + + part(const part& other); + + part(part&& other); + + // Assignment + + part& operator=(part other); + + // Swap + + friend void swap(part& first, part& second); + + // Destructor + + ~part(); + + // General accessors + + type getType() const + { + return type_; + } + + // Noun phrase accessors + + std::string getNounRole() const; + + selrestr getNounSelrestrs() const; + + std::set getNounSynrestrs() const; + + bool nounHasSynrestr(std::string synrestr) const; + + // Preposition accessors + + std::vector getPrepositionChoices() const; + + bool isPrepositionLiteral() const; + + // Literal accessors + + std::string getLiteralValue() const; + + private: + + // Private constructors + + part(type t) : type_(t) + { + } + + // Data + + union { + struct { + std::string role; + selrestr selrestrs; + std::set synrestrs; + } noun_phrase_; + struct { + std::vector choices; + bool literal; + } preposition_; + std::string literal_; + }; + + type type_ = type::invalid; + + }; + +}; + +#endif /* end of include guard: PART_H_C8F0661B */ -- cgit 1.4.1