int main(int argc, const char* argv[]) { gmp_randstate_t state; data_arr source; mpz_t seed; uint32_t min, max, n; mpz_init(seed); parse_input(argc, argv, seed, &min, &max); gmp_randinit_default(state); gmp_randseed(state, seed); n = rand_range(state, min, max); fprintf(stderr, "%u\n",n); source = make_array(n); generate_random_arr(n, source, state); fprint_array(stdout, source, n); gmp_randclear(state); delete_array(source, n); mpz_clear(seed); return 0; }
void Trainer::InitIOTable() { int count=e_dim*e_dim*c_dim*c_dim; this->ptable = new TableCell[count]; //init the table with phrase translation probability for(int espan=0;espan<=this->elen;espan++) { for(int estart=0;estart<=this->elen-espan;estart++) { int eend=estart+espan; vector<WORDTYPE> ephrase; //get the ch phrase according to the ch span index this->training_pair->GetEPhrase(estart,eend,ephrase); for(int cspan=0;cspan<=this->clen;cspan++) { if(espan==0 && cspan==0) continue; for(int cstart=0;cstart<=this->clen-cspan;cstart++) { int cend=cstart+cspan; int index=this->GetArrayIndex(estart,eend,cstart,cend); if(pruning && pindicate_table[index]>this->conflict_link) { continue; } //get the eng phrase according to the eng span index vector<WORDTYPE> cphrase; this->training_pair->GetCPhrase(cstart,cend,cphrase); //how to deal with if we can't find the proper rule ? Rule* rule = this->grammar.GetPhrase2PhraseRule(ephrase,cphrase); if(rule && rule->prob>0) { this->Increase_inside(index,rule->left,rule->prob); if (this->debug_level >= 3) { fprintf(Loger::logfile, "prob[%d,%d,%d,%d] = %.2g\n",estart,eend,cstart,cend,rule->prob); fprintf(Loger::logfile, " en = "); fprint_array(Loger::logfile,ephrase); fprintf(Loger::logfile, "\n"); fprintf(Loger::logfile, " cn = "); fprint_array(Loger::logfile, cphrase); fprintf(Loger::logfile, "\n"); fflush(Loger::logfile); } } } } } } //init the out-side probability this->Increase_outside(0,elen,0,clen,grammar.start_symbol,1.0); }