diff options
Diffstat (limited to 'generator/word.cpp')
| -rw-r--r-- | generator/word.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
| diff --git a/generator/word.cpp b/generator/word.cpp new file mode 100644 index 0000000..8ba3ce2 --- /dev/null +++ b/generator/word.cpp | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | #include "word.h" | ||
| 2 | #include <list> | ||
| 3 | #include <string> | ||
| 4 | #include "database.h" | ||
| 5 | #include "notion.h" | ||
| 6 | #include "lemma.h" | ||
| 7 | #include "field.h" | ||
| 8 | #include "group.h" | ||
| 9 | |||
| 10 | namespace verbly { | ||
| 11 | namespace generator { | ||
| 12 | |||
| 13 | int word::nextId_ = 0; | ||
| 14 | |||
| 15 | word::word( | ||
| 16 | notion& n, | ||
| 17 | lemma& l) : | ||
| 18 | id_(nextId_++), | ||
| 19 | notion_(n), | ||
| 20 | lemma_(l) | ||
| 21 | { | ||
| 22 | } | ||
| 23 | |||
| 24 | word::word( | ||
| 25 | notion& n, | ||
| 26 | lemma& l, | ||
| 27 | int tagCount) : | ||
| 28 | id_(nextId_++), | ||
| 29 | notion_(n), | ||
| 30 | lemma_(l), | ||
| 31 | tagCount_(tagCount), | ||
| 32 | hasTagCount_(true) | ||
| 33 | { | ||
| 34 | } | ||
| 35 | |||
| 36 | void word::setAdjectivePosition(positioning adjectivePosition) | ||
| 37 | { | ||
| 38 | adjectivePosition_ = adjectivePosition; | ||
| 39 | } | ||
| 40 | |||
| 41 | void word::setVerbGroup(const group& verbGroup) | ||
| 42 | { | ||
| 43 | verbGroup_ = &verbGroup; | ||
| 44 | } | ||
| 45 | |||
| 46 | database& operator<<(database& db, const word& arg) | ||
| 47 | { | ||
| 48 | std::list<field> fields; | ||
| 49 | |||
| 50 | fields.emplace_back("word_id", arg.getId()); | ||
| 51 | fields.emplace_back("notion_id", arg.getNotion().getId()); | ||
| 52 | fields.emplace_back("lemma_id", arg.getLemma().getId()); | ||
| 53 | |||
| 54 | if (arg.hasTagCount()) | ||
| 55 | { | ||
| 56 | fields.emplace_back("tag_count", arg.getTagCount()); | ||
| 57 | } | ||
| 58 | |||
| 59 | if ((arg.getNotion().getPartOfSpeech() == part_of_speech::adjective) | ||
| 60 | && (arg.getAdjectivePosition() != positioning::undefined)) | ||
| 61 | { | ||
| 62 | fields.emplace_back("position", static_cast<int>(arg.getAdjectivePosition())); | ||
| 63 | } | ||
| 64 | |||
| 65 | if ((arg.getNotion().getPartOfSpeech() == part_of_speech::verb) | ||
| 66 | && (arg.hasVerbGroup())) | ||
| 67 | { | ||
| 68 | fields.emplace_back("group_id", arg.getVerbGroup().getId()); | ||
| 69 | } | ||
| 70 | |||
| 71 | db.insertIntoTable("words", std::move(fields)); | ||
| 72 | |||
| 73 | return db; | ||
| 74 | } | ||
| 75 | |||
| 76 | }; | ||
| 77 | }; | ||
