From 6746da6edd7d9d50efe374eabbb79a3cac882d81 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 16 Jan 2017 18:02:50 -0500 Subject: 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. --- generator/notion.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 generator/notion.h (limited to 'generator/notion.h') diff --git a/generator/notion.h b/generator/notion.h new file mode 100644 index 0000000..76210de --- /dev/null +++ b/generator/notion.h @@ -0,0 +1,91 @@ +#ifndef NOTION_H_221DE2BC +#define NOTION_H_221DE2BC + +#include +#include +#include +#include "enums.h" + +namespace verbly { + namespace generator { + + class database; + + class notion { + public: + + // Constructors + + explicit notion(part_of_speech partOfSpeech); + + notion(part_of_speech partOfSpeech, int wnid); + + // Mutators + + void incrementNumOfImages(); + + void setPrepositionGroups(std::list groups); + + // Accessors + + int getId() const + { + return id_; + } + + part_of_speech getPartOfSpeech() const + { + return partOfSpeech_; + } + + bool hasWnid() const + { + return hasWnid_; + } + + int getWnid() const + { + // Calling code should always call hasWnid first. + assert(hasWnid_); + + return wnid_; + } + + int getNumOfImages() const + { + // Calling code should always call hasWnid and check that the notion is a noun first. + assert(hasWnid_ && (partOfSpeech_ == part_of_speech::noun)); + + return numOfImages_; + } + + std::list getPrepositionGroups() const + { + // Calling code should always check that the notion is a preposition first. + assert(partOfSpeech_ == part_of_speech::preposition); + + return prepositionGroups_; + } + + private: + + static int nextId_; + + const int id_; + const part_of_speech partOfSpeech_; + const int wnid_ = 0; + const bool hasWnid_ = false; + + int numOfImages_ = 0; + std::list prepositionGroups_; + + }; + + // Serializer + + database& operator<<(database& db, const notion& arg); + + }; +}; + +#endif /* end of include guard: NOTION_H_221DE2BC */ -- cgit 1.4.1