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);
40 // FILE *pFile = fopen ( "mysave.txt" , "rb" );
43 text = csa->GetText(0);
44 cout << "Text 0: \"" << text << "\"" << endl;
46 text = csa->GetText(1);
47 cout << "Text 1: \"" << text << "\"" << endl;
49 text = csa->GetText(2);
50 cout << "Text 2: \"" << text << "\"" << endl;
53 text = csa->GetText(2, 2, 4);
54 cout << "Substring of Text 3: \"" << text << "\"" << endl;
57 printf("n:o contains: %u\n", csa->CountContains((uchar *)"ac"));
58 printf("n:o suffix: %u\n", csa->CountSuffix((uchar *)"b"));
59 printf("n:o equal: %u\n", csa->CountEqual((uchar *)"acabab"));
60 printf("is equal: %u\n", csa->IsEqual((uchar *)"abacb"));
62 TextCollection::document_result dr;
63 dr = csa->Contains((uchar*)"ab");
64 printDocumentResult(dr);
66 TextCollection::full_result fr;
67 fr = csa->FullContains((uchar *)"ab");
70 // FILE *pFile2 = fopen ( "mysave.txt" , "wb" );