jsgf.h
Go to the documentation of this file.
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 2007 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* 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
* 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,
* 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
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
#ifndef __JSGF_H__
#define __JSGF_H__
#include <stdio.h>
/* Win32/WinCE DLL gunk */
#include <sphinxbase/sphinxbase_export.h>
#include <sphinxbase/hash_table.h>
#include <sphinxbase/fsg_model.h>
#include <sphinxbase/logmath.h>
#ifdef __cplusplus
extern "C" {
#endif
#if 0
/* Fool Emacs. */
}
#endif
typedef struct jsgf_s jsgf_t;
typedef struct jsgf_rule_s jsgf_rule_t;
SPHINXBASE_EXPORT
jsgf_t *jsgf_grammar_new(jsgf_t *parent);
SPHINXBASE_EXPORT
jsgf_t *jsgf_parse_file(const char *filename, jsgf_t *parent);
SPHINXBASE_EXPORT
char const *jsgf_grammar_name(jsgf_t *jsgf);
SPHINXBASE_EXPORT
void jsgf_grammar_free(jsgf_t *jsgf);
typedef hash_iter_t jsgf_rule_iter_t;
SPHINXBASE_EXPORT
jsgf_rule_iter_t *jsgf_rule_iter(jsgf_t *grammar);
#define jsgf_rule_iter_next(itor) hash_table_iter_next(itor)
#define jsgf_rule_iter_rule(itor) ((jsgf_rule_t *)(itor)->ent->val)
#define jsgf_rule_iter_free(itor) hash_table_iter_free(itor)
SPHINXBASE_EXPORT
jsgf_rule_t *jsgf_get_rule(jsgf_t *grammar, char const *name);
SPHINXBASE_EXPORT
char const *jsgf_rule_name(jsgf_rule_t *rule);
SPHINXBASE_EXPORT
int jsgf_rule_public(jsgf_rule_t *rule);
SPHINXBASE_EXPORT
fsg_model_t *jsgf_build_fsg(jsgf_t *grammar, jsgf_rule_t *rule,
logmath_t *lmath, float32 lw);
SPHINXBASE_EXPORT
fsg_model_t *jsgf_build_fsg_raw(jsgf_t *grammar, jsgf_rule_t *rule,
logmath_t *lmath, float32 lw);
SPHINXBASE_EXPORT
fsg_model_t *jsgf_read_file(const char *file, logmath_t * lmath, float32 lw);
SPHINXBASE_EXPORT
int jsgf_write_fsg(jsgf_t *grammar, jsgf_rule_t *rule, FILE *outfh);
#ifdef __cplusplus
}
#endif
#endif /* __JSGF_H__ */
jsgf_s
Definition: jsgf_internal.h:69
logmath_s
Definition: logmath.c:49
jsgf_parse_file
SPHINXBASE_EXPORT jsgf_t * jsgf_parse_file(const char *filename, jsgf_t *parent)
Parse a JSGF grammar from a file.
Definition: jsgf.c:734
jsgf_build_fsg
SPHINXBASE_EXPORT fsg_model_t * jsgf_build_fsg(jsgf_t *grammar, jsgf_rule_t *rule, logmath_t *lmath, float32 lw)
Build a Sphinx FSG object from a JSGF rule.
Definition: jsgf.c:497
jsgf_rule_name
SPHINXBASE_EXPORT char const * jsgf_rule_name(jsgf_rule_t *rule)
Get the rule name from a rule.
Definition: jsgf.c:437
jsgf_grammar_new
SPHINXBASE_EXPORT jsgf_t * jsgf_grammar_new(jsgf_t *parent)
Create a new JSGF grammar.
Definition: jsgf.c:79
jsgf_read_file
SPHINXBASE_EXPORT fsg_model_t * jsgf_read_file(const char *file, logmath_t *lmath, float32 lw)
Read JSGF from file and return FSG object from it.
Definition: jsgf.c:511
jsgf_rule_s
Definition: jsgf_internal.h:86
jsgf_grammar_name
SPHINXBASE_EXPORT char const * jsgf_grammar_name(jsgf_t *jsgf)
Get the grammar name from the file.
Definition: jsgf.c:233
jsgf_build_fsg_raw
SPHINXBASE_EXPORT fsg_model_t * jsgf_build_fsg_raw(jsgf_t *grammar, jsgf_rule_t *rule, logmath_t *lmath, float32 lw)
Build a Sphinx FSG object from a JSGF rule.
Definition: jsgf.c:504
jsgf_rule_s::name
char * name
Rule name (NULL for an alternation/grouping)
Definition: jsgf_internal.h:88
hash_iter_s
Definition: hash_table.h:168
jsgf_rule_public
SPHINXBASE_EXPORT int jsgf_rule_public(jsgf_rule_t *rule)
Test if a rule is public or not.
Definition: jsgf.c:443
jsgf_get_rule
SPHINXBASE_EXPORT jsgf_rule_t * jsgf_get_rule(jsgf_t *grammar, char const *name)
Get a rule by name from a grammar.
Definition: jsgf.c:427
hash_table.h
Hash table implementation.
fsg_model_s
Word level FSG definition.
Definition: fsg_model.h:91
logmath.h
Fast integer logarithmic addition operations.
jsgf_rule_iter_t
hash_iter_t jsgf_rule_iter_t
Iterator over rules in a grammar.
Definition: jsgf.h:101
jsgf_grammar_free
SPHINXBASE_EXPORT void jsgf_grammar_free(jsgf_t *jsgf)
Free a JSGF grammar.
Definition: jsgf.c:125
jsgf_write_fsg
SPHINXBASE_EXPORT int jsgf_write_fsg(jsgf_t *grammar, jsgf_rule_t *rule, FILE *outfh)
Convert a JSGF rule to Sphinx FSG text form.
Definition: jsgf.c:542
jsgf_rule_iter
SPHINXBASE_EXPORT jsgf_rule_iter_t * jsgf_rule_iter(jsgf_t *grammar)
Get an iterator over all rules in a grammar.
Definition: jsgf.c:421