6 #include <static_bitsequence.h>
7 #include <alphabet_mapper.h>
8 #include <static_sequence.h>
12 int main(int argc, char ** argv) {
14 cout << "usage: " << argv[0] << " <file> <samp>" << endl;
17 struct stat text_info;
18 if(stat(argv[1],&text_info)<0) {
19 cout << "could not stat: " << argv[1] << endl;
28 uint n= (uint)text_info.st_size/4;
29 uint * text = new uint[n+1];
30 FILE * fp = fopen(argv[1],"r");
32 cout << "could not open " << argv[1] << endl;
36 cout << "File: " << argv[1] << endl;
37 cout << "Length: " << n << endl;
40 for(uint i=0;i<n;i++) {
42 uint read=fread(&c,sizeof(uint),1,fp);
46 max_symbol = max(max_symbol,text[i]);
52 /*uint *occ = new uint[max_symbol];
53 for(uint i=0;i<max_symbol;i++)
58 alphabet_mapper * am = new alphabet_mapper_none();
59 static_bitsequence_builder * bmb = new static_bitsequence_builder_rrr02(samp);
60 cout << "Building Huffman table..."; cout.flush();
61 wt_coder * wtc = new wt_coder_huff(text,n,am);
62 cout << "done" << endl; cout.flush();
63 static_sequence * wt = new static_sequence_wvtree(text,n,wtc,bmb,am,true);
66 char * fname = new char[10+string(argv[1]).length()];
67 sprintf(fname,"%s.wt",argv[1]);
68 fp = fopen(fname,"w");
72 fp = fopen(fname,"r");
73 wt = static_sequence::load(fp);
78 cout << "WT Size: " << wt->size() << endl;
79 cout << "ft = " << 1.*wt->size()/(bits(max_symbol-1)*n/8) << endl;