summary refs log tree commit diff stats
path: root/generator/notion.h
blob: 6e3849739012e61722bdc587cfebc0adb9e2a610 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef NOTION_H_221DE2BC
#define NOTION_H_221DE2BC

#include <cassert>
#include <list>
#include <string>
#include "../lib/enums.h"

namespace verbly {
  namespace generator {

    class database;

    class notion {
    public:

      // Constructors

      explicit notion(part_of_speech partOfSpeech);

      notion(part_of_speech partOfSpeech, int wnid);

      // Mutators

      void incrementNumOfImages();

      void setPrepositionGroups(std::list<std::string> groups);

      // Accessors

      int getId() const
      {
        return id_;
      }

      part_of_speech getPartOfSpeech() const
      {
        return partOfSpeech_;
      }

      bool hasWnid() const
      {
        return hasWnid_;
      }

      int getWnid() const
      {
        // Calling code should always call hasWnid first.
        assert(hasWnid_);

        return wnid_;
      }

      int getNumOfImages() const
      {
        // Calling code should always call hasWnid and check that the notion is a noun first.
        assert(hasWnid_ && (partOfSpeech_ == part_of_speech::noun));

        return numOfImages_;
      }

      std::list<std::string> getPrepositionGroups() const
      {
        // Calling code should always check that the notion is a preposition first.
        assert(partOfSpeech_ == part_of_speech::preposition);

        return prepositionGroups_;
      }

    private:

      static int nextId_;

      const int id_;
      const part_of_speech partOfSpeech_;
      const int wnid_ = 0;
      const bool hasWnid_ = false;

      int numOfImages_ = 0;
      std::list<std::string> prepositionGroups_;

    };

    // Serializer

    database& operator<<(database& db, const notion& arg);

  };
};

#endif /* end of include guard: NOTION_H_221DE2BC */