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/noun.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/noun.cpp') diff --git a/lib/noun.cpp b/lib/noun.cpp index 71c9af0..d8b34c9 100644 --- a/lib/noun.cpp +++ b/lib/noun.cpp @@ -34,6 +34,13 @@ namespace verbly { return _plural; } + + int noun::wnid() const + { + assert(_valid == true); + + return _wnid; + } bool noun::has_plural_form() const { @@ -196,6 +203,16 @@ namespace verbly { return _data->adjectives().variant_of(*this); } + std::string noun::imagenet_url() const + { + std::stringstream url; + url << "http://www.image-net.org/api/text/imagenet.synset.geturls?wnid=n"; + url.width(8); + url.fill('0'); + url << (_wnid % 100000000); + return url.str(); + } + bool noun::operator<(const noun& other) const { return _id < other._id; -- cgit 1.4.1