/** * <EN> * If multiple instances defined from init, remove initial one (id=0) * </EN> * <JA> * 複数インスタンスが定義されている場合、初期インスタンス(id=0)は * 無効なので消す. * </JA> * * @param jconf [i/o] global configuration instance * * @callgraph * @callergraph * @ingroup jconf */ static void j_config_remove_initial(Jconf *jconf) { JCONF_AM *am; JCONF_LM *lm; JCONF_SEARCH *s; if(jconf->am_root->next != NULL && jconf->am_root->id == 0) { am = jconf->am_root->next; /*free(jconf->am_root);*/ j_jconf_am_free(jconf->am_root); jconf->am_root = am; } if(jconf->lm_root->next != NULL && jconf->lm_root->id == 0) { lm = jconf->lm_root->next; /*free(jconf->lm_root);*/ j_jconf_lm_free(jconf->lm_root); jconf->lm_root = lm; } if(jconf->search_root->next != NULL && jconf->search_root->id == 0) { s = jconf->search_root->next; /*free(jconf->search_root);*/ j_jconf_search_free(jconf->search_root); jconf->search_root = s; } }
/** * <EN> * Remove an LM process instance. * The specified lm conf will also be released and destroyed * inside this function. * </EN> * <JA> * 言語モデルインスタンスを削除する. * 指定された言語モデル設定もこの関数内で解放・削除される. * </JA> * * @param recog [in] engine instance * @param lmconf [in] LM configuration corresponding to the target * LM process to remove * * @return TRUE on success, or FALSE on failure. * * @callgraph * @callergraph * @ingroup jfunc_process */ boolean j_process_lm_remove(Recog *recog, JCONF_LM *lmconf) { RecogProcess *r; PROCESS_LM *lm, *lm_prev; JCONF_LM *l, *l_prev; if (lmconf == NULL) { jlog("ERROR: j_process_lm_remove: lmconf == NULL\n"); return FALSE; } /* check if still used by a process */ for(r=recog->process_list; r; r=r->next) { if (r->config->lmconf == lmconf) { jlog("ERROR: j_process_lm_remove: specified lmconf %02d %s still used in a recogprocess %02d %s\n", lmconf->id, lmconf->name, r->config->id, r->config->name); return FALSE; } } /* find corresponding LM process in engine and remove it from list */ lm_prev = NULL; for(lm=recog->lmlist; lm; lm=lm->next) { if (lm->config == lmconf) { if (lm_prev == NULL) { recog->lmlist = lm->next; } else { lm_prev->next = lm->next; } break; } lm_prev = lm; } if (!lm) { jlog("ERROR: j_process_lm_remove: specified lmconf %02d %s not found in LM process, removal failed\n", lmconf->id, lmconf->name); return FALSE; } /* remove config from list in engine */ l_prev = NULL; for(l=recog->jconf->lm_root; l; l=l->next) { if (l == lmconf) { if (l_prev == NULL) { recog->jconf->lm_root = l->next; } else { l_prev->next = l->next; } break; } l_prev = l; } if (!l) { jlog("ERROR: j_process_lm_remove: lmconf %02d %s not found\n", lmconf->id, lmconf->name); return FALSE; } /* free them */ j_process_lm_free(lm); if (verbose_flag) jlog("STAT: LM process %02d %s removed\n", lmconf->id, lmconf->name); j_jconf_lm_free(lmconf); /* tell engine to update */ recog->process_want_reload = TRUE; return TRUE; }