[Julius-cvs 582] CVS update: julius4/libjulius/src

アーカイブの一覧に戻る

sumom****@users***** sumom****@users*****
2011年 2月 5日 (土) 18:00:41 JST


Index: julius4/libjulius/src/default.c
diff -u julius4/libjulius/src/default.c:1.10 julius4/libjulius/src/default.c:1.11
--- julius4/libjulius/src/default.c:1.10	Tue Feb 10 17:15:48 2009
+++ julius4/libjulius/src/default.c	Sat Feb  5 18:00:41 2011
@@ -17,7 +17,7 @@
  * @author Akinobu Lee
  * @date   Fri Feb 16 15:05:43 2007
  *
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
  * 
  */
 /*
@@ -194,6 +194,8 @@
   strcpy(j->wordrecog_tail_silence_model_name, "silE");
   j->wordrecog_silence_context_name[0] = '\0';
   strcpy(j->unknown_name, UNK_WORD_DEFAULT); // or UNK_WORD_DEFAULT2
+  j->additional_dict_files		= NULL;
+  j->additional_dict_entries		= NULL;
 }
 
 /** 
Index: julius4/libjulius/src/instance.c
diff -u julius4/libjulius/src/instance.c:1.4 julius4/libjulius/src/instance.c:1.5
--- julius4/libjulius/src/instance.c:1.4	Sat Jul  4 23:11:42 2009
+++ julius4/libjulius/src/instance.c	Sat Feb  5 18:00:41 2011
@@ -12,7 +12,7 @@
  * @author Akinobu Lee
  * @date   Sun Oct 28 18:06:20 2007
  *
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
  * 
  */
 /*
@@ -457,6 +457,21 @@
 void
 j_jconf_lm_free(JCONF_LM *lmconf)
 {
+  JCONF_LM_NAMELIST *nl, *nltmp;
+  nl = lmconf->additional_dict_files;
+  while (nl) {
+    nltmp = nl->next;
+    free(nl->name);
+    free(nl);
+    nl = nltmp;
+  }
+  nl = lmconf->additional_dict_entries;
+  while (nl) {
+    nltmp = nl->next;
+    free(nl->name);
+    free(nl);
+    nl = nltmp;
+  }
   free(lmconf);
 }
 
Index: julius4/libjulius/src/jfunc.c
diff -u julius4/libjulius/src/jfunc.c:1.6 julius4/libjulius/src/jfunc.c:1.7
--- julius4/libjulius/src/jfunc.c:1.6	Wed Mar 18 16:05:30 2009
+++ julius4/libjulius/src/jfunc.c	Sat Feb  5 18:00:41 2011
@@ -19,7 +19,7 @@
  * @author Akinobu Lee
  * @date   Wed Aug  8 15:04:28 2007
  *
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
  * 
  */
 /*
@@ -315,36 +315,26 @@
 
 /** 
  * <EN>
- * Load parameters from command argments, and set to each configuration
- * instances in jconf.
+ * If multiple instances defined from init, remove initial one (id=0)
  * </EN>
  * <JA>
- * コマンド引数からパラメータを読み込み,jconf 内の各設定インスタンスに
- * 値を格納する. 
+ * 複数インスタンスが定義されている場合、初期インスタンス(id=0)は
+ * 無効なので消す. 
  * </JA>
  * 
  * @param jconf [i/o] global configuration instance
- * @param argc [in] number of arguments
- * @param argv [in] list of argument strings
- * 
- * @return 0 on success, or -1 on failure.
  * 
  * @callgraph
  * @callergraph
  * @ingroup jconf
  */
-int
-j_config_load_args(Jconf *jconf, int argc, char *argv[])
+static void
+j_config_remove_initial(Jconf *jconf)
 {
   JCONF_AM *am;
   JCONF_LM *lm;
   JCONF_SEARCH *s;
 
-  /* parse options and set variables */
-  if (opt_parse(argc, argv, NULL, jconf) == FALSE) {
-    return -1;
-  }
-  /* if multiple instances defined from init, remove initial one (id=0) */
   if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {
     am = jconf->am_root->next;
     free(jconf->am_root);
@@ -360,6 +350,74 @@
     free(jconf->search_root);
     jconf->search_root = s;
   }
+}
+
+/** 
+ * <EN>
+ * Load parameters from command argments, and set to each configuration
+ * instances in jconf.
+ * </EN>
+ * <JA>
+ * コマンド引数からパラメータを読み込み,jconf 内の各設定インスタンスに
+ * 値を格納する. 
+ * </JA>
+ * 
+ * @param jconf [i/o] global configuration instance
+ * @param argc [in] number of arguments
+ * @param argv [in] list of argument strings
+ * 
+ * @return 0 on success, or -1 on failure.
+ * 
+ * @callgraph
+ * @callergraph
+ * @ingroup jconf
+ */
+int
+j_config_load_args(Jconf *jconf, int argc, char *argv[])
+{
+  /* parse options and set variables */
+  if (opt_parse(argc, argv, NULL, jconf) == FALSE) {
+    return -1;
+  }
+  /* if multiple instances defined from init, remove initial one (id=0) */
+  j_config_remove_initial(jconf);
+
+  return 0;
+}
+
+/** 
+ * <EN>
+ * Load parameters from command argment string, and set to each configuration
+ * instances in jconf.
+ * </EN>
+ * <JA>
+ * コマンド引数を含む文字列からパラメータを読み込み,jconf 内の各設定インスタンスに
+ * 値を格納する. 
+ * </JA>
+ * 
+ * @param jconf [i/o] global configuration instance
+ * @param argstr [in] argument string
+ * 
+ * @return 0 on success, or -1 on failure.
+ * 
+ * @callgraph
+ * @callergraph
+ * @ingroup jconf
+ */
+int
+j_config_load_string(Jconf *jconf, char *string)
+{
+  int argc;
+  char **argv;
+  char *buf;
+  
+  /* parse options and set variables */
+  if (config_string_parse(string, jconf) == FALSE) {
+    return -1;
+  }
+  /* if multiple instances defined from init, remove initial one (id=0) */
+  j_config_remove_initial(jconf);
+
   return 0;
 }
 
@@ -385,30 +443,13 @@
 int
 j_config_load_file(Jconf *jconf, char *filename)
 {
-  JCONF_AM *am;
-  JCONF_LM *lm;
-  JCONF_SEARCH *s;
-
   /* parse options and set variables */
   if (config_file_parse(filename, jconf) == FALSE) {
     return -1;
   }
   /* if multiple instances defined from init, remove initial one (id=0) */
-  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {
-    am = jconf->am_root->next;
-    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);
-    jconf->lm_root = lm;
-  }
-  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {
-    s = jconf->search_root->next;
-    free(jconf->search_root);
-    jconf->search_root = s;
-  }
+  j_config_remove_initial(jconf);
+
   return 0;
 }
 
@@ -435,32 +476,11 @@
 j_config_load_args_new(int argc, char *argv[])
 {
   Jconf *jconf;
-  JCONF_AM *am;
-  JCONF_LM *lm;
-  JCONF_SEARCH *s;
-
   jconf = j_jconf_new();
-  /* parse options and set variables */
-  if (opt_parse(argc, argv, NULL, jconf) == FALSE) {
+  if (j_config_load_args(jconf, argc, argv) == -1) {
     j_jconf_free(jconf);
     return NULL;
   }
-  /* if multiple instances defined from init, remove initial one (id=0) */
-  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {
-    am = jconf->am_root->next;
-    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);
-    jconf->lm_root = lm;
-  }
-  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {
-    s = jconf->search_root->next;
-    free(jconf->search_root);
-    jconf->search_root = s;
-  }
   return jconf;
 }
 
@@ -486,37 +506,108 @@
 j_config_load_file_new(char *filename)
 {
   Jconf *jconf;
-  JCONF_AM *am;
-  JCONF_LM *lm;
-  JCONF_SEARCH *s;
-
   jconf = j_jconf_new();
-  /* parse options and set variables */
-  if (config_file_parse(filename, jconf) == FALSE) {
+  if (j_config_load_file(jconf, filename) == -1) {
     j_jconf_free(jconf);
     return NULL;
   }
-  /* if multiple instances defined from init, remove initial one (id=0) */
-  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {
-    am = jconf->am_root->next;
-    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);
-    jconf->lm_root = lm;
-  }
-  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {
-    s = jconf->search_root->next;
-    free(jconf->search_root);
-    jconf->search_root = s;
+  return jconf;
+}
+
+/** 
+ * <EN>
+ * Create a new configuration instance and load parameters from string
+ * file.
+ * </EN>
+ * <JA>
+ * 新たな設定インスタンスを割り付け,そこに
+ * 文字列から設定パラメータを読み込んで返す. 
+ * </JA>
+ * 
+ * @param string [in] option string
+ * 
+ * @return the newly allocated global configuration instance.
+ * 
+ * @callgraph
+ * @callergraph
+ * @ingroup jconf
+ */
+Jconf *
+j_config_load_string_new(char *string)
+{
+  Jconf *jconf;
+  jconf = j_jconf_new();
+  if (j_config_load_string(jconf, string) == -1) {
+    j_jconf_free(jconf);
+    return NULL;
   }
   return jconf;
 }
 
 /** 
  * <EN>
+ * Book to read an additional dictionary file to be read.
+ * when called multiple times, all the file name will be stored and read.
+ * The file will be read just after the normal dictionary at startup.
+ * </EN>
+ * <JA>
+ * 追加辞書ファイルの読み込みを指定する.
+ * 複数回呼ばれた場合、すべて読み込まれる。
+ * 指定された辞書は起動時に通常の辞書のあとに続けて読み込まれる.
+ * </JA>
+ *
+ * @param lm [i/o] a LM configuration
+ * @param dictfile [in] dictinoary file name
+ * 
+ * @return the newly allocated global configuration instance.
+ * 
+ * @callgraph
+ * @callergraph
+ * @ingroup jconf
+ */
+void
+j_add_dict(JCONF_LM *lm, char *dictfile)
+{
+  JCONF_LM_NAMELIST *nl;
+  nl = (JCONF_LM_NAMELIST *)mymalloc(sizeof(JCONF_LM_NAMELIST));
+  nl->name = (char *)mymalloc(strlen(dictfile) + 1);
+  strcpy(nl->name, dictfile);
+  nl->next = lm->additional_dict_files;
+  lm->additional_dict_files = nl;
+}
+
+/** 
+ * <EN>
+ * Add an additional word entry.
+ * The string should contain a word entry in as the same format as dictionary.
+ * If called multiple times, all the specified words will be appended.
+ * </EN>
+ * <JA>
+ * 追加の単語エントリを指定する.
+ * 内容は辞書ファイルと同じフォーマット.
+ * 起動までに複数回呼ばれた場合、そのすべてが起動時に追加される.
+ * </JA>
+ *
+ * @param lm [i/o] a LM configuration
+ * @param wordentry [in] word entry string in dictionary format
+ * 
+ * @callgraph
+ * @callergraph
+ * @ingroup jconf
+ */
+void
+j_add_word(JCONF_LM *lm, char *wordentry)
+{
+  JCONF_LM_NAMELIST *nl;
+  nl = (JCONF_LM_NAMELIST *)mymalloc(sizeof(JCONF_LM_NAMELIST));
+  nl->name = (char *)mymalloc(strlen(wordentry) + 1);
+  strcpy(nl->name, wordentry);
+  nl->next = lm->additional_dict_entries;
+  lm->additional_dict_entries = nl;
+}
+
+/** 
+ * <EN>
  * Initialize and setup A/D-in device specified by the configuration
  * for recognition.  When threading is enabled for the device,
  * A/D-in thread will start inside this function.
Index: julius4/libjulius/src/m_fusion.c
diff -u julius4/libjulius/src/m_fusion.c:1.14 julius4/libjulius/src/m_fusion.c:1.15
--- julius4/libjulius/src/m_fusion.c:1.14	Sat Jul  4 23:11:42 2009
+++ julius4/libjulius/src/m_fusion.c	Sat Feb  5 18:00:41 2011
@@ -20,7 +20,7 @@
  * @author Akinobu Lee
  * @date   Thu May 12 13:31:47 2005
  *
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
  * 
  */
 /*
@@ -302,6 +302,49 @@
     return NULL;
   }
 
+  /* load additional entries */
+  JCONF_LM_NAMELIST *nl;
+  char buf[MAXLINELEN];
+  int n;
+  for (nl = lmconf->additional_dict_files; nl; nl=nl->next) {
+    FILE *fp;
+    if ((fp = fopen(nl->name, "rb")) == NULL) {
+      jlog("ERROR: m_fusion: failed to open %s\n",nl->name);
+      word_info_free(winfo);
+      return NULL;
+    }
+    n = winfo->num;
+    while (getl_fp(buf, MAXLINELEN, fp) != NULL) {
+      if (voca_load_line(buf, winfo, hmminfo) == FALSE) break;
+    }
+    if (voca_load_end(winfo) == FALSE) {
+      jlog("ERROR: m_fusion: failed to read dictionary %s\n", nl->name);
+      fclose(fp);
+      word_info_free(winfo);
+      return NULL;
+    }
+    if (fclose(fp) == -1) {
+      jlog("ERROR: m_fusion: failed to close %s\n", nl->name);
+      word_info_free(winfo);
+      return NULL;
+    }
+    jlog("STAT: + additional dictionary: %s (%d words)\n", nl->name, winfo->num - n);
+  }
+  n = winfo->num;
+  for (nl = lmconf->additional_dict_entries; nl; nl=nl->next) {
+    if (voca_load_line(nl->name, winfo, hmminfo) == FALSE) {
+      jlog("ERROR: m_fusion: failed to set entry: %s\n", nl->name);
+    }
+  }
+  if (lmconf->additional_dict_entries) {
+    if (voca_load_end(winfo) == FALSE) {
+      jlog("ERROR: m_fusion: failed to read additinoal word entry\n");
+      word_info_free(winfo);
+      return NULL;
+    }
+    jlog("STAT: + additional entries: %d words\n", winfo->num - n);
+  }
+
   if (lmconf->lmtype == LM_PROB) {
     /* if necessary, append a IW-sp word to the dict if "-iwspword" specified */
     if (lmconf->enable_iwspword) {
Index: julius4/libjulius/src/m_info.c
diff -u julius4/libjulius/src/m_info.c:1.9 julius4/libjulius/src/m_info.c:1.10
--- julius4/libjulius/src/m_info.c:1.9	Thu Sep 25 14:00:06 2008
+++ julius4/libjulius/src/m_info.c	Sat Feb  5 18:00:41 2011
@@ -12,7 +12,7 @@
  * @author Akinobu Lee
  * @date   Thu May 12 14:14:01 2005
  *
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
  * 
  */
 /*
@@ -434,6 +434,24 @@
       if (lm->config->enable_iwspword) {
 	jlog("\tIW-sp word added to dict= \"%s\"\n", lm->config->iwspentry);
       }
+      if (lm->config->additional_dict_files) {
+	JCONF_LM_NAMELIST *nl;
+	jlog("\tadditional dictionaries:\n");
+	for(nl=lm->config->additional_dict_files;nl;nl=nl->next) {
+	  jlog("\t\t\t%s\n", nl->name);
+	}
+	jlog("\n");
+      }
+      if (lm->config->additional_dict_entries) {
+	JCONF_LM_NAMELIST *nl;
+	int n = 0;
+	jlog("\tadditional dict entries:\n");
+	for(nl=lm->config->additional_dict_entries;nl;nl=nl->next) {
+	  jlog("\t\t\t%s\n", nl->name);
+	  n++;
+	}
+	jlog("--- total %d entries\n", n);
+      }
     }
 
     if (lm->lmtype == LM_PROB) {    
Index: julius4/libjulius/src/m_jconf.c
diff -u julius4/libjulius/src/m_jconf.c:1.6 julius4/libjulius/src/m_jconf.c:1.7
--- julius4/libjulius/src/m_jconf.c:1.6	Fri Sep 18 17:31:08 2009
+++ julius4/libjulius/src/m_jconf.c	Sat Feb  5 18:00:41 2011
@@ -37,7 +37,7 @@
  * @author Akinobu Lee
  * @date   Thu May 12 14:16:18 2005
  *
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
  * 
  */
 /*
@@ -54,6 +54,7 @@
 #endif
 
 #define ISTOKEN(A) (A == ' ' || A == '\t' || A == '\n') ///< Determine token characters
+#define BUFLEN 512
 
 /** 
  * <JA>
@@ -359,13 +360,143 @@
 /* read-in and parse jconf file and process those using m_options */
 /** 
  * <JA>
- * jconf 設定ファイルを読み込んで解析し,対応するオプションを設定する. 
+ * @brief  オプション文字列を分解して追加格納する.
+ *
+ * @param buf [in] 文字列
+ * @param argv [i/o] オプション列へのポインタ
+ * @param argc [i/o] オプション列の数へのポインタ
+ * @param maxnum [i/o] オプション列の割付最大数
+ * </JA>
+ * <EN>
+ * @brief  Divide option string into option arguments and append to array.
+ *
+ * @param buf [in] option string
+ * @param argv [i/o] pointer to option array
+ * @param argc [i/o] pointer to the length of option array
+ * @param maxnum [i/o] pointer to the allocated length of option array
+ * </EN>
+ */
+static void
+add_to_arglist(char *buf, char ***argv_ret, int *argc_ret, int *maxnum_ret)
+{
+  char *p = buf;
+  char cpy[BUFLEN];
+  char *dst, *dst_from;
+  char **argv = *argv_ret;
+  int argc = *argc_ret;
+  int maxnum = *maxnum_ret;
+
+  dst = cpy;
+  while (1) {
+    while (*p != '\0' && ISTOKEN(*p)) p++;
+    if (*p == '\0') break;
+      
+    dst_from = dst;
+      
+    while (*p != '\0' && (!ISTOKEN(*p))) {
+      if (*p == '\\') {     /* escape by '\' */
+	if (*(++p) == '\0') break;
+	*(dst++) = *(p++);
+      } else {
+	if (*p == '"') { /* quote by "" */
+	  p++;
+	  while (*p != '\0' && *p != '"') *(dst++) = *(p++);
+	  if (*p == '\0') break;
+	  p++;
+	} else if (*p == '\'') { /* quote by '' */
+	  p++;
+	  while (*p != '\0' && *p != '\'') *(dst++) = *(p++);
+	  if (*p == '\0') break;
+	  p++;
+	} else if (*p == '#') { /* comment out by '#' */
+	  *p = '\0';
+	  break;
+	} else {		/* other */
+	  *(dst++) = *(p++);
+	}
+      }
+    }
+    if (dst != dst_from) {
+      *dst = '\0'; dst++;
+      if ( argc >= maxnum) {
+	maxnum += 20;
+	argv = (char **)myrealloc(argv, sizeof(char *) * maxnum);
+      }
+      argv[argc++] = strcpy((char*)mymalloc(strlen(dst_from)+1), dst_from);
+    }
+  }
+  *argv_ret = argv;
+  *argc_ret = argc;
+  *maxnum_ret = maxnum;
+}
+
+/** 
+ * <JA>
+ * オプション指定を含む文字列を解析して値をセットする.
+ * 相対パス名はカレントからの相対として扱われる.
+ * 
+ * @param str [in] オプション指定を含む文字列
+ * @param jconf [out] 値をセットする jconf 設定データ
+ * </JA>
+ * <EN>
+ * Parse a string and set the specified option values.
+ * Relative paths will be treated as relative to current directory.
+ * 
+ * @param str [in] string which contains options
+ * @param jconf [out] global configuration data to be written.
+ * </EN>
+ *
+ * @callgraph
+ * @callergraph
+ */
+boolean
+config_string_parse(char *str, Jconf *jconf)
+{
+  int c_argc;
+  char **c_argv;
+  int maxnum;
+  char buf[BUFLEN];
+  char *cdir;
+  int i;
+  boolean ret;
+
+  jlog("STAT: parsing option string: \"%s\"\n", str);
+  
+  /* set the content of jconf file into argument list c_argv[1..c_argc-1] */
+  maxnum = 20;
+  c_argv = (char **)mymalloc(sizeof(char *) * maxnum);
+  c_argv[0] = strcpy((char *)mymalloc(7), "string");
+  c_argc = 1;
+  add_to_arglist(str, &c_argv, &c_argc, &maxnum);
+  /* env expansion */
+  for (i=1;i<c_argc;i++) {
+    c_argv[i] = expand_env(c_argv[i]);
+  }
+  /* now that options are in c_argv[][], call opt_parse() to process them */
+  /* relative paths in string are relative to current */
+  ret = opt_parse(c_argc, c_argv, NULL, jconf);
+
+  /* free arguments */
+  while (c_argc-- > 0) {
+    free(c_argv[c_argc]);
+  }
+  free(c_argv);
+
+  return(ret);
+}
+
+/** 
+ * <JA>
+ * jconf 設定ファイルを読み込んで解析し,対応するオプションを設定する.
+ * オプション内の相対パスは、その jconf 設定ファイルからの相対となる.
  * 
  * @param conffile [in] jconf ファイルのパス名
  * @param jconf [out] 値をセットする jconf 設定データ
  * </JA>
  * <EN>
  * Read and parse a jconf file, and set the specified option values.
+ * Relative paths in the file will be treated as relative to the file,
+ * not the application current.
  * 
  * @param conffile [in] jconf file path name
  * @param jconf [out] global configuration data to be written.
@@ -380,10 +511,8 @@
   int c_argc;
   char **c_argv;
   FILE *fp;
-  int maxnum, step;
-#define BUFLEN 512
-  char buf[BUFLEN], cpy[BUFLEN];
-  char *p, *dst, *dst_from;
+  int maxnum;
+  char buf[BUFLEN];
   char *cdir;
   int i;
   boolean ret;
@@ -397,52 +526,13 @@
     jlog("ERROR: m_jconf: failed to open jconf file: %s\n", conffile);
     return FALSE;
   }
-  step = 20;
-  maxnum = step;
+  maxnum = 20;
   c_argv = (char **)mymalloc(sizeof(char *) * maxnum);
   c_argv[0] = strcpy((char *)mymalloc(strlen(conffile)+1), conffile);
   c_argc = 1;
   while (fgets_jconf(buf, BUFLEN, fp) != NULL) {
     if (buf[0] == '\0') continue;
-    p = buf; dst = cpy;
-    while (1) {
-      while (*p != '\0' && ISTOKEN(*p)) p++;
-      if (*p == '\0') break;
-      
-      dst_from = dst;
-      
-      while (*p != '\0' && (!ISTOKEN(*p))) {
-	if (*p == '\\') {     /* escape by '\' */
-	  if (*(++p) == '\0') break;
-	  *(dst++) = *(p++);
-	} else {
-	  if (*p == '"') { /* quote by "" */
-	    p++;
-	    while (*p != '\0' && *p != '"') *(dst++) = *(p++);
-	    if (*p == '\0') break;
-	    p++;
-	  } else if (*p == '\'') { /* quote by '' */
-	    p++;
-	    while (*p != '\0' && *p != '\'') *(dst++) = *(p++);
-	    if (*p == '\0') break;
-	    p++;
-	  } else if (*p == '#') { /* comment out by '#' */
-	    *p = '\0';
-	    break;
-	  } else {		/* other */
-	    *(dst++) = *(p++);
-	  }
-	}
-      }
-      if (dst != dst_from) {
-	*dst = '\0'; dst++;
-	if (c_argc >= maxnum) {
-	  maxnum += step;
-	  c_argv = (char **)myrealloc(c_argv, sizeof(char *) * maxnum);
-	}
-	c_argv[c_argc++] = strcpy((char*)mymalloc(strlen(dst_from)+1), dst_from);
-      }
-    }
+    add_to_arglist(buf, &c_argv, &c_argc, &maxnum);
   }
   if (fclose(fp) == -1) {
     jlog("ERROR: m_jconf: cannot close jconf file\n");
Index: julius4/libjulius/src/m_options.c
diff -u julius4/libjulius/src/m_options.c:1.19 julius4/libjulius/src/m_options.c:1.20
--- julius4/libjulius/src/m_options.c:1.19	Sun Apr  4 00:06:15 2010
+++ julius4/libjulius/src/m_options.c	Sat Feb  5 18:00:41 2011
@@ -18,7 +18,7 @@
  * @author Akinobu Lee
  * @date   Thu May 12 18:52:07 2005
  *
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
  * 
  */
 /*
@@ -1270,6 +1270,18 @@
       plugin_load_dirs(tmparg);
       continue;
 #endif
+    } else if (strmatch(argv[i],"-adddict")) {
+	if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
+	GET_TMPARG;
+	char *arg = filepath(tmparg, cwd);
+	j_add_dict(jconf->lmnow, arg);
+	free(arg);
+	continue;
+    } else if (strmatch(argv[i],"-addentry")) {
+	if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
+	GET_TMPARG;
+	j_add_word(jconf->lmnow, tmparg);
+	continue;
     }
     if (argv[i][0] == '-' && strlen(argv[i]) == 2) {
       /* 1-letter options */
Index: julius4/libjulius/src/search_bestfirst_main.c
diff -u julius4/libjulius/src/search_bestfirst_main.c:1.9 julius4/libjulius/src/search_bestfirst_main.c:1.10
--- julius4/libjulius/src/search_bestfirst_main.c:1.9	Sat Jul  4 23:11:42 2009
+++ julius4/libjulius/src/search_bestfirst_main.c	Sat Feb  5 18:00:41 2011
@@ -35,7 +35,7 @@
  * @author Akinobu Lee
  * @date   Thu Sep 08 11:51:12 2005
  *
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
  * 
  */
 /*
@@ -658,11 +658,15 @@
     sd->sentcm = (LOGPROB *)mymalloc(sizeof(LOGPROB)*stacknum);
     sd->sentnum = stacknum;
   } else if (sd->sentnum < stacknum) { /* need expanded */
-    sd->sentcm = (LOGPROB *)myrealloc(sentcm, sizeof(LOGPROB)*stacknum);
+    sd->sentcm = (LOGPROB *)myrealloc(sd->sentcm, sizeof(LOGPROB)*stacknum);
     sd->sentnum = stacknum;
   }
   if (sd->wordcm == NULL) {
     sd->wordcm = (LOGPROB *)mymalloc(sizeof(LOGPROB) * winfo->num);
+    sd->wordnum = winfo->num;
+  } else if (sd->wordnum < winfo->num) {
+    sd->wordcm = (LOGPROB *)myremalloc(sd->wordcm, sizeof(LOGPROB) * winfo->num);
+    sd->wordnum = winfo->num;
   }
   
   cm_alpha = jconf->annotate.cm_alpha;
@@ -670,7 +674,7 @@
   for (j = 0, cm_alpha = jconf->annotate.cm_alpha_bgn; cm_alpha <= jconf->annotate.cm_alpha_end; cm_alpha += jconf->annotate.cm_alpha_step) {
 #endif
     /* clear whole word cm buffer */
-    for(w=0;w<winfo->num;w++) {
+    for(w=0;w<sd->wordnum;w++) {
       sd->wordcm[w] = 0.0;
     }
     /* get best score */



Julius-cvs メーリングリストの案内
アーカイブの一覧に戻る