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