diff --git a/include/sphinxbase/fsg_model.h b/include/sphinxbase/fsg_model.h
index 40cb7494..c59954be 100644
--- a/include/sphinxbase/fsg_model.h
+++ b/include/sphinxbase/fsg_model.h
@@ -8,7 +8,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -16,16 +16,16 @@
* distribution.
*
*
- * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
- * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
@@ -34,7 +34,7 @@
/*
* fsg_model.h -- Word-level finite state graph
- *
+ *
* **********************************************
* CMU ARPA Speech Project
*
@@ -68,6 +68,8 @@ extern "C" {
}
#endif
+#define MAX_TAG_SIZE 50
+
/*
* A single transition in the FSG.
*/
@@ -76,12 +78,14 @@ typedef struct fsg_link_s {
int32 to_state;
int32 logs2prob; /**< log(transition probability)*lw */
int32 wid; /**< Word-ID; <0 if epsilon or null transition */
+ char tag[MAX_TAG_SIZE]; /**< List containig tags (char *) associated with the link */
} fsg_link_t;
/* Access macros */
#define fsg_link_from_state(l) ((l)->from_state)
#define fsg_link_to_state(l) ((l)->to_state)
#define fsg_link_wid(l) ((l)->wid)
+#define fsg_link_tag(l) ((l)->tag)
#define fsg_link_logs2prob(l) ((l)->logs2prob)
/**
@@ -154,9 +158,9 @@ fsg_model_t *fsg_model_init(char const *name, logmath_t *lmath,
/**
* Read a word FSG from the given file and return a pointer to the structure
* created. Return NULL if any error occurred.
- *
+ *
* File format:
- *
+ *
*
* Any number of comment lines; ignored
* FSG_BEGIN []
@@ -169,24 +173,24 @@ fsg_model_t *fsg_model_init(char const *name, logmath_t *lmath,
* FSG_END
* Any number of comment lines; ignored
*
- *
+ *
* The FSG spec begins with the line containing the keyword FSG_BEGIN.
* It has an optional fsg name string. If not present, the FSG has the empty
* string as its name.
- *
+ *
* Following the FSG_BEGIN declaration is the number of states, the start
* state, and the final state, each on a separate line. States are numbered
* in the range [0 .. -1].
- *
+ *
* These are followed by all the state transitions, each on a separate line,
* and terminated by the FSG_END line. A state transition has the given
* probability of being taken, and emits the given word. The word emission
* is optional; if word-string omitted, it is an epsilon or null transition.
- *
+ *
* Comments can also be embedded within the FSG body proper (i.e. between
* FSG_BEGIN and FSG_END): any line with a # character in col 1 is treated
* as a comment line.
- *
+ *
* Return value: a new fsg_model_t structure if the file is successfully
* read, NULL otherwise.
*/
@@ -239,7 +243,7 @@ int fsg_model_word_id(fsg_model_t *fsg, char const *word);
*/
SPHINXBASE_EXPORT
void fsg_model_trans_add(fsg_model_t * fsg,
- int32 from, int32 to, int32 logp, int32 wid);
+ int32 from, int32 to, int32 logp, int32 wid, glist_t tags);
/**
* Add a null transition between the given states.
diff --git a/include/sphinxbase/jsgf.h b/include/sphinxbase/jsgf.h
index 3c3de1de..142e7797 100644
--- a/include/sphinxbase/jsgf.h
+++ b/include/sphinxbase/jsgf.h
@@ -63,6 +63,10 @@ extern "C" {
typedef struct jsgf_s jsgf_t;
typedef struct jsgf_rule_s jsgf_rule_t;
+typedef struct jsgf_rhs_s jsgf_rhs_t;
+typedef struct jsgf_atom_s jsgf_atom_t;
+typedef struct jsgf_link_s jsgf_link_t;
+typedef struct jsgf_rule_stack_s jsgf_rule_stack_t;
/**
* Create a new JSGF grammar.
@@ -201,6 +205,71 @@ fsg_model_t *jsgf_read_string(const char *string, logmath_t * lmath, float32 lw)
SPHINXBASE_EXPORT
int jsgf_write_fsg(jsgf_t *grammar, jsgf_rule_t *rule, FILE *outfh);
+/* ------------ MOVED FROM jsgf_internal.h ---------- */
+#define jsgf_atom_is_rule(atom) ((atom)->name[0] == '<')
+
+void jsgf_add_link(jsgf_t *grammar, jsgf_atom_t *atom, int from, int to);
+jsgf_atom_t *jsgf_atom_new(char *name, float weight);
+jsgf_atom_t *jsgf_kleene_new(jsgf_t *jsgf, jsgf_atom_t *atom, int plus);
+jsgf_rule_t *jsgf_optional_new(jsgf_t *jsgf, jsgf_rhs_t *exp);
+jsgf_rule_t *jsgf_define_rule(jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int is_public);
+jsgf_rule_t *jsgf_import_rule(jsgf_t *jsgf, char *name);
+
+int jsgf_atom_free(jsgf_atom_t *atom);
+int jsgf_rule_free(jsgf_rule_t *rule);
+jsgf_rule_t *jsgf_rule_retain(jsgf_rule_t *rule);
+
+/* ------------ MY FUNCTIONS ----------- */
+
+/**
+ * Creates a new atom with single tag.
+ *
+ */
+SPHINXBASE_EXPORT
+jsgf_atom_t *jsgf_atom_with_tag_new(char *name, float weight, char *tag);
+
+/**
+ * Creates a new rhs struct.
+ *
+ */
+SPHINXBASE_EXPORT
+jsgf_rhs_t *jsgf_rhs_new();
+
+/**
+ * Some getters and setters put to allow the single inclusion of jsgf.h.
+ *
+ */
+
+SPHINXBASE_EXPORT
+jsgf_rhs_t *jsgf_get_rule_rhs(jsgf_rule_t *rule);
+
+SPHINXBASE_EXPORT
+jsgf_rhs_t *jsgf_get_rhs_alt(jsgf_rhs_t *rhs);
+
+SPHINXBASE_EXPORT
+gnode_t *jsgf_get_rhs_atom(jsgf_rhs_t *rhs);
+
+SPHINXBASE_EXPORT
+char *jsgf_get_atom_name(jsgf_atom_t *atom);
+
+SPHINXBASE_EXPORT
+void jsgf_set_rule_rhs(jsgf_rule_t *rule, jsgf_rhs_t *rhs);
+
+SPHINXBASE_EXPORT
+void jsgf_set_rhs_alt(jsgf_rhs_t *rhs, jsgf_rhs_t *alt);
+
+SPHINXBASE_EXPORT
+void jsgf_set_rhs_atom(jsgf_rhs_t *rhs, gnode_t* gn);
+
+SPHINXBASE_EXPORT
+void jsgf_set_atom_name(jsgf_atom_t *atom, char *name);
+
+SPHINXBASE_EXPORT
+int jsgf_is_atom_rule(jsgf_atom_t *atom);
+
+SPHINXBASE_EXPORT
+int jsgf_rule_clean(jsgf_rule_t *rule);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libsphinxbase/lm/fsg_model.c b/src/libsphinxbase/lm/fsg_model.c
index ac80ef9a..a09e2735 100644
--- a/src/libsphinxbase/lm/fsg_model.c
+++ b/src/libsphinxbase/lm/fsg_model.c
@@ -8,7 +8,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -16,16 +16,16 @@
* distribution.
*
*
- * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
- * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
@@ -111,7 +111,7 @@ nextline_str2words(FILE * fp, int32 * lineno,
void
fsg_model_trans_add(fsg_model_t * fsg,
- int32 from, int32 to, int32 logp, int32 wid)
+ int32 from, int32 to, int32 logp, int32 wid, glist_t tags)
{
fsg_link_t *link;
glist_t gl;
@@ -137,6 +137,12 @@ fsg_model_trans_add(fsg_model_t * fsg,
link->logs2prob = logp;
link->wid = wid;
+ gnode_t *gnt = tags;
+ if(gnt)
+ {
+ strncpy(link->tag,(char *)gnode_ptr(gnt),50);
+ }
+
/* Add it to the list of transitions and update the hash table */
gl = glist_add_ptr(gl, (void *) link);
hash_table_replace_bkey(fsg->trans[from].trans,
@@ -208,7 +214,7 @@ fsg_model_null_trans_closure(fsg_model_t * fsg, glist_t nulls)
E_INFO("Computing transitive closure for null transitions\n");
/* If our caller didn't give us a list of null-transitions,
- make such a list. Just loop through all the FSG states,
+ make such a list. Just loop through all the FSG states,
and all the null-transitions in that state (which are kept in
their own hash table). */
if (nulls == NULL) {
@@ -431,12 +437,12 @@ fsg_model_add_silence(fsg_model_t * fsg, char const *silword,
n_trans = 0;
if (state == -1) {
for (src = 0; src < fsg->n_state; src++) {
- fsg_model_trans_add(fsg, src, src, logsilp, silwid);
+ fsg_model_trans_add(fsg, src, src, logsilp, silwid, NULL);
++n_trans;
}
}
else {
- fsg_model_trans_add(fsg, state, state, logsilp, silwid);
+ fsg_model_trans_add(fsg, state, state, logsilp, silwid, NULL);
++n_trans;
}
@@ -684,7 +690,7 @@ fsg_model_read(FILE * fp, logmath_t * lmath, float32 lw)
wid = lastwid;
++lastwid;
}
- fsg_model_trans_add(fsg, i, j, tprob, wid);
+ fsg_model_trans_add(fsg, i, j, tprob, wid, NULL);
++n_trans;
}
else {
diff --git a/src/libsphinxbase/lm/jsgf.c b/src/libsphinxbase/lm/jsgf.c
index 73d1d17b..f6c45d97 100644
--- a/src/libsphinxbase/lm/jsgf.c
+++ b/src/libsphinxbase/lm/jsgf.c
@@ -8,27 +8,27 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
- * This work was supported in part by funding from the Defense Advanced
- * Research Projects Agency and the National Science Foundation of the
+ * This work was supported in part by funding from the Defense Advanced
+ * Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
- * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
- * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
@@ -61,6 +61,21 @@ extern int yyparse(void *scanner, jsgf_t * jsgf);
static int expand_rule(jsgf_t * grammar, jsgf_rule_t * rule,
int rule_entry, int rule_exit);
+jsgf_atom_t *
+jsgf_atom_with_tag_new(char *name, float weight, char *tag)
+{
+ jsgf_atom_t *atom;
+
+ atom = ckd_calloc(1, sizeof(*atom));
+ atom->name = ckd_salloc(name);
+ atom->weight = weight;
+ const char *tagC = ckd_salloc(tag);
+
+ glist_t tags = glist_add_ptr(NULL,(void *)tagC);
+ atom->tags = tags;
+ return atom;
+}
+
jsgf_atom_t *
jsgf_atom_new(char *name, float weight)
{
@@ -69,6 +84,7 @@ jsgf_atom_new(char *name, float weight)
atom = ckd_calloc(1, sizeof(*atom));
atom->name = ckd_salloc(name);
atom->weight = weight;
+ atom->tags = NULL;
return atom;
}
@@ -77,6 +93,15 @@ jsgf_atom_free(jsgf_atom_t * atom)
{
if (atom == NULL)
return 0;
+
+ gnode_t *gn;
+ for(gn = atom->tags;gn;gn = gnode_next(gn)){
+ char *tag = (char *)gnode_ptr(gn);
+ if(tag){
+ ckd_free(tag);
+ }
+ }
+ glist_free(atom->tags);
ckd_free(atom->name);
ckd_free(atom);
return 0;
@@ -252,7 +277,7 @@ jsgf_fullname_from_rule(jsgf_rule_t * rule, const char *name)
return fullname;
}
-/* Extract as rulename everything after the secondlast dot, if existent.
+/* Extract as rulename everything after the secondlast dot, if existent.
* Because everything before the secondlast dot is the path-specification. */
static char *
importname2rulename(char *importname)
@@ -304,16 +329,15 @@ expand_rhs(jsgf_t * grammar, jsgf_rule_t * rule, jsgf_rhs_t * rhs,
/* Iterate over atoms in rhs and generate links/nodes */
for (gn = rhs->atoms; gn; gn = gnode_next(gn)) {
jsgf_atom_t *atom = gnode_ptr(gn);
-
if (jsgf_atom_is_rule(atom)) {
jsgf_rule_t *subrule;
char *fullname;
gnode_t *subnode;
jsgf_rule_stack_t *rule_stack_entry = NULL;
- /* Special case for and pseudo-rules
- If this is the only atom in the rhs, and it's the
- first rhs in the rule, then emit a null transition,
+ /* Special case for and pseudo-rules
+ If this is the only atom in the rhs, and it's the
+ first rhs in the rule, then emit a null transition,
creating an exit state if needed. */
if (0 == strcmp(atom->name, "")) {
if (gn == rhs->atoms && gnode_next(gn) == NULL) {
@@ -566,7 +590,7 @@ jsgf_build_fsg_internal(jsgf_t * grammar, jsgf_rule_t * rule,
int wid = fsg_model_word_add(fsg, link->atom->name);
fsg_model_trans_add(fsg, link->from, link->to,
logmath_log(lmath, link->atom->weight),
- wid);
+ wid, link->atom->tags);
}
}
else {
@@ -961,3 +985,98 @@ jsgf_parse_string(const char *string, jsgf_t * parent)
return jsgf;
}
+
+jsgf_rhs_t *
+jsgf_get_rule_rhs(jsgf_rule_t *rule)
+{
+ if(!rule)
+ return NULL;
+
+ return rule->rhs;
+}
+
+jsgf_rhs_t *
+jsgf_get_rhs_alt(jsgf_rhs_t *rhs)
+{
+ if(!rhs)
+ return NULL;
+
+ return rhs->alt;
+}
+
+gnode_t *
+jsgf_get_rhs_atom(jsgf_rhs_t *rhs)
+{
+ if(!rhs)
+ return NULL;
+
+ return rhs->atoms;
+}
+
+char *
+jsgf_get_atom_name(jsgf_atom_t *atom)
+{
+ if(!atom)
+ return NULL;
+
+ return atom->name;
+}
+
+void
+jsgf_set_rule_rhs(jsgf_rule_t *rule, jsgf_rhs_t *rhs)
+{
+ if(rule)
+ rule->rhs = rhs;
+}
+
+void
+jsgf_set_rhs_alt(jsgf_rhs_t *rhs, jsgf_rhs_t *alt)
+{
+ if(rhs)
+ rhs->alt = alt;
+}
+
+void
+jsgf_set_rhs_atom(jsgf_rhs_t *rhs, gnode_t* gn)
+{
+ if(rhs)
+ rhs->atoms = gn;
+}
+
+void
+jsgf_set_atom_name(jsgf_atom_t *atom, char *name)
+{
+ if(atom)
+ atom->name = name;
+}
+
+int
+jsgf_is_atom_rule(jsgf_atom_t *atom)
+{
+ if(!atom)
+ return -1;
+
+ if(atom->name[0] == '<'){
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+jsgf_rhs_t *
+jsgf_rhs_new()
+{
+ return (jsgf_rhs_t *) ckd_calloc(1, sizeof(jsgf_rhs_t));
+}
+
+int
+jsgf_rule_clean(jsgf_rule_t *rule)
+{
+ if (rule == NULL)
+ return 0;
+ if (--rule->refcnt > 0)
+ return rule->refcnt;
+ jsgf_rhs_free(rule->rhs);
+ return 0;
+}
+
diff --git a/src/libsphinxbase/lm/jsgf_internal.h b/src/libsphinxbase/lm/jsgf_internal.h
index a5cbc983..87b7888e 100644
--- a/src/libsphinxbase/lm/jsgf_internal.h
+++ b/src/libsphinxbase/lm/jsgf_internal.h
@@ -8,27 +8,27 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
- * This work was supported in part by funding from the Defense Advanced
- * Research Projects Agency and the National Science Foundation of the
+ * This work was supported in part by funding from the Defense Advanced
+ * Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
- * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
- * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
@@ -67,11 +67,6 @@ extern "C" {
#define YY_NO_INPUT /* Silence a compiler warning. */
-typedef struct jsgf_rhs_s jsgf_rhs_t;
-typedef struct jsgf_atom_s jsgf_atom_t;
-typedef struct jsgf_link_s jsgf_link_t;
-typedef struct jsgf_rule_stack_s jsgf_rule_stack_t;
-
struct jsgf_s {
char *version; /**< JSGF version (from header) */
char *charset; /**< JSGF charset (default UTF-8) */
@@ -119,19 +114,6 @@ struct jsgf_link_s {
int to; /**< To state */
};
-#define jsgf_atom_is_rule(atom) ((atom)->name[0] == '<')
-
-void jsgf_add_link(jsgf_t *grammar, jsgf_atom_t *atom, int from, int to);
-jsgf_atom_t *jsgf_atom_new(char *name, float weight);
-jsgf_atom_t *jsgf_kleene_new(jsgf_t *jsgf, jsgf_atom_t *atom, int plus);
-jsgf_rule_t *jsgf_optional_new(jsgf_t *jsgf, jsgf_rhs_t *exp);
-jsgf_rule_t *jsgf_define_rule(jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int is_public);
-jsgf_rule_t *jsgf_import_rule(jsgf_t *jsgf, char *name);
-
-int jsgf_atom_free(jsgf_atom_t *atom);
-int jsgf_rule_free(jsgf_rule_t *rule);
-jsgf_rule_t *jsgf_rule_retain(jsgf_rule_t *rule);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/libsphinxbase/util/listelem_alloc.c b/src/libsphinxbase/util/listelem_alloc.c
index d6b4ceda..9bde0cb8 100644
--- a/src/libsphinxbase/util/listelem_alloc.c
+++ b/src/libsphinxbase/util/listelem_alloc.c
@@ -8,27 +8,27 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
- * This work was supported in part by funding from the Defense Advanced
- * Research Projects Agency and the National Science Foundation of the
+ * This work was supported in part by funding from the Defense Advanced
+ * Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
- * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
- * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
@@ -45,7 +45,7 @@
/**
* Fast linked list allocator.
- *
+ *
* We keep a separate linked list for each element-size. Element-size
* must be a multiple of pointer-size.
*
@@ -124,7 +124,7 @@ listelem_alloc_free(listelem_alloc_t *list)
if (list == NULL)
return;
for (gn = list->blocks; gn; gn = gnode_next(gn))
- ckd_free(gnode_ptr(gn));
+ if(gn) ckd_free(gnode_ptr(gn));
glist_free(list->blocks);
glist_free(list->blocksize);
ckd_free(list);
diff --git a/swig/fsg_model.i b/swig/fsg_model.i
index 6d7952d5..6146bee2 100644
--- a/swig/fsg_model.i
+++ b/swig/fsg_model.i
@@ -60,7 +60,7 @@
}
void trans_add(int src, int dst, int logp, int wid) {
- fsg_model_trans_add($self, src, dst, logp, wid);
+ fsg_model_trans_add($self, src, dst, logp, wid, NULL);
}
int null_trans_add(int src, int dst, int logp) {