// Generate Transactions and Taxonomy // void gen_taxrules(TaxPar &par) { Taxonomy *tax; StringSet *lits; StringSetIter *patterns; Transaction *trans; poisson_distribution<LINT> tlen(par.tlen - 1); ofstream data_fp; ofstream pat_fp; ofstream tax_fp; data_fp.open(data_file, ios::trunc); pat_fp.open(pat_file, ios::trunc); tax_fp.open(tax_file, ios::trunc); if (data_fp.fail() || pat_fp.fail() || tax_fp.fail()) { cerr << "Error opening output file" << endl; exit(1); } // generate taxonomy and write it to file tax = new Taxonomy(par.nitems, par.nroots, par.fanout, par.depth_ratio); if (par.ascii) tax->write_asc(tax_fp); else tax->write(tax_fp); lits = new StringSet(par.nitems, par.lits, tax); par.write(pat_fp); lits->display(pat_fp); patterns = new StringSetIter(*lits); for (LINT i = 0; i < par.ntrans; i ++) { trans = mk_tran(*patterns, tlen(generator) + 1, tax); if (par.ascii) trans->write_asc(data_fp); else trans->write(data_fp); delete trans; delete trans; } data_fp.close(); pat_fp.close(); tax_fp.close(); }
// Generate Transactions and Taxonomy // void gen_taxrules(TaxPar &par) { Taxonomy *tax; StringSet *lits; StringSetIter *patterns; Transaction *trans; PoissonDist *tlen; ofstream data_fp; ofstream pat_fp; ofstream tax_fp; ofstream conf_fp; //added by MJZaki data_fp.open(data_file); pat_fp.open(pat_file); tax_fp.open(tax_file); conf_fp.open(conf_file); //added by MJZaki if (data_fp.fail() || pat_fp.fail() || tax_fp.fail() || conf_fp.fail()) { cerr << "Error opening output file" << endl; exit(1); } // generate taxonomy and write it to file tax = new Taxonomy(par.nitems, par.nroots, par.fanout, par.depth_ratio); if (par.ascii) tax->write_asc(tax_fp); else tax->write(tax_fp); tlen = new PoissonDist(par.tlen - 1); lits = new StringSet(par.nitems, par.lits, tax); par.write(pat_fp); lits->display(pat_fp); patterns = new StringSetIter(*lits); LINT NTRANS = 0; for (LINT i = 0; i < par.ntrans; i++) { trans = mk_tran(*patterns, (*tlen)() + 1, par.lits.npats, tax); if (par.ascii) trans->write_asc(data_fp); else trans->write(data_fp); if (trans->size() > 0) NTRANS++;//added by MJZaki: repeat if trans empty else i--; delete trans; } data_fp.close(); pat_fp.close(); tax_fp.close(); //added by MJZaki if (par.ascii) { conf_fp << NTRANS << "\n"; conf_fp << par.nitems << "\n"; conf_fp << par.tlen << "\n"; } else { conf_fp.write((char *) &NTRANS, sizeof(LINT)); conf_fp.write((char *) &par.nitems, sizeof(LINT)); int t = (int) par.tlen; conf_fp.write((char *) &t, sizeof(LINT)); } conf_fp.close(); }