summary refs log tree commit diff stats
path: root/generator
diff options
context:
space:
mode:
Diffstat (limited to 'generator')
-rw-r--r--generator/form.cpp4
-rw-r--r--generator/form.h6
-rw-r--r--generator/schema.sql3
3 files changed, 11 insertions, 2 deletions
diff --git a/generator/form.cpp b/generator/form.cpp index 6be9d47..f616344 100644 --- a/generator/form.cpp +++ b/generator/form.cpp
@@ -14,7 +14,8 @@ namespace verbly {
14 id_(nextId_++), 14 id_(nextId_++),
15 text_(text), 15 text_(text),
16 complexity_(std::count(std::begin(text), std::end(text), ' ') + 1), 16 complexity_(std::count(std::begin(text), std::end(text), ' ') + 1),
17 proper_(std::any_of(std::begin(text), std::end(text), std::isupper)) 17 proper_(std::any_of(std::begin(text), std::end(text), std::isupper)),
18 length_(text.length())
18 { 19 {
19 } 20 }
20 21
@@ -32,6 +33,7 @@ namespace verbly {
32 fields.emplace_back("form", arg.getText()); 33 fields.emplace_back("form", arg.getText());
33 fields.emplace_back("complexity", arg.getComplexity()); 34 fields.emplace_back("complexity", arg.getComplexity());
34 fields.emplace_back("proper", arg.isProper()); 35 fields.emplace_back("proper", arg.isProper());
36 fields.emplace_back("length", arg.getLength());
35 37
36 db.insertIntoTable("forms", std::move(fields)); 38 db.insertIntoTable("forms", std::move(fields));
37 } 39 }
diff --git a/generator/form.h b/generator/form.h index 5576035..5a2de30 100644 --- a/generator/form.h +++ b/generator/form.h
@@ -43,6 +43,11 @@ namespace verbly {
43 return proper_; 43 return proper_;
44 } 44 }
45 45
46 int getLength() const
47 {
48 return length_;
49 }
50
46 std::set<const pronunciation*> getPronunciations() const 51 std::set<const pronunciation*> getPronunciations() const
47 { 52 {
48 return pronunciations_; 53 return pronunciations_;
@@ -56,6 +61,7 @@ namespace verbly {
56 const std::string text_; 61 const std::string text_;
57 const int complexity_; 62 const int complexity_;
58 const bool proper_; 63 const bool proper_;
64 const int length_;
59 65
60 std::set<const pronunciation*> pronunciations_; 66 std::set<const pronunciation*> pronunciations_;
61 67
diff --git a/generator/schema.sql b/generator/schema.sql index a49a853..c0f2bcb 100644 --- a/generator/schema.sql +++ b/generator/schema.sql
@@ -155,7 +155,8 @@ CREATE TABLE `forms` (
155 `form_id` INTEGER PRIMARY KEY, 155 `form_id` INTEGER PRIMARY KEY,
156 `form` VARCHAR(32) NOT NULL, 156 `form` VARCHAR(32) NOT NULL,
157 `complexity` SMALLINT NOT NULL, 157 `complexity` SMALLINT NOT NULL,
158 `proper` SMALLINT NOT NULL 158 `proper` SMALLINT NOT NULL,
159 `length` SMALLINT NOT NULL
159); 160);
160 161
161CREATE UNIQUE INDEX `form_by_string` ON `forms`(`form`); 162CREATE UNIQUE INDEX `form_by_string` ON `forms`(`form`);