Exemplo n.º 1
0
void
PinyinPhraseLib::optimize_phrase_frequencies (uint32 max_freq)
{
	uint32 freq = m_phrase_lib.get_max_phrase_frequency ();

	if (freq < max_freq || !max_freq) return;

	double ratio = ((double) max_freq) / freq;

	Phrase phrase;
	
	for (int i = 0; i<(int)m_phrase_lib.number_of_phrases (); ++i) {
		phrase = m_phrase_lib.get_phrase_by_index (i);
		phrase.set_frequency ((uint32)(phrase.frequency () * ratio));
	}
}