diff options
Diffstat (limited to 'generator/notion.h')
| -rw-r--r-- | generator/notion.h | 22 |
1 files changed, 14 insertions, 8 deletions
| diff --git a/generator/notion.h b/generator/notion.h index 817e66a..3bff916 100644 --- a/generator/notion.h +++ b/generator/notion.h | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | #ifndef NOTION_H_221DE2BC | 1 | #ifndef NOTION_H_221DE2BC |
| 2 | #define NOTION_H_221DE2BC | 2 | #define NOTION_H_221DE2BC |
| 3 | 3 | ||
| 4 | #include <cassert> | ||
| 5 | #include <list> | 4 | #include <list> |
| 6 | #include <string> | 5 | #include <string> |
| 6 | #include <hkutil/database.h> | ||
| 7 | #include "../lib/enums.h" | 7 | #include "../lib/enums.h" |
| 8 | 8 | ||
| 9 | namespace verbly { | 9 | namespace verbly { |
| @@ -43,24 +43,30 @@ namespace verbly { | |||
| 43 | 43 | ||
| 44 | int getWnid() const | 44 | int getWnid() const |
| 45 | { | 45 | { |
| 46 | // Calling code should always call hasWnid first. | 46 | if (!hasWnid_) |
| 47 | assert(hasWnid_); | 47 | { |
| 48 | throw std::domain_error("Notion does not have wnid"); | ||
| 49 | } | ||
| 48 | 50 | ||
| 49 | return wnid_; | 51 | return wnid_; |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | int getNumOfImages() const | 54 | int getNumOfImages() const |
| 53 | { | 55 | { |
| 54 | // Calling code should always call hasWnid and check that the notion is a noun first. | 56 | if (!hasWnid_ || (partOfSpeech_ != part_of_speech::noun)) |
| 55 | assert(hasWnid_ && (partOfSpeech_ == part_of_speech::noun)); | 57 | { |
| 58 | throw std::domain_error("Notion is not a noun with wnid"); | ||
| 59 | } | ||
| 56 | 60 | ||
| 57 | return numOfImages_; | 61 | return numOfImages_; |
| 58 | } | 62 | } |
| 59 | 63 | ||
| 60 | std::list<std::string> getPrepositionGroups() const | 64 | std::list<std::string> getPrepositionGroups() const |
| 61 | { | 65 | { |
| 62 | // Calling code should always check that the notion is a preposition first. | 66 | if (partOfSpeech_ != part_of_speech::preposition) |
| 63 | assert(partOfSpeech_ == part_of_speech::preposition); | 67 | { |
| 68 | throw std::domain_error("Notion is not a preposition"); | ||
| 69 | } | ||
| 64 | 70 | ||
| 65 | return prepositionGroups_; | 71 | return prepositionGroups_; |
| 66 | } | 72 | } |
| @@ -81,7 +87,7 @@ namespace verbly { | |||
| 81 | 87 | ||
| 82 | // Serializer | 88 | // Serializer |
| 83 | 89 | ||
| 84 | database& operator<<(database& db, const notion& arg); | 90 | hatkirby::database& operator<<(hatkirby::database& db, const notion& arg); |
| 85 | 91 | ||
| 86 | }; | 92 | }; |
| 87 | }; | 93 | }; |
