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

Function test_word_ngrams

dlib/test/feature_hashing.cpp:38–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36// ----------------------------------------------------------------------------------------
37
38 void test_word_ngrams()
39 {
40 const unsigned long num_buckets = 1 << 20;
41 const std::vector<std::string> tokens = {"a", "b", "a", "b"};
42 DLIB_TEST(hash_word_ngrams(tokens, 1, 2, num_buckets) ==
43 expected({"a", "b", "a", "b", "a b", "b a", "a b"}, num_buckets));
44 DLIB_TEST(hash_word_ngrams(tokens, 3, 3, num_buckets) ==
45 expected({"a b a", "b a b"}, num_buckets));
46 DLIB_TEST(hash_word_ngrams(tokens, 5, 6, num_buckets).empty());
47 DLIB_TEST(hash_word_ngrams(std::vector<std::string>(), 1, 2, num_buckets).empty());
48 }
49
50// ----------------------------------------------------------------------------------------
51

Callers 1

perform_testMethod · 0.85

Calls 3

hash_word_ngramsFunction · 0.85
expectedFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected