[Julius-cvs 328] CVS update: julius4/jcontrol

Back to archive index

sumom****@users***** sumom****@users*****
2008年 10月 17日 (金) 08:33:23 JST


Index: julius4/jcontrol/japi.h
diff -u julius4/jcontrol/japi.h:1.2 julius4/jcontrol/japi.h:1.3
--- julius4/jcontrol/japi.h:1.2	Tue Dec 18 17:45:48 2007
+++ julius4/jcontrol/japi.h	Fri Oct 17 08:33:23 2008
@@ -12,7 +12,7 @@
  * @author Akinobu LEE
  * @date   Thu Mar 24 07:12:32 2005
  *
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
  * 
  */
 /*
@@ -92,6 +92,7 @@
 void japi_set_input_handler_on_change(int, char *);
 
 /* japi_grammar.c */
+void japi_get_graminfo(int sd);
 void japi_change_grammar(int sd, char *prefixpath);
 void japi_add_grammar(int sd, char *prefixpath);
 void japi_delete_grammar(int sd, char *idlist);
Index: julius4/jcontrol/japi_grammar.c
diff -u julius4/jcontrol/japi_grammar.c:1.2 julius4/jcontrol/japi_grammar.c:1.3
--- julius4/jcontrol/japi_grammar.c:1.2	Tue Dec 18 17:45:48 2007
+++ julius4/jcontrol/japi_grammar.c	Fri Oct 17 08:33:23 2008
@@ -12,7 +12,7 @@
  * @author Akinobu LEE
  * @date   Thu Mar 24 07:13:41 2005
  *
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
  * 
  */
 /*
@@ -45,13 +45,25 @@
 static int
 check_grammar_path(char *prefix)
 {
-  snprintf(buf, MAXLINELEN, "%s.dfa", prefix);
-  if (access(buf, R_OK) < 0) {
-    perror("japi_change_grammar"); return -1;
-  }
-  snprintf(buf, MAXLINELEN, "%s.dict", prefix);
-  if (access(buf, R_OK) < 0) {
-    perror("japi_change_grammar"); return -1;
+  int i;
+
+  i = strlen(prefix) - 1;
+  while(prefix[i] != '.' && i >= 0) i--;
+  if (i < 0 && strcmp(&(prefix[i]), ".dict") != 0) {
+    snprintf(buf, MAXLINELEN, "%s.dfa", prefix);
+    if (access(buf, R_OK) < 0) {
+      fprintf(stderr, "Error: \"%s.dfa\" not exist\n", prefix);
+      return -1;
+    }
+    snprintf(buf, MAXLINELEN, "%s.dict", prefix);
+    if (access(buf, R_OK) < 0) {
+      fprintf(stderr, "Error: \"%s.dict\" not exist\n", prefix);
+      return -1;
+    }
+  } else {
+    if (access(prefix, R_OK) < 0) {
+      fprintf(stderr, "Error: \"%s\" not exist\n", prefix);
+    }
   }
   return 0;
 }
@@ -78,17 +90,24 @@
 send_grammar(int sd, char *prefix)
 {
   FILE *fp;
-  
-  snprintf(buf, MAXLINELEN, "%s.dfa", prefix);
-  if ((fp = fopen(buf, "r")) == NULL) {
-    perror("japi_change_grammar"); return -1;
-  }
-  while(fgets(buf, MAXLINELEN, fp) != NULL) {
-    do_send(sd, buf);
+  int i;
+
+  i = strlen(prefix) - 1;
+  while(prefix[i] != '.' && i >= 0) i--;
+  if (i < 0 && strcmp(&(prefix[i]), ".dict") != 0) {
+    snprintf(buf, MAXLINELEN, "%s.dfa", prefix);
+    if ((fp = fopen(buf, "r")) == NULL) {
+      perror("japi_change_grammar"); return -1;
+    }
+    while(fgets(buf, MAXLINELEN, fp) != NULL) {
+      do_send(sd, buf);
+    }
+    do_send(sd, "DFAEND\n");
+    fclose(fp);
+    snprintf(buf, MAXLINELEN, "%s.dict", prefix);
+  } else {
+    snprintf(buf, MAXLINELEN, "%s", prefix);
   }
-  do_send(sd, "DFAEND\n");
-  fclose(fp);
-  snprintf(buf, MAXLINELEN, "%s.dict", prefix);
   if ((fp = fopen(buf, "r")) == NULL) {
     perror("japi_change_grammar"); return -1;
   }
@@ -283,6 +302,12 @@
 }
 
 void
+japi_get_graminfo(int sd)
+{
+  do_send(sd, "GRAMINFO\n");
+}
+
+void
 japi_add_words(int sd, char *idstr, char *dictfile)
 {
   FILE *fp;
Index: julius4/jcontrol/jcontrol.c
diff -u julius4/jcontrol/jcontrol.c:1.3 julius4/jcontrol/jcontrol.c:1.4
--- julius4/jcontrol/jcontrol.c:1.3	Tue May 13 15:32:47 2008
+++ julius4/jcontrol/jcontrol.c	Fri Oct 17 08:33:23 2008
@@ -12,7 +12,7 @@
  * @author Akinobu LEE
  * @date   Thu Mar 24 11:49:27 2005
  *
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
  * 
  */
 /*
@@ -60,6 +60,8 @@
       japi_get_version(sd);
     } else if (strmatch(com, "status")) {
       japi_get_status(sd);
+    } else if (strmatch(com, "graminfo")) {
+      japi_get_graminfo(sd);
     } else if (strmatch(com, "pause")) {
       japi_pause_recog(sd);
     } else if (strmatch(com, "terminate")) {


Julius-cvs メーリングリストの案内
Back to archive index