ZGen  0.2.0
a linearization system for natural language.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fixture1.h
Go to the documentation of this file.
1 #ifndef __ZGEN_UNITTEST_BESTFIRST_FIXTURE_1_H__
2 #define __ZGEN_UNITTEST_BESTFIRST_FIXTURE_1_H__
3 
4 #include "engine/engine.h"
5 #include "types/instance.h"
6 #include "utils/ioutils.h"
9 
10 struct Fixture1 {
12  : allocator(127, 128) {
13  namespace z = ZGen;
14  namespace io = ZGen::IO;
15  namespace bf = ZGen::BestFirst;
16 
17  std::stringstream S;
18  S << "__00_01__ NP 4 N" << std::endl
19  << "1 NP 2 N" << std::endl
20  << "2 VBZ 4 N" << std::endl
21  << "3 NNS 2 N" << std::endl
22  << "4 VBZ -1 N" << std::endl
23  << "5 JJ 6 N" << std::endl
24  << "6 NN 4 N" << std::endl
25  << "7 NP 4 N" << std::endl
26  << "8 CD 7 N" << std::endl
27  ;
28 
30 
31  const z::dependency_t* inst = &data[0];
32  bf::Span* span_0 = allocator.malloc(); span_0->init(inst, 0, inst->postag(0));
33  bf::Span* span_1 = allocator.malloc(); span_1->init(inst, 1, inst->postag(1));
34  bf::Span* span_2 = allocator.malloc(); span_2->init(inst, 2, inst->postag(2));
35  bf::Span* span_3 = allocator.malloc(); span_3->init(inst, 3, inst->postag(3));
36  bf::Span* span_4 = allocator.malloc(); span_4->init(inst, 4, inst->postag(4));
37  bf::Span* span_5 = allocator.malloc(); span_5->init(inst, 5, inst->postag(5));
38  bf::Span* span_6 = allocator.malloc(); span_6->init(inst, 6, inst->postag(6));
39  bf::Span* span_7 = allocator.malloc(); span_7->init(inst, 7, inst->postag(7));
40  bf::Span* span_8 = allocator.malloc(); span_8->init(inst, 8, inst->postag(8));
41 
42  bf::Span* span_1_2_3 = allocator.malloc();
43  span_1_2_3->copy(span_2);
44  span_1_2_3->link_left(span_1);
45  span_1_2_3->link_right(span_3);
46 
47  bf::Span* span_5_6 = allocator.malloc();
48  span_5_6->copy(span_6);
49  span_5_6->link_left(span_5);
50 
51  bf::Span* span_7_8 = allocator.malloc();
52  span_7_8->copy(span_7);
53  span_7_8->link_right(span_8);
54 
55  root = allocator.malloc();
56  root->copy(span_4);
57  root->link_left(span_1_2_3);
58  root->link_left(span_0);
59  root->link_right(span_5_6);
60  root->link_right(span_7_8);
61  }
62 
65  std::vector<ZGen::dependency_t> data;
66 };
67 
68 #endif // end for __ZGEN_UNITTEST_BESTFIRST_FIXTURE_1_H__
bool link_left(const Span *modifier)
Definition: span.cc:59
Definition: fixture1.h:10
DependencyParse dependency_t
Definition: instance.h:70
void copy(const Span *other)
Definition: span.cc:25
int read_dependency_dataset(std::istream &is, std::vector< dependency_t > &data)
Definition: ioutils.cc:69
void init(const dependency_t *ref, int root_id, postag_t tag)
Definition: span.cc:14
Fixture1()
Definition: fixture1.h:11
bool link_right(const Span *modifier)
Definition: span.cc:70
ZGen::BestFirst::Span * root
Definition: fixture1.h:63
Span * malloc()
Definition: span_allocator.cc:30
std::vector< ZGen::dependency_t > data
Definition: fixture1.h:65
ZGen::BestFirst::SpanAllocator allocator
Definition: fixture1.h:64
Definition: span_allocator.h:27
Definition: span.h:13