about summary refs log tree commit diff stats
path: root/verbly/noun.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-03-16 11:27:16 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-03-16 11:27:16 -0400
commit3aceae8ab1eb5992110ea57a9479bbc3177feb21 (patch)
tree13167a266805344efb7bb1d900486f782c23285e /verbly/noun.cpp
parente1be2716746e75cf6ed37e86461a7f580a964564 (diff)
downloadfurries-3aceae8ab1eb5992110ea57a9479bbc3177feb21.tar.gz
furries-3aceae8ab1eb5992110ea57a9479bbc3177feb21.tar.bz2
furries-3aceae8ab1eb5992110ea57a9479bbc3177feb21.zip
Added more inflections, word relationships, and pronunciations
Nouns, adjectives, and adverbs now have inflected forms. A large number of WordNet word relationships (all noun-noun relationships, plus synonymy and antonymy for all word types except verbs) have been added. Additionally, CMUDICT is now being used to store word pronunciations for rhyming purposes. Verbly is now also a compiled library rather than being header-only due to the complexity of the query interface.
Diffstat (limited to 'verbly/noun.cpp')
-rw-r--r--verbly/noun.cpp916
1 files changed, 916 insertions, 0 deletions
diff --git a/verbly/noun.cpp b/verbly/noun.cpp new file mode 100644 index 0000000..9336a1c --- /dev/null +++ b/verbly/noun.cpp
@@ -0,0 +1,916 @@
1#include "verbly.h"
2
3namespace verbly {
4
5 noun::noun(const data& _data, int _id) : word(_data, _id)
6 {
7
8 }
9
10 std::string noun::base_form() const
11 {
12 return _singular;
13 }
14
15 std::string noun::singular_form() const
16 {
17 return _singular;
18 }
19
20 std::string noun::plural_form() const
21 {
22 return _plural;
23 }
24
25 bool noun::has_plural_form() const
26 {
27 return !_plural.empty();
28 }
29
30 noun_query noun::hypernyms() const
31 {
32 return _data.nouns().hypernym_of(*this);
33 }
34
35 noun_query noun::hyponyms() const
36 {
37 return _data.nouns().hyponym_of(*this);
38 }
39
40 noun_query noun::part_meronyms() const
41 {
42 return _data.nouns().part_meronym_of(*this);
43 }
44
45 noun_query noun::part_holonyms() const
46 {
47 return _data.nouns().part_holonym_of(*this);
48 }
49
50 noun_query noun::substance_meronyms() const
51 {
52 return _data.nouns().substance_meronym_of(*this);
53 }
54
55 noun_query noun::substance_holonyms() const
56 {
57 return _data.nouns().substance_holonym_of(*this);
58 }
59
60 noun_query noun::member_meronyms() const
61 {
62 return _data.nouns().member_meronym_of(*this);
63 }
64
65 noun_query noun::member_holonyms() const
66 {
67 return _data.nouns().member_holonym_of(*this);
68 }
69
70 noun_query noun::classes() const
71 {
72 return _data.nouns().class_of(*this);
73 }
74
75 noun_query noun::instances() const
76 {
77 return _data.nouns().instance_of(*this);
78 }
79
80 noun_query noun::synonyms() const
81 {
82 return _data.nouns().synonym_of(*this);
83 }
84
85 noun_query noun::antonyms() const
86 {
87 return _data.nouns().antonym_of(*this);
88 }
89
90 adjective_query noun::pertainyms() const
91 {
92 return _data.adjectives().pertainym_of(*this);
93 }
94
95 adjective_query noun::variations() const
96 {
97 return _data.adjectives().variant_of(*this);
98 }
99
100 noun_query::noun_query(const data& _data) : _data(_data)
101 {
102
103 }
104
105 noun_query& noun_query::limit(int _limit)
106 {
107 if ((_limit > 0) || (_limit == unlimited))
108 {
109 this->_limit = _limit;
110 }
111
112 return *this;
113 }
114
115 noun_query& noun_query::random(bool _random)
116 {
117 this->_random = _random;
118
119 return *this;
120 }
121
122 noun_query& noun_query::except(const noun& _word)
123 {
124 _except.push_back(_word);
125
126 return *this;
127 }
128
129 noun_query& noun_query::rhymes_with(const word& _word)
130 {
131 for (auto rhyme : _word.rhyme_phonemes())
132 {
133 _rhymes.push_back(rhyme);
134 }
135
136 if (dynamic_cast<const noun*>(&_word) != nullptr)
137 {
138 _except.push_back(dynamic_cast<const noun&>(_word));
139 }
140
141 return *this;
142 }
143
144 noun_query& noun_query::has_pronunciation(bool _has_prn)
145 {
146 this->_has_prn = _has_prn;
147
148 return *this;
149 }
150
151 noun_query& noun_query::is_hypernym(bool _arg)
152 {
153 _is_hypernym = _arg;
154
155 return *this;
156 }
157
158 noun_query& noun_query::hypernym_of(const noun& _noun)
159 {
160 _hypernym_of.push_back(_noun);
161
162 return *this;
163 }
164
165 noun_query& noun_query::not_hypernym_of(const noun& _noun)
166 {
167 _not_hypernym_of.push_back(_noun);
168
169 return *this;
170 }
171
172 noun_query& noun_query::is_hyponym(bool _arg)
173 {
174 _is_hyponym = _arg;
175
176 return *this;
177 }
178
179 noun_query& noun_query::hyponym_of(const noun& _noun)
180 {
181 _hyponym_of.push_back(_noun);
182
183 return *this;
184 }
185
186 noun_query& noun_query::not_hyponym_of(const noun& _noun)
187 {
188 _not_hyponym_of.push_back(_noun);
189
190 return *this;
191 }
192
193 noun_query& noun_query::is_part_meronym(bool _arg)
194 {
195 _is_part_meronym = _arg;
196
197 return *this;
198 }
199
200 noun_query& noun_query::part_meronym_of(const noun& _noun)
201 {
202 _part_meronym_of.push_back(_noun);
203
204 return *this;
205 }
206
207 noun_query& noun_query::not_part_meronym_of(const noun& _noun)
208 {
209 _not_part_meronym_of.push_back(_noun);
210
211 return *this;
212 }
213
214 noun_query& noun_query::is_part_holonym(bool _arg)
215 {
216 _is_part_holonym = _arg;
217
218 return *this;
219 }
220
221 noun_query& noun_query::part_holonym_of(const noun& _noun)
222 {
223 _part_holonym_of.push_back(_noun);
224
225 return *this;
226 }
227
228 noun_query& noun_query::not_part_holonym_of(const noun& _noun)
229 {
230 _not_part_holonym_of.push_back(_noun);
231
232 return *this;
233 }
234
235 noun_query& noun_query::is_substance_meronym(bool _arg)
236 {
237 _is_substance_meronym = _arg;
238
239 return *this;
240 }
241
242 noun_query& noun_query::substance_meronym_of(const noun& _noun)
243 {
244 _substance_meronym_of.push_back(_noun);
245
246 return *this;
247 }
248
249 noun_query& noun_query::not_substance_meronym_of(const noun& _noun)
250 {
251 _not_substance_meronym_of.push_back(_noun);
252
253 return *this;
254 }
255
256 noun_query& noun_query::is_substance_holonym(bool _arg)
257 {
258 _is_substance_holonym = _arg;
259
260 return *this;
261 }
262
263 noun_query& noun_query::substance_holonym_of(const noun& _noun)
264 {
265 _substance_holonym_of.push_back(_noun);
266
267 return *this;
268 }
269
270 noun_query& noun_query::not_substance_holonym_of(const noun& _noun)
271 {
272 _not_substance_holonym_of.push_back(_noun);
273
274 return *this;
275 }
276
277 noun_query& noun_query::is_member_meronym(bool _arg)
278 {
279 _is_member_meronym = _arg;
280
281 return *this;
282 }
283
284 noun_query& noun_query::member_meronym_of(const noun& _noun)
285 {
286 _member_meronym_of.push_back(_noun);
287
288 return *this;
289 }
290
291 noun_query& noun_query::not_member_meronym_of(const noun& _noun)
292 {
293 _not_member_meronym_of.push_back(_noun);
294
295 return *this;
296 }
297
298 noun_query& noun_query::is_member_holonym(bool _arg)
299 {
300 _is_member_holonym = _arg;
301
302 return *this;
303 }
304
305 noun_query& noun_query::member_holonym_of(const noun& _noun)
306 {
307 _member_holonym_of.push_back(_noun);
308
309 return *this;
310 }
311
312 noun_query& noun_query::not_member_holonym_of(const noun& _noun)
313 {
314 _not_member_holonym_of.push_back(_noun);
315
316 return *this;
317 }
318
319 noun_query& noun_query::is_proper(bool _arg)
320 {
321 _is_proper = _arg;
322
323 return *this;
324 }
325
326 noun_query& noun_query::instance_of(const noun& _noun)
327 {
328 _instance_of.push_back(_noun);
329
330 return *this;
331 }
332
333 noun_query& noun_query::not_instance_of(const noun& _noun)
334 {
335 _not_instance_of.push_back(_noun);
336
337 return *this;
338 }
339
340 noun_query& noun_query::is_class(bool _arg)
341 {
342 _is_class = _arg;
343
344 return *this;
345 }
346
347 noun_query& noun_query::class_of(const noun& _noun)
348 {
349 _class_of.push_back(_noun);
350
351 return *this;
352 }
353
354 noun_query& noun_query::not_class_of(const noun& _noun)
355 {
356 _not_class_of.push_back(_noun);
357
358 return *this;
359 }
360
361 noun_query& noun_query::has_synonyms(bool _arg)
362 {
363 _has_synonyms = _arg;
364
365 return *this;
366 }
367
368 noun_query& noun_query::synonym_of(const noun& _noun)
369 {
370 _synonym_of.push_back(_noun);
371
372 return *this;
373 }
374
375 noun_query& noun_query::not_synonym_of(const noun& _noun)
376 {
377 _not_synonym_of.push_back(_noun);
378
379 return *this;
380 }
381
382 noun_query& noun_query::has_antonyms(bool _arg)
383 {
384 _has_antonyms = _arg;
385
386 return *this;
387 }
388
389 noun_query& noun_query::antonym_of(const noun& _noun)
390 {
391 _antonym_of.push_back(_noun);
392
393 return *this;
394 }
395
396 noun_query& noun_query::not_antonym_of(const noun& _noun)
397 {
398 _not_antonym_of.push_back(_noun);
399
400 return *this;
401 }
402
403 noun_query& noun_query::has_pertainym(bool _arg)
404 {
405 _has_pertainym = _arg;
406
407 return *this;
408 }
409
410 noun_query& noun_query::anti_pertainym_of(const adjective& _adj)
411 {
412 _anti_pertainym_of.push_back(_adj);
413
414 return *this;
415 }
416
417 noun_query& noun_query::is_attribute(bool _arg)
418 {
419 _is_attribute = _arg;
420
421 return *this;
422 }
423
424 noun_query& noun_query::attribute_of(const adjective& _adj)
425 {
426 _attribute_of.push_back(_adj);
427
428 return *this;
429 }
430
431 std::list<noun> noun_query::run() const
432 {
433 std::stringstream construct;
434 construct << "SELECT noun_id, singular, plural FROM nouns";
435 std::list<std::string> conditions;
436
437 if (_has_prn)
438 {
439 conditions.push_back("noun_id IN (SELECT noun_id FROM noun_pronunciations)");
440 }
441
442 if (!_rhymes.empty())
443 {
444 std::list<std::string> clauses(_rhymes.size(), "pronunciation LIKE @RHMPRN");
445 std::string cond = "noun_id IN (SELECT noun_id FROM noun_pronunciations WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
446 conditions.push_back(cond);
447 }
448
449 for (auto except : _except)
450 {
451 conditions.push_back("noun_id != @EXCID");
452 }
453
454 if (_is_hypernym)
455 {
456 conditions.push_back("noun_id IN (SELECT hypernym_id FROM hypernymy)");
457 }
458
459 if (!_hypernym_of.empty())
460 {
461 std::list<std::string> clauses(_hypernym_of.size(), "hyponym_id = @HYPO");
462 std::string cond = "noun_id IN (SELECT hypernym_id FROM hypernymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
463 conditions.push_back(cond);
464 }
465
466 if (!_not_hypernym_of.empty())
467 {
468 std::list<std::string> clauses(_not_hypernym_of.size(), "hyponym_id = @NHYPO");
469 std::string cond = "noun_id NOT IN (SELECT hypernym_id FROM hypernymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
470 conditions.push_back(cond);
471 }
472
473 if (_is_hyponym)
474 {
475 conditions.push_back("noun_id IN (SELECT hyponym_id FROM hypernymy)");
476 }
477
478 if (!_hyponym_of.empty())
479 {
480 std::list<std::string> clauses(_hyponym_of.size(), "hypernym_id = @HYPER");
481 std::string cond = "noun_id IN (SELECT hyponym_id FROM hypernymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
482 conditions.push_back(cond);
483 }
484
485 if (!_not_hyponym_of.empty())
486 {
487 std::list<std::string> clauses(_not_hyponym_of.size(), "hypernym_id = @NHYPER");
488 std::string cond = "noun_id NOT IN (SELECT hyponym_id FROM hypernymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
489 conditions.push_back(cond);
490 }
491
492 if (_is_part_meronym)
493 {
494 conditions.push_back("noun_id IN (SELECT meronym_id FROM part_meronymy)");
495 }
496
497 if (!_part_meronym_of.empty())
498 {
499 std::list<std::string> clauses(_part_meronym_of.size(), "holonym_id = @PHOLO");
500 std::string cond = "noun_id IN (SELECT meronym_id FROM part_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
501 conditions.push_back(cond);
502 }
503
504 if (!_not_part_meronym_of.empty())
505 {
506 std::list<std::string> clauses(_not_part_meronym_of.size(), "holonym_id = @NPHOLO");
507 std::string cond = "noun_id NOT IN (SELECT meronym_id FROM part_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
508 conditions.push_back(cond);
509 }
510
511 if (_is_part_holonym)
512 {
513 conditions.push_back("noun_id IN (SELECT holonym_id FROM part_meronymy)");
514 }
515
516 if (!_part_holonym_of.empty())
517 {
518 std::list<std::string> clauses(_part_holonym_of.size(), "meronym_id = @PMERO");
519 std::string cond = "noun_id IN (SELECT holonym_id FROM part_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
520 conditions.push_back(cond);
521 }
522
523 if (!_not_part_holonym_of.empty())
524 {
525 std::list<std::string> clauses(_not_part_holonym_of.size(), "meronym_id = @NPMERO");
526 std::string cond = "noun_id NOT IN (SELECT holonym_id FROM part_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
527 conditions.push_back(cond);
528 }
529
530 if (_is_substance_meronym)
531 {
532 conditions.push_back("noun_id IN (SELECT meronym_id FROM substance_meronymy)");
533 }
534
535 if (!_substance_meronym_of.empty())
536 {
537 std::list<std::string> clauses(_substance_meronym_of.size(), "holonym_id = @SHOLO");
538 std::string cond = "noun_id IN (SELECT meronym_id FROM substance_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
539 conditions.push_back(cond);
540 }
541
542 if (!_not_substance_meronym_of.empty())
543 {
544 std::list<std::string> clauses(_not_substance_meronym_of.size(), "holonym_id = @NSHOLO");
545 std::string cond = "noun_id NOT IN (SELECT meronym_id FROM substance_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
546 conditions.push_back(cond);
547 }
548
549 if (_is_substance_holonym)
550 {
551 conditions.push_back("noun_id IN (SELECT holonym_id FROM substance_meronymy)");
552 }
553
554 if (!_substance_holonym_of.empty())
555 {
556 std::list<std::string> clauses(_substance_holonym_of.size(), "meronym_id = @SMERO");
557 std::string cond = "noun_id IN (SELECT holonym_id FROM substance_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
558 conditions.push_back(cond);
559 }
560
561 if (!_not_substance_holonym_of.empty())
562 {
563 std::list<std::string> clauses(_not_substance_holonym_of.size(), "meronym_id = @NSMERO");
564 std::string cond = "noun_id NOT IN (SELECT holonym_id FROM substance_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
565 conditions.push_back(cond);
566 }
567
568 if (_is_member_meronym)
569 {
570 conditions.push_back("noun_id IN (SELECT meronym_id FROM member_meronymy)");
571 }
572
573 if (!_member_meronym_of.empty())
574 {
575 std::list<std::string> clauses(_member_meronym_of.size(), "holonym_id = @MHOLO");
576 std::string cond = "noun_id IN (SELECT meronym_id FROM member_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
577 conditions.push_back(cond);
578 }
579
580 if (!_not_member_meronym_of.empty())
581 {
582 std::list<std::string> clauses(_not_member_meronym_of.size(), "holonym_id = @NMHOLO");
583 std::string cond = "noun_id NOT IN (SELECT meronym_id FROM member_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
584 conditions.push_back(cond);
585 }
586
587 if (_is_member_holonym)
588 {
589 conditions.push_back("noun_id IN (SELECT holonym_id FROM member_meronym)");
590 }
591
592 if (!_member_holonym_of.empty())
593 {
594 std::list<std::string> clauses(_member_holonym_of.size(), "meronym_id = @MMERO");
595 std::string cond = "noun_id IN (SELECT holonym_id FROM member_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
596 conditions.push_back(cond);
597 }
598
599 if (!_not_member_holonym_of.empty())
600 {
601 std::list<std::string> clauses(_not_member_holonym_of.size(), "meronym_id = @NMMERO");
602 std::string cond = "noun_id NOT IN (SELECT holonym_id FROM member_meronymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
603 conditions.push_back(cond);
604 }
605
606 if (_is_proper)
607 {
608 conditions.push_back("noun_id IN (SELECT instance_id FROM instantiation)");
609 }
610
611 if (!_instance_of.empty())
612 {
613 std::list<std::string> clauses(_instance_of.size(), "class_id = @CLSID");
614 std::string cond = "noun_id IN (SELECT instance_id FROM instantiation WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
615 conditions.push_back(cond);
616 }
617
618 if (!_not_instance_of.empty())
619 {
620 std::list<std::string> clauses(_not_instance_of.size(), "class_id = @NCLSID");
621 std::string cond = "noun_id NOT IN (SELECT instance_id FROM instantiation WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
622 conditions.push_back(cond);
623 }
624
625 if (_is_class)
626 {
627 conditions.push_back("noun_id IN (SELECT class_id FROM instantiation)");
628 }
629
630 if (!_class_of.empty())
631 {
632 std::list<std::string> clauses(_class_of.size(), "instance_id = @INSID");
633 std::string cond = "noun_id IN (SELECT class_id FROM instantiation WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
634 conditions.push_back(cond);
635 }
636
637 if (!_not_class_of.empty())
638 {
639 std::list<std::string> clauses(_not_class_of.size(), "instance_id = @NINSID");
640 std::string cond = "noun_id NOT IN (SELECT class_id FROM instantiation WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
641 conditions.push_back(cond);
642 }
643
644 if (_has_synonyms)
645 {
646 conditions.push_back("noun_id IN (SELECT adjective_2_id FROM adjective_synonymy)");
647 }
648
649 if (!_synonym_of.empty())
650 {
651 std::list<std::string> clauses(_synonym_of.size(), "adjective_1_id = @SYNID");
652 std::string cond = "noun_id IN (SELECT adjective_2_id FROM adjective_synonymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
653 conditions.push_back(cond);
654 }
655
656 if (!_not_synonym_of.empty())
657 {
658 std::list<std::string> clauses(_not_synonym_of.size(), "adjective_1_id = @NSYNID");
659 std::string cond = "noun_id NOT IN (SELECT adjective_2_id FROM adjective_synonymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
660 conditions.push_back(cond);
661 }
662
663 if (_has_antonyms)
664 {
665 conditions.push_back("noun_id IN (SELECT adjective_2_id FROM adjective_antonymy)");
666 }
667
668 if (!_antonym_of.empty())
669 {
670 std::list<std::string> clauses(_antonym_of.size(), "adjective_1_id = @ANTID");
671 std::string cond = "noun_id IN (SELECT adjective_2_id FROM adjective_antonymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
672 conditions.push_back(cond);
673 }
674
675 if (!_not_antonym_of.empty())
676 {
677 std::list<std::string> clauses(_not_antonym_of.size(), "adjective_1_id = @NANTID");
678 std::string cond = "noun_id NOT IN (SELECT adjective_2_id FROM adjective_antonymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
679 conditions.push_back(cond);
680 }
681
682 if (_has_pertainym)
683 {
684 conditions.push_back("noun_id IN (SELECT noun_id FROM pertainymy)");
685 }
686
687 if (!_anti_pertainym_of.empty())
688 {
689 std::list<std::string> clauses(_anti_pertainym_of.size(), "pertainym_id = @PERID");
690 std::string cond = "noun_id IN (SELECT noun_id FROM pertainymy WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
691 conditions.push_back(cond);
692 }
693
694 if (_is_attribute)
695 {
696 conditions.push_back("noun_id IN (SELECT noun_id FROM variation)");
697 }
698
699 if (!_attribute_of.empty())
700 {
701 std::list<std::string> clauses(_attribute_of.size(), "adjective_id = @VALID");
702 std::string cond = "noun_id IN (SELECT noun_id FROM variation WHERE " + verbly::implode(std::begin(clauses), std::end(clauses), " OR ") + ")";
703 conditions.push_back(cond);
704 }
705
706 if (!conditions.empty())
707 {
708 construct << " WHERE ";
709 construct << verbly::implode(std::begin(conditions), std::end(conditions), " AND ");
710 }
711
712 if (_random)
713 {
714 construct << " ORDER BY RANDOM()";
715 }
716
717 if (_limit != unlimited)
718 {
719 construct << " LIMIT " << _limit;
720 }
721
722 sqlite3_stmt* ppstmt;
723 std::string query = construct.str();
724 if (sqlite3_prepare_v2(_data.ppdb, query.c_str(), query.length(), &ppstmt, NULL) != SQLITE_OK)
725 {
726 throw std::runtime_error(sqlite3_errmsg(_data.ppdb));
727 }
728
729 if (!_rhymes.empty())
730 {
731 int i = 0;
732 for (auto rhyme : _rhymes)
733 {
734 std::string rhymer = "%" + rhyme;
735 sqlite3_bind_text(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@RHMPRN"), rhymer.c_str(), rhymer.length(), SQLITE_STATIC);
736
737 i++;
738 }
739 }
740
741 for (auto except : _except)
742 {
743 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@EXCID"), except._id);
744 }
745
746 for (auto hyponym : _hypernym_of)
747 {
748 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@HYPO"), hyponym._id);
749 }
750
751 for (auto hyponym : _not_hypernym_of)
752 {
753 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NHYPO"), hyponym._id);
754 }
755
756 for (auto hypernym : _hyponym_of)
757 {
758 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@HYPER"), hypernym._id);
759 }
760
761 for (auto hypernym : _not_hyponym_of)
762 {
763 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NHYPER"), hypernym._id);
764 }
765
766 for (auto holonym : _part_meronym_of)
767 {
768 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@PHOLO"), holonym._id);
769 }
770
771 for (auto holonym : _not_part_meronym_of)
772 {
773 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NPHOLO"), holonym._id);
774 }
775
776 for (auto meronym : _part_holonym_of)
777 {
778 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@PMERO"), meronym._id);
779 }
780
781 for (auto meronym : _not_part_holonym_of)
782 {
783 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NPMERO"), meronym._id);
784 }
785
786 for (auto holonym : _substance_meronym_of)
787 {
788 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@SHOLO"), holonym._id);
789 }
790
791 for (auto holonym : _not_substance_meronym_of)
792 {
793 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NSHOLO"), holonym._id);
794 }
795
796 for (auto meronym : _substance_holonym_of)
797 {
798 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@SMERO"), meronym._id);
799 }
800
801 for (auto meronym : _not_substance_holonym_of)
802 {
803 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NSMERO"), meronym._id);
804 }
805
806 for (auto holonym : _member_meronym_of)
807 {
808 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@MHOLO"), holonym._id);
809 }
810
811 for (auto holonym : _not_member_meronym_of)
812 {
813 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NMHOLO"), holonym._id);
814 }
815
816 for (auto meronym : _member_holonym_of)
817 {
818 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@MMERO"), meronym._id);
819 }
820
821 for (auto meronym : _not_member_holonym_of)
822 {
823 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NMMERO"), meronym._id);
824 }
825
826 for (auto cls : _instance_of)
827 {
828 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@CLSID"), cls._id);
829 }
830
831 for (auto cls : _not_instance_of)
832 {
833 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NCLSID"), cls._id);
834 }
835
836 for (auto inst : _class_of)
837 {
838 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@INSID"), inst._id);
839 }
840
841 for (auto inst : _not_class_of)
842 {
843 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NINSID"), inst._id);
844 }
845
846 for (auto synonym : _synonym_of)
847 {
848 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@SYNID"), synonym._id);
849 }
850
851 for (auto synonym : _not_synonym_of)
852 {
853 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NSYNID"), synonym._id);
854 }
855
856 for (auto antonym : _antonym_of)
857 {
858 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@ANTID"), antonym._id);
859 }
860
861 for (auto antonym : _not_antonym_of)
862 {
863 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@NANTID"), antonym._id);
864 }
865
866 for (auto pertainym : _anti_pertainym_of)
867 {
868 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@PERID"), pertainym._id);
869 }
870
871 for (auto value : _attribute_of)
872 {
873 sqlite3_bind_int(ppstmt, sqlite3_bind_parameter_index(ppstmt, "@VALID"), value._id);
874 }
875
876 std::list<noun> output;
877 while (sqlite3_step(ppstmt) == SQLITE_ROW)
878 {
879 noun tnc {_data, sqlite3_column_int(ppstmt, 0)};
880 tnc._singular = std::string(reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 1)));
881
882 if (sqlite3_column_type(ppstmt, 2) != SQLITE_NULL)
883 {
884 tnc._plural = std::string(reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 2)));
885 }
886
887 output.push_back(tnc);
888 }
889
890 sqlite3_finalize(ppstmt);
891
892 for (auto& noun : output)
893 {
894 query = "SELECT pronunciation FROM noun_pronunciations WHERE noun_id = ?";
895 if (sqlite3_prepare_v2(_data.ppdb, query.c_str(), query.length(), &ppstmt, NULL) != SQLITE_OK)
896 {
897 throw std::runtime_error(sqlite3_errmsg(_data.ppdb));
898 }
899
900 sqlite3_bind_int(ppstmt, 1, noun._id);
901
902 while (sqlite3_step(ppstmt) == SQLITE_ROW)
903 {
904 std::string pronunciation(reinterpret_cast<const char*>(sqlite3_column_text(ppstmt, 0)));
905 auto phonemes = verbly::split<std::list<std::string>>(pronunciation, " ");
906
907 noun.pronunciations.push_back(phonemes);
908 }
909
910 sqlite3_finalize(ppstmt);
911 }
912
913 return output;
914 }
915
916};