| 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 |
no test coverage detected