Julius 4.2
libsent/src/dfa/dfa_lookup.c
説明を見る。
00001 
00024 /*
00025  * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University
00026  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00027  * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology
00028  * All rights reserved
00029  */
00030 
00031 #include <sent/stddefs.h>
00032 #include <sent/dfa.h>
00033 #include <ctype.h>
00034 
00044 WORD_ID
00045 dfa_symbol_lookup(DFA_INFO *dinfo, char *terminalname)
00046 {
00047   WORD_ID id;
00048   int c;
00049   char *p;
00050 
00051   /* check if terminal name is digit */
00052   for(p=terminalname;*p!='\0';p++) {
00053     c = *p;
00054     if (! isdigit(c)) {
00055       jlog("Error: dfa_lookup: terminal number is not digit in dict! [%s]\n", terminalname);
00056       return(WORD_INVALID);
00057     }
00058   }
00059 
00060   /* Currently, terminal ID is already assigned by mkdfa in wname,
00061      so this function only returns the ID */
00062   id = atoi(terminalname);
00063   if (id >= dinfo->term_num) return(WORD_INVALID); /* error */
00064   else return(id);
00065 }