From 063dd6c583b2348f3ceda45ef0fbf69538038560 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 10 Feb 2017 11:50:05 -0500 Subject: Updated verbly (bugfix) --- fruity.cpp | 27 ++++++++++++--------------- vendor/verbly | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/fruity.cpp b/fruity.cpp index a189d7c..80a6f6d 100644 --- a/fruity.cpp +++ b/fruity.cpp @@ -54,17 +54,15 @@ int main(int argc, char** argv) verbly::word fruit = fruitQuery.first(); verbly::word hyper = database.words(verbly::notion::hyponyms %= fruit).first(); - std::list tokens; + verbly::token utterance; int choice = std::uniform_int_distribution(0,2)(random_engine); if (choice == 0) { - verbly::word descriptor = pertainymQuery.first(); - tokens.push_back(descriptor.getBaseForm()); + utterance << pertainymQuery.first(); } else if (choice == 1) { - verbly::word descriptor = antiMannernymQuery.first(); - tokens.push_back(descriptor.getBaseForm()); + utterance << antiMannernymQuery.first(); } verbly::filter thingFilter = ( @@ -89,37 +87,36 @@ int main(int argc, char** argv) thingFilter &= (verbly::notion::fullHypernyms %= (verbly::notion::wnid == 100015388)); } - verbly::word thing = database.words(thingFilter).first(); - tokens.push_back(thing.getBaseForm()); + utterance << database.words(thingFilter).first(); } verbly::query similarQuery = database.words( (verbly::notion::partOfSpeech == verbly::part_of_speech::noun) && (verbly::notion::fullHypernyms %= hyper) - && (verbly::form::text != fruit.getBaseForm()) - && (verbly::word::id != hyper.getId()) + && !fruit.getBaseForm() + && !hyper && (verbly::form::proper == false) && (verbly::form::complexity == 1)); std::vector similarResults = similarQuery.all(); if (!similarResults.empty()) { - tokens.push_back(similarResults.front().getBaseForm()); + utterance << similarResults.front(); } else { verbly::query differentQuery = database.words( fruitFilter - && (verbly::form::text != fruit.getBaseForm()) - && (verbly::word::id != hyper.getId()) + && !fruit.getBaseForm() + && !hyper && (verbly::form::proper == false) && (verbly::form::complexity == 1)); - tokens.push_back(differentQuery.first().getBaseForm()); + utterance << differentQuery.first(); } - std::string fruitName = verbly::implode(std::begin(tokens), std::end(tokens), " "); + std::string fruitName = utterance.compile(); std::ostringstream result; - result << fruit.getBaseForm(); + result << fruit.getBaseForm().getText(); result << "? "; choice = std::uniform_int_distribution(0,3)(random_engine); diff --git a/vendor/verbly b/vendor/verbly index 6cc23ba..f625e90 160000 --- a/vendor/verbly +++ b/vendor/verbly @@ -1 +1 @@ -Subproject commit 6cc23ba387d0813b801ba094709673a61bac889c +Subproject commit f625e90a0721483f7f44b94b9bb57cc9d59565e8 -- cgit 1.4.1