KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
semantic_trees_by_hand.h
Go to the documentation of this file.
1 #ifndef SEMANTIC_TREES_BY_HAND_H_
2 #define SEMANTIC_TREES_BY_HAND_H_
3 
12 #include <string>
13 #include <vector>
14 #include <boost/make_shared.hpp>
15 
16 namespace semantics
17 {
18 
20 {
21  std::string example_id; // just for referring to these examples taken from captions
22  std::string caption_id; // corresponds to caption number
23  std::string sentence;
24  std::string image;
26  std::string parse;
27 };
28 
29 Sentence_sem build_semantic_tree(size_t index);
30 
31 inline std::vector<Sentence_sem> collect_semantic_trees()
32 {
34 
35  /* // TEST specifying config files by config_file_path_map
36  // comment out any of the four semantic_trait category config file
37  // path specifications and that semantic_trait will not be filled
38  // in. E.g., for the case that we don't yet handle colors and
39  // sizes, comment out those lines.
40  std::map<std::string,std::string> config_file_path_map;
41  config_file_path_map["colors"] = "config/colors.config";
42  config_file_path_map["sizes"] = "config/sizes.config";
43  config_file_path_map["objects"] = "config/objects.config";
44  config_file_path_map["binary_relations"] = "config/binary_relations.config";
45  initialize_semantic_maps(config_file_path_map);
46  */
47 
48  std::vector<Sentence_sem> result;
49  result.push_back(build_semantic_tree(9));
50  // result.push_back(build_semantic_tree_2());
51  result.push_back(build_semantic_tree(3));
52  // result.push_back(build_semantic_tree_3a());
53  // result.push_back(build_semantic_tree_4());
54  result.push_back(build_semantic_tree(5));
55  result.push_back(build_semantic_tree(6));
56  result.push_back(build_semantic_tree(7));
57  result.push_back(build_semantic_tree(8));
58  result.push_back(build_semantic_tree(9));
59  result.push_back(build_semantic_tree(10));
60  result.push_back(build_semantic_tree(11));
61  result.push_back(build_semantic_tree(12));
62  return result;
63 }
64 
65 
66 inline Sentence_sem build_semantic_tree(size_t index)
67 {
69 
71  Sentence_sem result;
72  switch(index)
73  {
74  case 1:
75  e = boost::make_shared<Elaboration_tree>("TABLE");
76  e->elaborate_color("BROWN");
77  e->elaborate_with_relation("FRONT_OF", "COUCH");
78  // e->elaborate_with_relation("SUPPORTS", "SAILBOAT");
79  e->null_elaboration();
80  // e->null_elaboration();
81  // e->elaborate_size("SMALL");
82  // e->null_elaboration();
83 
84  result.example_id = "1";
85  result.caption_id = "14";
86  result.sentence =
87  "In front of the couch is a wood table with a small sailboat "
88  "model on top . ";
89  result.image = "indoor_0021.jpg";
90  result.etree = e;
91  result.parse =
92  "(ROOT (S (NP (DT The) (NN table) ) (VP (VBZ has) "
93  "(NP (NP (DT some) (NNS flowers) ) (PP (IN on) (NP (PRP it) "
94  ") ) ) ) (. .) ) )";
95 
96  return result;
97 
98  case 2:
99  e = boost::make_shared<Elaboration_tree>("TABLE");
100  e->elaborate_size("SMALL");
101  e->elaborate_with_relation("NEXT_TO", "COUCH");
102  e->elaborate_with_relation("SUPPORTS", "LAMP");
103  e->null_elaboration();
104  e->null_elaboration();
105  e->null_elaboration();
106 
107  result.example_id = "2";
108  result.caption_id = "14";
109  result.sentence =
110  "Next to the couch is a small table with a lit lamp on top . ";
111  result.image = "indoor_0021.jpg";
112  result.etree = e;
113  result.parse = "";
114 
115  return result;
116 
117  case 3:
118  // implicitly references "right of" the room
119  // simplifies by only referring to one of the chairs and
120  // one of the benches
121 
122  e = boost::make_shared<Elaboration_tree>("TABLE");
123  e->elaborate_with_relation("CONTAINED_BY_RIGHT", "ROOM");
124  e->elaborate_with_relation("NEAR", "CHAIR");
125  e->elaborate_with_relation("NEAR", "CHAIR");
126  e->elaborate_size("LONG");
127  e->elaborate_color("BROWN");
128  e->null_elaboration();
129  e->elaborate_color("BROWN");
130  e->null_elaboration();
131  e->elaborate_size("LONG");
132  e->null_elaboration();
133 
134  result.example_id = "3";
135  result.caption_id = "33";
136  result.sentence =
137  "One the right is a long wooden table with a wooden chair "
138  "and a long bench around it . ";
139  // "On the right is a long wooden table with two wooden chairs
140  // "and two long benches around it . "
141  result.image = "indoor_0436.jpg";
142  result.etree = e;
143  result.parse =
144  "(ROOT (S (PP (IN On) (NP (DT the) (NN right) ) ) (VP (VBZ is) (NP (NP (DT a) (JJ long) (JJ wooden) (NN table) ) (PP (IN with) (NP (NP (CD two) (JJ wooden) (NNS chairs) ) (CC and) (NP (CD two) ) ) ) ) ) (NP (NP (JJ long) (NNS benches) ) (PP (IN around) (NP (PRP it) ) ) ) (. .) ) )";
145 
146  return result;
147 
148  case 999:
149  // simplifies 3 by removing "right of" the room
150  // simplifies by only referring to one of the chairs and one of the benches
151  e = boost::make_shared<Elaboration_tree>("TABLE");
152  e->elaborate_with_relation("NEAR", "CHAIR");
153  e->elaborate_with_relation("NEAR", "CHAIR");
154  e->elaborate_size("LONG");
155  e->elaborate_color("BROWN");
156  e->null_elaboration();
157  e->elaborate_color("BROWN");
158  e->null_elaboration();
159  e->elaborate_size("LONG");
160  e->null_elaboration();
161 
162  result.example_id = "3a";
163  result.caption_id = "33";
164  result.sentence =
165  "There is a long wooden table with a wooden chair and a "
166  "long bench around it . ";
167  // "On the right is a long wooden table with two wooden chairs "
168  // "and two long benches around it . "
169  result.image = "indoor_0436.jpg";
170  result.etree = e;
171  result.parse = "";
172 
173  return result;
174 
175  case 4:
176  // "In front of the table on the left is a couch where the
177  // front of the couch is facing right . "
178  // Implicitly reference relative to the room: "...on the left..."
179  // Also, removed the "where" clause, which references the "front"
180  // of the couch "facing right"
181 
182  e = boost::make_shared<Elaboration_tree>("COUCH");
183  e->elaborate_with_relation("FRONT_OF", "TABLE");
184  e->null_elaboration();
185  e->elaborate_with_relation("CONTAINED_BY_LEFT", "ROOM");
186 
187  result.example_id = "4";
188  result.caption_id = "36";
189  result.sentence =
190  "In front of the table on the left is a couch . ";
191  result.image = "living-room-modern.jpg";
192  result.etree = e;
193  result.parse = "";
194 
195  return result;
196 
197  case 5:
198  e = boost::make_shared<Elaboration_tree>("TABLE");
199  e->elaborate_with_relation("LEFT_OF", "COUCH");
200  // e->elaborate_with_relation("SUPPORTS", "VASE");
201  // e->elaborate_with_relation("CENTER", "VASE");
202  e->elaborate_color("BLACK");
203  // e->null_elaboration();
204  // e->null_elaboration();
205  // e->elaborate_with_relation("CONTAINS","FLOWERS");
206  // e->null_elaboration();
207  // e->elaborate_color("WHITE");
208 
209  result.example_id = "5";
210  result.caption_id = "36";
211  result.sentence =
212  "To the left of the couch is a black topped table "
213  "with a vase of white flowers on the center .";
214  result.image = "living-room-modern.jpg";
215  result.etree = e;
216  result.parse =
217  "(ROOT (SINV (PP (TO To) (NP (NP (DT the) (NN left) ) (PP (IN of) (NP (DT the) (NN couch) ) ) ) ) (VP (VBZ is) ) (NP (NP (DT a) (JJ black) (VBN topped) (NN table) ) (PP (IN with) (NP (NP (DT a) (NN vase) ) (PP (IN of) (NP (JJ white) (NNS flowers) ) ) ) ) (PP (IN on) (NP (DT the) (NN center) ) ) ) (. .) ) )";
218 
219  return result;
220 
221  case 6:
222  e = boost::make_shared<Elaboration_tree>("TABLE");
223  e->elaborate_with_relation("FRONT_OF", "COUCH");
224  e->elaborate_size("TALL");
225  // e->elaborate_with_relation("SUPPORTS", "CUP");
226 
227  result.example_id = "6";
228  result.caption_id = "36";
229  result.sentence =
230  "In front of the couch is a tall thin stand with a cup on it . ";
231  result.image = "living-room-modern.jpg";
232  result.etree = e;
233  result.parse =
234  "(ROOT (SINV (PP (IN In) (NP (NP (NN front) ) (PP (IN of) (NP (DT the) (NN couch) ) ) ) ) (VP (VBZ is) ) (NP (NP (DT a) (JJ tall) (JJ thin) (NN stand) ) (PP (IN with) (NP (NP (DT a) (NN cup) ) (PP (IN on) (NP (PRP it) ) ) ) ) ) (. .) ) )";
235 
236  return result;
237 
238  case 7:
239  e = boost::make_shared<Elaboration_tree>("CHAIR");
240  e->elaborate_with_relation("FRONT_OF", "BED");
241  e->elaborate_with_relation("NEAR", "TABLE");
242  e->elaborate_with_relation("NEAR", "MIRROR");
243 
244  result.example_id = "7";
245  result.caption_id = "80";
246  result.sentence =
247  "In front of the bed is a chair with a table and mirror . ";
248  result.image = "yellow-bed-room-l.jpg";
249  result.etree = e;
250  result.parse =
251  "(ROOT (SINV (PP (IN In) (NP (NP (NN front) ) (PP (IN of) (NP (DT the) (NN bed) ) ) ) ) (VP (VBZ is) ) (NP (NP (DT a) (NN chair) ) (PP (IN with) (NP (DT a) (NN table) (CC and) (NN mirror) ) ) ) (. .) ) )";
252 
253  return result;
254 
255  case 8:
256  // Another implicit reference spatial relation relative
257  // to the room, or camera, or image
258 
259  e = boost::make_shared<Elaboration_tree>("TABLE");
260  e->elaborate_with_relation("CONTAINED_BY", "ROOM");
261  e->elaborate_color("WHITE");
262 
263  result.example_id = "8";
264  result.caption_id = "83";
265  result.sentence =
266  "There is a table with a white tablecloth "
267  "in the middle of the room . ";
268  result.image = "0000000013.jpg";
269  result.etree = e;
270  result.parse =
271  "(ROOT (S (NP (EX There) ) (VP (VBZ is) (NP (NP (DT a) (NN table) ) (PP (IN with) (NP (NP (DT a) (JJ white) (NN tablecloth) ) (PP (IN in) (NP (NP (DT the) (NN middle) ) (PP (IN of) (NP (DT the) (NN room) ) ) ) ) ) ) ) ) (. .) ) )";
272 
273  return result;
274 
275  case 9:
276  e = boost::make_shared<Elaboration_tree>("TABLE");
277  // e->elaborate_with_relation("SUPPORTS", "FLOWERS");
278 
279  result.example_id = "9";
280  result.caption_id = "83";
281  result.sentence = "The table has some flowers on it.";
282  result.image = "0000000013.jpg";
283  result.etree = e;
284  result.parse =
285  "(ROOT (S (NP (DT The) (NN table) ) (VP (VBZ has) (NP (NP (DT some) (NNS flowers) ) (PP (IN on) (NP (PRP it) ) ) ) ) (. .) ) )";
286 
287  return result;
288 
289  case 10:
290  // lack representation of corner of object (such as the room)
291  // this is something we should add to the Room representation
292 
293  e = boost::make_shared<Elaboration_tree>("ROOM");
294  e->elaborate_with_relation("CONTAINS", "TABLE");
295  e->null_elaboration();
296  e->elaborate_with_relation("SUPPORTS", "LAMP");
297  e->elaborate_color("BROWN");
298 
299  result.example_id = "10";
300  result.caption_id = "78";
301  result.sentence =
302  "A corner of a room with a single wooden table with a lamp on it . ";
303  result.image = "IMG_2435.jpg";
304  result.etree = e;
305  result.parse =
306  "(NP (NP (DT A) (NN corner) ) (PP (IN of) (NP (NP (DT a) (NN room) ) (PP (IN with) (NP (DT a) (JJ single) (JJ wooden) (NN table) ) ) ) ) (PP (IN with) (NP (NP (DT a) (NN lamp) ) (PP (IN on) (NP (PRP it) ) ) ) ) (. .) ) )";
307 
308  return result;
309 
310  case 11:
311  e = boost::make_shared<Elaboration_tree>("BED");
312  e->elaborate_with_relation("CONTAINED_BY", "ROOM");
313 
314  result.example_id = "11";
315  result.caption_id = "88";
316  result.sentence = "In the middle of the room is a bed . ";
317  result.image = "2333_2.jpg";
318  result.etree = e;
319  result.parse =
320  "(SINV (PP (IN In) (NP (NP (DT the) (NN middle) ) (PP (IN of) (NP (DT the) (NN room) ) ) ) ) (VP (VBZ is) ) (NP (DT a) (NN bed) ) (. .) ) )";
321 
322  return result;
323 
324  case 12:
325  // see if we can match while glossing over counts/plurals
326  e = boost::make_shared<Elaboration_tree>("LAMP");
327  e->elaborate_color("GREEN"); // modifies LAMP
328  e->elaborate_with_relation("ABOVE", "COUCH");
329  // e->elaborate_with_relation("NE", "PICTURE");
330 
331  result.example_id = "12";
332  result.caption_id = "704";
333  result.sentence =
334  "Above the couch are two green lamps "
335  "and a keep calm carry on poster .";
336  result.image = "2086268311_4315366940_m.jpg";
337  result.etree = e;
338  result.parse =
339  "(S (S (ADVP (IN Above) ) (NP (DT the) (NN couch) ) (VP (VBP are) (NP (CD two) (JJ green) (NNS lamps) ) ) ) (CC and) (S (NP (DT a) ) (VP (VB keep) (ADJP (JJ calm) (SBAR (S (VP (VBP carry) (PP (IN on) (NP (NN poster) ) ) ) ) ) ) ) ) (. .) ) )";
340 
341  return result;
342  default:
343  return result;
344  }
345 }
346 
347 };
348 
349 #endif
std::string caption_id
Definition: semantic_trees_by_hand.h:22
Definition: semantic_trees_by_hand.h:19
std::string sentence
Definition: semantic_trees_by_hand.h:23
Sentence_sem build_semantic_tree(size_t index)
Definition: semantic_trees_by_hand.h:66
void initialize_semantic_maps()
read in mappings from files, default config path
Definition: Semantic_traits.cpp:53
std::string parse
Definition: semantic_trees_by_hand.h:26
the main "Semantic tree" object
Definition: Elaboration_tree.h:23
std::string image
Definition: semantic_trees_by_hand.h:24
std::string example_id
Definition: semantic_trees_by_hand.h:21
std::vector< Sentence_sem > collect_semantic_trees()
Definition: semantic_trees_by_hand.h:31
boost::shared_ptr< Elaboration_tree > Self_ptr
Definition: Elaboration_tree.h:29
semantics::Elaboration_tree::Self_ptr etree
Definition: semantic_trees_by_hand.h:25