MCPcopy Create free account
hub / github.com/davisking/dlib / dotest1

Function dotest1

dlib/test/parse.cpp:61–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59// ----------------------------------------------------------------------------------------
60
61 void dotest1()
62 {
63 print_spinner();
64 dlog << LINFO << "in dotest1()";
65
66 std::vector<std::string> words;
67 std::vector<tags> sequence;
68 for (int i = 0; i < 8; ++i)
69 {
70 sequence.push_back(DET);
71 sequence.push_back(N);
72 sequence.push_back(V);
73 sequence.push_back(DET);
74 sequence.push_back(N);
75 sequence.push_back(A);
76
77 words.push_back("The");
78 words.push_back("flight");
79 words.push_back("includes");
80 words.push_back("a");
81 words.push_back("meal");
82 words.push_back("AWORD");
83 }
84
85 std::vector<parse_tree_element<tags> > parse_tree;
86
87 find_max_parse_cky(sequence, user_defined_ruleset<true>, parse_tree);
88 DLIB_TEST(parse_tree.size() != 0);
89
90
91 std::vector<unsigned long> roots;
92 find_trees_not_rooted_with_tag(parse_tree, G, roots);
93 DLIB_TEST(roots.size() == 8);
94
95 for (unsigned long i = 0; i < roots.size(); ++i)
96 {
97 dlog << LINFO << parse_tree_to_string(parse_tree, words, roots[i]);
98 DLIB_TEST(parse_tree_to_string(parse_tree, words, roots[i]) == "[[The flight] [[includes [a meal]] AWORD]]");
99 dlog << LINFO << parse_tree_to_string_tagged(parse_tree, words, roots[i]);
100 DLIB_TEST(parse_tree_to_string_tagged(parse_tree, words, roots[i]) == "[5 [3 The flight] [4 [4 includes [3 a meal]] AWORD]]");
101 }
102
103
104 words.clear();
105 sequence.clear();
106
107 for (int i = 0; i < 2; ++i)
108 {
109 sequence.push_back(DET);
110 sequence.push_back(N);
111 sequence.push_back(V);
112 sequence.push_back(DET);
113 sequence.push_back(N);
114
115 words.push_back("The");
116 words.push_back("flight");
117 words.push_back("includes");
118 words.push_back("a");

Callers 1

perform_testMethod · 0.70

Calls 10

print_spinnerFunction · 0.85
find_max_parse_ckyFunction · 0.85
parse_tree_to_stringFunction · 0.85
parse_trees_to_stringFunction · 0.85
push_backMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected