1 // Test driver for text collection
6 #include "TextCollection.h"
7 using SXSI::TextCollection;
9 void printDocumentResult(TextCollection::document_result dr)
11 TextCollection::document_result::iterator it;
12 printf("document result:");
13 for (it = dr.begin(); it != dr.end(); ++it)
19 void printFullResult(TextCollection::full_result fr)
21 TextCollection::full_result::iterator it;
22 printf("full result:");
23 for (it = fr.begin(); it != fr.end(); ++it)
24 printf(" (%i, %lu)", (*it).first, (*it).second);
31 uchar *text = (uchar*) "acabab";
32 TextCollection *csa = TextCollection::InitTextCollection(1);
33 csa->InsertText(text);
34 text = (uchar*) "abaca";
35 csa->InsertText(text);
36 text = (uchar*) "abacb";
37 csa->InsertText(text);
41 text = csa->GetText(0);
42 cout << "Text 0: \"" << text << "\"" << endl;
44 text = csa->GetText(1);
45 cout << "Text 1: \"" << text << "\"" << endl;
47 text = csa->GetText(2);
48 cout << "Text 2: \"" << text << "\"" << endl;
51 text = csa->GetText(2, 2, 4);
52 cout << "Substring of Text 3: \"" << text << "\"" << endl;
55 printf("n:o contains: %u\n", csa->CountContains((uchar *)"ac"));
56 printf("n:o suffix: %u\n", csa->CountSuffix((uchar *)"b"));
57 printf("n:o equal: %u\n", csa->CountEqual((uchar *)"acabab"));
58 printf("is equal: %u\n", csa->IsEqual((uchar *)"abacb"));
60 TextCollection::document_result dr;
61 dr = csa->Contains((uchar*)"ab");
62 printDocumentResult(dr);
64 TextCollection::full_result fr;
65 fr = csa->FullContains((uchar *)"ab");