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

Function test_map_samples

dlib/test/tfidf.cpp:150–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148// ----------------------------------------------------------------------------------------
149
150 void test_map_samples()
151 {
152 using map_type = std::map<unsigned long,double>;
153 std::vector<map_type> documents;
154 for (const auto& d : corpus())
155 documents.emplace_back(d.begin(), d.end());
156
157 tfidf_transformer<map_type> by_map;
158 tfidf_transformer<sparse_type> by_vector;
159 by_map.train(documents);
160 by_vector.train(corpus());
161 DLIB_TEST(by_map.vocabulary() == by_vector.vocabulary());
162 for (unsigned long i = 0; i < documents.size(); ++i)
163 {
164 DLIB_TEST(by_map(documents[i]) == by_vector(corpus()[i]));
165 }
166 }
167
168// ----------------------------------------------------------------------------------------
169

Callers 1

perform_testMethod · 0.85

Calls 6

corpusFunction · 0.85
emplace_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
trainMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected