summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--fruity.cpp27
m---------vendor/verbly0
2 files changed, 12 insertions, 15 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)
54 verbly::word fruit = fruitQuery.first(); 54 verbly::word fruit = fruitQuery.first();
55 verbly::word hyper = database.words(verbly::notion::hyponyms %= fruit).first(); 55 verbly::word hyper = database.words(verbly::notion::hyponyms %= fruit).first();
56 56
57 std::list<std::string> tokens; 57 verbly::token utterance;
58 58
59 int choice = std::uniform_int_distribution<int>(0,2)(random_engine); 59 int choice = std::uniform_int_distribution<int>(0,2)(random_engine);
60 if (choice == 0) 60 if (choice == 0)
61 { 61 {
62 verbly::word descriptor = pertainymQuery.first(); 62 utterance << pertainymQuery.first();
63 tokens.push_back(descriptor.getBaseForm());
64 } else if (choice == 1) 63 } else if (choice == 1)
65 { 64 {
66 verbly::word descriptor = antiMannernymQuery.first(); 65 utterance << antiMannernymQuery.first();
67 tokens.push_back(descriptor.getBaseForm());
68 } 66 }
69 67
70 verbly::filter thingFilter = ( 68 verbly::filter thingFilter = (
@@ -89,37 +87,36 @@ int main(int argc, char** argv)
89 thingFilter &= (verbly::notion::fullHypernyms %= (verbly::notion::wnid == 100015388)); 87 thingFilter &= (verbly::notion::fullHypernyms %= (verbly::notion::wnid == 100015388));
90 } 88 }
91 89
92 verbly::word thing = database.words(thingFilter).first(); 90 utterance << database.words(thingFilter).first();
93 tokens.push_back(thing.getBaseForm());
94 } 91 }
95 92
96 verbly::query<verbly::word> similarQuery = database.words( 93 verbly::query<verbly::word> similarQuery = database.words(
97 (verbly::notion::partOfSpeech == verbly::part_of_speech::noun) 94 (verbly::notion::partOfSpeech == verbly::part_of_speech::noun)
98 && (verbly::notion::fullHypernyms %= hyper) 95 && (verbly::notion::fullHypernyms %= hyper)
99 && (verbly::form::text != fruit.getBaseForm()) 96 && !fruit.getBaseForm()
100 && (verbly::word::id != hyper.getId()) 97 && !hyper
101 && (verbly::form::proper == false) 98 && (verbly::form::proper == false)
102 && (verbly::form::complexity == 1)); 99 && (verbly::form::complexity == 1));
103 std::vector<verbly::word> similarResults = similarQuery.all(); 100 std::vector<verbly::word> similarResults = similarQuery.all();
104 101
105 if (!similarResults.empty()) 102 if (!similarResults.empty())
106 { 103 {
107 tokens.push_back(similarResults.front().getBaseForm()); 104 utterance << similarResults.front();
108 } else { 105 } else {
109 verbly::query<verbly::word> differentQuery = database.words( 106 verbly::query<verbly::word> differentQuery = database.words(
110 fruitFilter 107 fruitFilter
111 && (verbly::form::text != fruit.getBaseForm()) 108 && !fruit.getBaseForm()
112 && (verbly::word::id != hyper.getId()) 109 && !hyper
113 && (verbly::form::proper == false) 110 && (verbly::form::proper == false)
114 && (verbly::form::complexity == 1)); 111 && (verbly::form::complexity == 1));
115 112
116 tokens.push_back(differentQuery.first().getBaseForm()); 113 utterance << differentQuery.first();
117 } 114 }
118 115
119 std::string fruitName = verbly::implode(std::begin(tokens), std::end(tokens), " "); 116 std::string fruitName = utterance.compile();
120 117
121 std::ostringstream result; 118 std::ostringstream result;
122 result << fruit.getBaseForm(); 119 result << fruit.getBaseForm().getText();
123 result << "? "; 120 result << "? ";
124 121
125 choice = std::uniform_int_distribution<int>(0,3)(random_engine); 122 choice = std::uniform_int_distribution<int>(0,3)(random_engine);
diff --git a/vendor/verbly b/vendor/verbly
Subproject 6cc23ba387d0813b801ba094709673a61bac889 Subproject f625e90a0721483f7f44b94b9bb57cc9d59565e