From 4c94e100e87a09284f0e0a5bc0df688672492a1e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 27 Mar 2016 14:28:54 -0400 Subject: Added prefix/suffix search, and word complexity search for nouns, adjectives, and adverbs Word complexity refers to the number of words in a noun, adjective, or adverb. --- generator/generator.cpp | 22 +++++++++++++--------- generator/schema.sql | 9 ++++++--- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'generator') diff --git a/generator/generator.cpp b/generator/generator.cpp index aea750c..6fbbfb8 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -1027,9 +1027,9 @@ int main(int argc, char** argv) { if (nouns.count(word) == 1) { - query = "INSERT INTO nouns (singular, proper, plural) VALUES (?, ?, ?)"; + query = "INSERT INTO nouns (singular, proper, complexity, plural) VALUES (?, ?, ?, ?)"; } else { - query = "INSERT INTO nouns (singular, proper) VALUES (?, ?)"; + query = "INSERT INTO nouns (singular, proper, complexity) VALUES (?, ?, ?)"; } break; @@ -1046,9 +1046,9 @@ int main(int argc, char** argv) { if (adjectives.count(word) == 1) { - query = "INSERT INTO adjectives (base_form, comparative, superlative) VALUES (?, ?, ?)"; + query = "INSERT INTO adjectives (base_form, complexity, comparative, superlative) VALUES (?, ?, ?, ?)"; } else { - query = "INSERT INTO adjectives (base_form) VALUES (?)"; + query = "INSERT INTO adjectives (base_form, complexity) VALUES (?, ?)"; } break; @@ -1058,9 +1058,9 @@ int main(int argc, char** argv) { if (adjectives.count(word) == 1) { - query = "INSERT INTO adverbs (base_form, comparative, superlative) VALUES (?, ?, ?)"; + query = "INSERT INTO adverbs (base_form, complexity, comparative, superlative) VALUES (?, ?, ?, ?)"; } else { - query = "INSERT INTO adverbs (base_form) VALUES (?)"; + query = "INSERT INTO adverbs (base_form, complexity) VALUES (?, ?)"; } break; @@ -1082,9 +1082,11 @@ int main(int argc, char** argv) return isupper(ch); }) ? 1 : 0)); + sqlite3_bind_int(ppstmt, 3, verbly::split>(word, " ").size()); + if (nouns.count(word) == 1) { - sqlite3_bind_text(ppstmt, 3, nouns[word].plural.c_str(), nouns[word].plural.length(), SQLITE_STATIC); + sqlite3_bind_text(ppstmt, 4, nouns[word].plural.c_str(), nouns[word].plural.length(), SQLITE_STATIC); } break; @@ -1093,10 +1095,12 @@ int main(int argc, char** argv) case 3: // Adjective case 4: // Adverb { + sqlite3_bind_int(ppstmt, 2, verbly::split>(word, " ").size()); + if (adjectives.count(word) == 1) { - sqlite3_bind_text(ppstmt, 2, adjectives[word].comparative.c_str(), adjectives[word].comparative.length(), SQLITE_STATIC); - sqlite3_bind_text(ppstmt, 3, adjectives[word].superlative.c_str(), adjectives[word].superlative.length(), SQLITE_STATIC); + sqlite3_bind_text(ppstmt, 3, adjectives[word].comparative.c_str(), adjectives[word].comparative.length(), SQLITE_STATIC); + sqlite3_bind_text(ppstmt, 4, adjectives[word].superlative.c_str(), adjectives[word].superlative.length(), SQLITE_STATIC); } break; diff --git a/generator/schema.sql b/generator/schema.sql index 2295444..f2445f0 100644 --- a/generator/schema.sql +++ b/generator/schema.sql @@ -36,7 +36,8 @@ CREATE TABLE `adjectives` ( `base_form` VARCHAR(32) NOT NULL, `comparative` VARCHAR(32), `superlative` VARCHAR(32), - `position` CHAR(1) + `position` CHAR(1), + `complexity` INTEGER NOT NULL ); DROP TABLE IF EXISTS `adverbs`; @@ -44,7 +45,8 @@ CREATE TABLE `adverbs` ( `adverb_id` INTEGER PRIMARY KEY, `base_form` VARCHAR(32) NOT NULL, `comparative` VARCHAR(32), - `superlative` VARCHAR(32) + `superlative` VARCHAR(32), + `complexity` INTEGER NOT NULL ); DROP TABLE IF EXISTS `nouns`; @@ -52,7 +54,8 @@ CREATE TABLE `nouns` ( `noun_id` INTEGER PRIMARY KEY, `singular` VARCHAR(32) NOT NULL, `plural` VARCHAR(32), - `proper` INTEGER(1) NOT NULL + `proper` INTEGER(1) NOT NULL, + `complexity` INTEGER NOT NULL ); DROP TABLE IF EXISTS `hypernymy`; -- cgit 1.4.1