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

Function test_integer_counts

dlib/test/tfidf.cpp:170–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168// ----------------------------------------------------------------------------------------
169
170 void test_integer_counts()
171 {
172 using int_sparse_type = std::vector<std::pair<unsigned long,unsigned int>>;
173 static_assert(std::is_same_v<tfidf_transformer<int_sparse_type>::scalar_type, double>);
174 std::vector<int_sparse_type> documents;
175 for (const auto& d : corpus())
176 documents.emplace_back(d.begin(), d.end());
177
178 tfidf_transformer<int_sparse_type> by_int;
179 tfidf_transformer<sparse_type> by_double;
180 by_int.use_sublinear_tf(true);
181 by_double.use_sublinear_tf(true);
182 by_int.train(documents);
183 by_double.train(corpus());
184 DLIB_TEST(by_int.vocabulary() == by_double.vocabulary());
185 DLIB_TEST(by_int.idf() == by_double.idf());
186 for (unsigned long i = 0; i < documents.size(); ++i)
187 {
188 DLIB_TEST(by_int(documents[i]) == by_double(corpus()[i]));
189 }
190 }
191
192// ----------------------------------------------------------------------------------------
193

Callers 1

perform_testMethod · 0.85

Calls 7

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

Tested by

no test coverage detected