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

Function test_serialization

dlib/test/tfidf.cpp:194–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192// ----------------------------------------------------------------------------------------
193
194 void test_serialization()
195 {
196 tfidf_transformer<sparse_type> tfidf;
197 tfidf.set_max_vocabulary_size(3);
198 tfidf.use_sublinear_tf(true);
199 tfidf.train(corpus());
200
201 std::ostringstream out;
202 serialize(tfidf, out);
203 tfidf_transformer<sparse_type> copy;
204 std::istringstream in(out.str());
205 deserialize(copy, in);
206
207 DLIB_TEST(copy.max_vocabulary_size() == 3);
208 DLIB_TEST(copy.uses_sublinear_tf());
209 DLIB_TEST(copy.vocabulary() == tfidf.vocabulary());
210 DLIB_TEST(copy.idf() == tfidf.idf());
211 for (const auto& d : corpus())
212 DLIB_TEST(copy(d) == tfidf(d));
213 }
214
215// ----------------------------------------------------------------------------------------
216

Callers 1

perform_testMethod · 0.70

Calls 9

corpusFunction · 0.85
use_sublinear_tfMethod · 0.80
max_vocabulary_sizeMethod · 0.80
uses_sublinear_tfMethod · 0.80
serializeFunction · 0.70
deserializeFunction · 0.70
trainMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected