diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-24 23:16:07 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-24 23:16:07 -0400 |
| commit | eef5de613c75661e5d94baa086f6f2ddc26c7ed0 (patch) | |
| tree | 180230f6a245c5bca94d894273f5d2b93ded3f04 /lib/frame.h | |
| parent | d5ee4e39e5b5b3b8daa85cd972802195ad35e965 (diff) | |
| download | verbly-eef5de613c75661e5d94baa086f6f2ddc26c7ed0.tar.gz verbly-eef5de613c75661e5d94baa086f6f2ddc26c7ed0.tar.bz2 verbly-eef5de613c75661e5d94baa086f6f2ddc26c7ed0.zip | |
Added verb frames
In addition: - Added prepositions. - Rewrote a lot of the query interface. It now, for a lot of relationships, supports nested AND, OR, and NOT logic. - Rewrote the token class. It is now a union-like class instead of being polymorphic, which means smart pointers are no longer necessary. - Querying with regards to word derivation has been temporarily removed. - Sentinel values are now supported for all word types. - The VerbNet data retrieved from http://verbs.colorado.edu/~mpalmer/projects/verbnet/downloads.html was found to not be perfectly satisfactory in some regards, especially regarding adjective phrases. A patch file is now included in the repository describing the changes made to the VerbNet v3.2 download for the canonical verbly datafile.
Diffstat (limited to 'lib/frame.h')
| -rw-r--r-- | lib/frame.h | 118 |
1 files changed, 118 insertions, 0 deletions
| diff --git a/lib/frame.h b/lib/frame.h new file mode 100644 index 0000000..fa57e1b --- /dev/null +++ b/lib/frame.h | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | #ifndef FRAME_H_9A5D90FE | ||
| 2 | #define FRAME_H_9A5D90FE | ||
| 3 | |||
| 4 | namespace verbly { | ||
| 5 | |||
| 6 | class frame_query; | ||
| 7 | |||
| 8 | class frame { | ||
| 9 | public: | ||
| 10 | class selrestr { | ||
| 11 | public: | ||
| 12 | enum class type { | ||
| 13 | empty, | ||
| 14 | singleton, | ||
| 15 | group | ||
| 16 | }; | ||
| 17 | |||
| 18 | type get_type() const; | ||
| 19 | selrestr(const selrestr& other); | ||
| 20 | ~selrestr(); | ||
| 21 | selrestr& operator=(const selrestr& other); | ||
| 22 | |||
| 23 | // Empty | ||
| 24 | selrestr(); | ||
| 25 | |||
| 26 | // Singleton | ||
| 27 | selrestr(std::string restriction, bool pos); | ||
| 28 | std::string get_restriction() const; | ||
| 29 | bool get_pos() const; | ||
| 30 | |||
| 31 | // Group | ||
| 32 | selrestr(std::list<selrestr> children, bool orlogic); | ||
| 33 | std::list<selrestr> get_children() const; | ||
| 34 | std::list<selrestr>::const_iterator begin() const; | ||
| 35 | std::list<selrestr>::const_iterator end() const; | ||
| 36 | bool get_orlogic() const; | ||
| 37 | |||
| 38 | private: | ||
| 39 | union { | ||
| 40 | struct { | ||
| 41 | bool pos; | ||
| 42 | std::string restriction; | ||
| 43 | } _singleton; | ||
| 44 | struct { | ||
| 45 | std::list<selrestr> children; | ||
| 46 | bool orlogic; | ||
| 47 | } _group; | ||
| 48 | }; | ||
| 49 | type _type; | ||
| 50 | }; | ||
| 51 | |||
| 52 | class part { | ||
| 53 | public: | ||
| 54 | enum class type { | ||
| 55 | noun_phrase, | ||
| 56 | verb, | ||
| 57 | literal_preposition, | ||
| 58 | selection_preposition, | ||
| 59 | adjective, | ||
| 60 | adverb, | ||
| 61 | literal | ||
| 62 | }; | ||
| 63 | |||
| 64 | type get_type() const; | ||
| 65 | part(const part& other); | ||
| 66 | ~part(); | ||
| 67 | |||
| 68 | // Noun phrase | ||
| 69 | std::string get_role() const; | ||
| 70 | selrestr get_selrestrs() const; | ||
| 71 | std::set<std::string> get_synrestrs() const; | ||
| 72 | |||
| 73 | // Literal preposition | ||
| 74 | std::vector<std::string> get_choices() const; | ||
| 75 | |||
| 76 | // Selection preposition | ||
| 77 | std::vector<std::string> get_preprestrs() const; | ||
| 78 | |||
| 79 | // Literal | ||
| 80 | std::string get_literal() const; | ||
| 81 | |||
| 82 | private: | ||
| 83 | friend class frame_query; | ||
| 84 | |||
| 85 | part(); | ||
| 86 | |||
| 87 | union { | ||
| 88 | struct { | ||
| 89 | std::string role; | ||
| 90 | selrestr selrestrs; | ||
| 91 | std::set<std::string> synrestrs; | ||
| 92 | } _noun_phrase; | ||
| 93 | struct { | ||
| 94 | std::vector<std::string> choices; | ||
| 95 | } _literal_preposition; | ||
| 96 | struct { | ||
| 97 | std::vector<std::string> preprestrs; | ||
| 98 | } _selection_preposition; | ||
| 99 | struct { | ||
| 100 | std::string lexval; | ||
| 101 | } _literal; | ||
| 102 | }; | ||
| 103 | type _type; | ||
| 104 | }; | ||
| 105 | |||
| 106 | std::vector<part> parts() const; | ||
| 107 | std::map<std::string, selrestr> roles() const; | ||
| 108 | |||
| 109 | private: | ||
| 110 | friend class frame_query; | ||
| 111 | |||
| 112 | std::vector<part> _parts; | ||
| 113 | std::map<std::string, selrestr> _roles; | ||
| 114 | }; | ||
| 115 | |||
| 116 | }; | ||
| 117 | |||
| 118 | #endif /* end of include guard: FRAME_H_9A5D90FE */ | ||
