From 040ee58fecdc9c478004bc2e554e1ae126ec4602 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 15 Apr 2016 17:24:44 -0400 Subject: Added support for ImageNet and fixed bug with query interface Datafile change: nouns now know how many images are associated with them on ImageNet, and also have their WordNet synset ID saved so that you can query for images of that noun via the ImageNet API. So far, verbly only exposes the ImageNet API URL, and doesn't actually interact with it itself. This may be changed in the future. The query interface had a huge issue in which multiple instances of the same condition would overwrite each other. This has been fixed. --- lib/data.cpp | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) (limited to 'lib/data.cpp') diff --git a/lib/data.cpp b/lib/data.cpp index 5a9397b..c14956f 100644 --- a/lib/data.cpp +++ b/lib/data.cpp @@ -57,4 +57,121 @@ namespace verbly { return preposition_query(*this); } + binding::type binding::get_type() const + { + return _type; + } + + binding::binding(const binding& other) + { + _type = other._type; + + switch (_type) + { + case type::integer: + { + _integer = other._integer; + + break; + } + + case type::string: + { + new(&_string) std::string(other._string); + + break; + } + } + } + + binding::~binding() + { + switch (_type) + { + case type::string: + { + using string_type = std::string; + _string.~string_type(); + + break; + } + } + } + + binding& binding::operator=(const binding& other) + { + this->~binding(); + + _type = other._type; + + switch (_type) + { + case type::integer: + { + _integer = other._integer; + + break; + } + + case type::string: + { + new(&_string) std::string(other._string); + + break; + } + } + + return *this; + } + + binding::binding(int _arg) + { + _type = type::integer; + _integer = _arg; + } + + int binding::get_integer() const + { + assert(_type == type::integer); + + return _integer; + } + + void binding::set_integer(int _arg) + { + *this = binding(_arg); + } + + binding& binding::operator=(int _arg) + { + *this = binding(_arg); + + return *this; + } + + binding::binding(std::string _arg) + { + _type = type::string; + new(&_string) std::string(_arg); + } + + std::string binding::get_string() const + { + assert(_type == type::string); + + return _string; + } + + void binding::set_string(std::string _arg) + { + *this = binding(_arg); + } + + binding& binding::operator=(std::string _arg) + { + *this = binding(_arg); + + return *this; + } + }; -- cgit 1.4.1