1 /* ñ¸ì¤ÎÉÑÅÙ¤ò·×»»¤¹¤ë */
6 count_nr_words(struct yomi_entry_list *yl)
10 for (ye = yl->head; ye; ye = ye->next) {
16 static struct word_entry **
17 make_word_array(struct yomi_entry_list *yl, int nr)
19 struct word_entry **array = malloc(sizeof(struct word_entry *) *
22 struct yomi_entry *ye;
23 for (ye = yl->head; ye; ye = ye->next) {
25 for (i = 0; i < ye->nr_entries; i++) {
26 array[nth] = &ye->entries[i];
33 /** qsortÍѤÎÈæ³Ó´Ø¿ô */
35 compare_word_entry_by_freq(const void *p1, const void *p2)
37 const struct word_entry * const *e1 = p1;
38 const struct word_entry * const *e2 = p2;
39 return abs((*e2)->raw_freq) - abs((*e1)->raw_freq);
43 set_freq(struct word_entry **array, int nr)
46 int percent = nr / 100;
47 for (i = 0; i < nr; i++) {
48 struct word_entry *we = array[i];
49 we->freq = 99 - (i / percent);
54 we->freq -= we->source_order;
55 if (we->raw_freq < 0) {
62 calc_freq(struct yomi_entry_list *yl)
65 struct word_entry **we;
67 nr = count_nr_words(yl);
68 we = make_word_array(yl, nr);
71 sizeof(struct word_entry *),
72 compare_word_entry_by_freq);