diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-19 14:40:21 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-19 14:40:21 -0400 |
| commit | 02c187fd3141203024b6f359ec714c0b804583c0 (patch) | |
| tree | a3944e5ed54bf1e6faea276346ac773f7623079b | |
| parent | 909852431ef20a6afb6716ff40577f1be806e0ca (diff) | |
| download | verbly-02c187fd3141203024b6f359ec714c0b804583c0.tar.gz verbly-02c187fd3141203024b6f359ec714c0b804583c0.tar.bz2 verbly-02c187fd3141203024b6f359ec714c0b804583c0.zip | |
Nouns with any uppercase letters are now considered proper
| -rw-r--r-- | generator/generator.cpp | 12 | ||||
| -rw-r--r-- | generator/schema.sql | 3 | ||||
| -rw-r--r-- | lib/noun.cpp | 16 | ||||
| -rw-r--r-- | lib/noun.h | 4 |
4 files changed, 29 insertions, 6 deletions
| diff --git a/generator/generator.cpp b/generator/generator.cpp index faef5f7..de369a4 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <sstream> | 10 | #include <sstream> |
| 11 | #include <regex> | 11 | #include <regex> |
| 12 | #include <list> | 12 | #include <list> |
| 13 | #include <algorithm> | ||
| 13 | #include "progress.h" | 14 | #include "progress.h" |
| 14 | 15 | ||
| 15 | struct verb { | 16 | struct verb { |
| @@ -525,9 +526,9 @@ int main(int argc, char** argv) | |||
| 525 | { | 526 | { |
| 526 | if (nouns.count(word) == 1) | 527 | if (nouns.count(word) == 1) |
| 527 | { | 528 | { |
| 528 | query = "INSERT INTO nouns (singular, plural) VALUES (?, ?)"; | 529 | query = "INSERT INTO nouns (singular, proper, plural) VALUES (?, ?, ?)"; |
| 529 | } else { | 530 | } else { |
| 530 | query = "INSERT INTO nouns (singular) VALUES (?)"; | 531 | query = "INSERT INTO nouns (singular, proper) VALUES (?, ?)"; |
| 531 | } | 532 | } |
| 532 | 533 | ||
| 533 | break; | 534 | break; |
| @@ -576,9 +577,14 @@ int main(int argc, char** argv) | |||
| 576 | { | 577 | { |
| 577 | case 1: // Noun | 578 | case 1: // Noun |
| 578 | { | 579 | { |
| 580 | auto sing = nouns[word].singular; | ||
| 581 | sqlite3_bind_int(ppstmt, 2, (std::any_of(std::begin(sing), std::end(sing), [] (char ch) { | ||
| 582 | return isupper(ch); | ||
| 583 | }) ? 1 : 0)); | ||
| 584 | |||
| 579 | if (nouns.count(word) == 1) | 585 | if (nouns.count(word) == 1) |
| 580 | { | 586 | { |
| 581 | sqlite3_bind_text(ppstmt, 2, nouns[word].plural.c_str(), nouns[word].plural.length(), SQLITE_STATIC); | 587 | sqlite3_bind_text(ppstmt, 3, nouns[word].plural.c_str(), nouns[word].plural.length(), SQLITE_STATIC); |
| 582 | } | 588 | } |
| 583 | 589 | ||
| 584 | break; | 590 | break; |
| diff --git a/generator/schema.sql b/generator/schema.sql index b4efe0a..8e1e822 100644 --- a/generator/schema.sql +++ b/generator/schema.sql | |||
| @@ -52,7 +52,8 @@ DROP TABLE IF EXISTS `nouns`; | |||
| 52 | CREATE TABLE `nouns` ( | 52 | CREATE TABLE `nouns` ( |
| 53 | `noun_id` INTEGER PRIMARY KEY, | 53 | `noun_id` INTEGER PRIMARY KEY, |
| 54 | `singular` VARCHAR(32) NOT NULL, | 54 | `singular` VARCHAR(32) NOT NULL, |
| 55 | `plural` VARCHAR(32) | 55 | `plural` VARCHAR(32), |
| 56 | `proper` INTEGER(1) NOT NULL | ||
| 56 | ); | 57 | ); |
| 57 | 58 | ||
| 58 | DROP TABLE IF EXISTS `hypernymy`; | 59 | DROP TABLE IF EXISTS `hypernymy`; |
| diff --git a/lib/noun.cpp b/lib/noun.cpp index 43fda2e..81e6613 100644 --- a/lib/noun.cpp +++ b/lib/noun.cpp | |||
| @@ -330,6 +330,13 @@ namespace verbly { | |||
| 330 | return *this; | 330 | return *this; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | noun_query& noun_query::is_instance(bool _arg) | ||
| 334 | { | ||
| 335 | _is_instance = _arg; | ||
| 336 | |||
| 337 | return *this; | ||
| 338 | } | ||
| 339 | |||
| 333 | noun_query& noun_query::instance_of(const noun& _noun) | 340 | noun_query& noun_query::instance_of(const noun& _noun) |
| 334 | { | 341 | { |
| 335 | _instance_of.push_back(_noun); | 342 | _instance_of.push_back(_noun); |
| @@ -644,12 +651,17 @@ namespace verbly { | |||
| 644 | 651 | ||
| 645 | if (_is_proper) | 652 | if (_is_proper) |
| 646 | { | 653 | { |
| 647 | conditions.push_back("noun_id IN (SELECT instance_id FROM instantiation)"); | 654 | conditions.push_back("proper = 1"); |
| 648 | } | 655 | } |
| 649 | 656 | ||
| 650 | if (_is_not_proper) | 657 | if (_is_not_proper) |
| 651 | { | 658 | { |
| 652 | conditions.push_back("noun_id NOT IN (SELECT instance_id FROM instantiation)"); | 659 | conditions.push_back("proper = 0"); |
| 660 | } | ||
| 661 | |||
| 662 | if (_is_instance) | ||
| 663 | { | ||
| 664 | conditions.push_back("noun_id IN (SELECT instance_id FROM instantiation)"); | ||
| 653 | } | 665 | } |
| 654 | 666 | ||
| 655 | if (!_instance_of.empty()) | 667 | if (!_instance_of.empty()) |
| diff --git a/lib/noun.h b/lib/noun.h index da76866..fbc2f9e 100644 --- a/lib/noun.h +++ b/lib/noun.h | |||
| @@ -79,6 +79,8 @@ namespace verbly { | |||
| 79 | 79 | ||
| 80 | noun_query& is_proper(bool _arg); | 80 | noun_query& is_proper(bool _arg); |
| 81 | noun_query& is_not_proper(bool _arg); | 81 | noun_query& is_not_proper(bool _arg); |
| 82 | |||
| 83 | noun_query& is_instance(bool _arg); | ||
| 82 | noun_query& instance_of(const noun& _noun); | 84 | noun_query& instance_of(const noun& _noun); |
| 83 | noun_query& not_instance_of(const noun& _noun); | 85 | noun_query& not_instance_of(const noun& _noun); |
| 84 | 86 | ||
| @@ -149,6 +151,8 @@ namespace verbly { | |||
| 149 | 151 | ||
| 150 | bool _is_proper = false; | 152 | bool _is_proper = false; |
| 151 | bool _is_not_proper = false; | 153 | bool _is_not_proper = false; |
| 154 | |||
| 155 | bool _is_instance = false; | ||
| 152 | std::list<noun> _instance_of; | 156 | std::list<noun> _instance_of; |
| 153 | std::list<noun> _not_instance_of; | 157 | std::list<noun> _not_instance_of; |
| 154 | 158 | ||
