MCPcopy Create free account
hub / github.com/catboost/catboost / TestPhraseSearch

Method TestPhraseSearch

library/cpp/containers/comptrie/comptrie_ut.cpp:563–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561}
562
563void TCompactTrieTest::TestPhraseSearch() {
564 static const char* phrases[] = {"ab", "ab cd", "ab cd ef"};
565 static const char* const goodphrase = "ab cd ef gh";
566 static const char* const badphrase = "cd ef gh ab";
567 TBufferOutput bufout;
568
569 TCompactTrieBuilder<char> builder;
570 for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) {
571 builder.Add(phrases[i], strlen(phrases[i]), i);
572 }
573 builder.Save(bufout);
574
575 TCompactTrie<char> trie(bufout.Buffer().Data(), bufout.Buffer().Size());
576 TVector<TCompactTrie<char>::TPhraseMatch> matches;
577 trie.FindPhrases(goodphrase, strlen(goodphrase), matches);
578
579 UNIT_ASSERT(matches.size() == Y_ARRAY_SIZE(phrases));
580 for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) {
581 UNIT_ASSERT(matches[i].first == strlen(phrases[i]));
582 UNIT_ASSERT(matches[i].second == i);
583 }
584
585 trie.FindPhrases(badphrase, strlen(badphrase), matches);
586 UNIT_ASSERT(matches.size() == 0);
587}
588
589void TCompactTrieTest::TestAddGet() {
590 TCompactTrieBuilder<char> builder;

Callers

nothing calls this directly

Calls 6

AddMethod · 0.45
SaveMethod · 0.45
DataMethod · 0.45
SizeMethod · 0.45
FindPhrasesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected