int unk_replace_probability(Index word_idx)
 {
     if (word_idx == UNK) return UNK; // UNK is not in freq_records
     assert(static_cast<unsigned>(word_idx) < freq_records.size());
     if (freq_records[word_idx] <= freq_threshold && prob_rand() <= prob_threshold) return UNK;
     return word_idx;
 }
Пример #2
0
int
rand_range(int min, int max)
{
  return ( (int) (prob_rand() * (double)(max - min) + (double)min) );
}