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
jsgf_t *jsgf_parse_string(const char *string, 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, const char *name);
SPHINXBASE_EXPORT
jsgf_rule_t *jsgf_get_public_rule(jsgf_t *grammar);
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
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);
#ifdef __cplusplus
}
#endif
#endif /* __JSGF_H__ */
hash_table.h
Hash table implementation.
jsgf_get_public_rule
SPHINXBASE_EXPORT jsgf_rule_t * jsgf_get_public_rule(jsgf_t *grammar)
Returns the first public rule of the grammar.
Definition jsgf.c:484
jsgf_grammar_new
SPHINXBASE_EXPORT jsgf_t * jsgf_grammar_new(jsgf_t *parent)
Create a new JSGF grammar.
Definition jsgf.c:86
jsgf_grammar_name
SPHINXBASE_EXPORT char const * jsgf_grammar_name(jsgf_t *jsgf)
Get the grammar name from the file.
Definition jsgf.c:216
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:585
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:592
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:599
jsgf_read_string
SPHINXBASE_EXPORT fsg_model_t * jsgf_read_string(const char *string, logmath_t *lmath, float32 lw)
Read JSGF from string and return FSG object from it.
Definition jsgf.c:630
jsgf_rule_public
SPHINXBASE_EXPORT int jsgf_rule_public(jsgf_rule_t *rule)
Test if a rule is public or not.
Definition jsgf.c:519
jsgf_grammar_free
SPHINXBASE_EXPORT void jsgf_grammar_free(jsgf_t *jsgf)
Free a JSGF grammar.
Definition jsgf.c:108
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:896
jsgf_get_rule
SPHINXBASE_EXPORT jsgf_rule_t * jsgf_get_rule(jsgf_t *grammar, const char *name)
Get a rule by name from a grammar.
Definition jsgf.c:469
jsgf_parse_string
SPHINXBASE_EXPORT jsgf_t * jsgf_parse_string(const char *string, jsgf_t *parent)
Parse a JSGF grammar from a string.
Definition jsgf.c:937
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:663
jsgf_rule_iter_t
hash_iter_t jsgf_rule_iter_t
Iterator over rules in a grammar.
Definition jsgf.h:111
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:463
jsgf_rule_name
SPHINXBASE_EXPORT char const * jsgf_rule_name(jsgf_rule_t *rule)
Get the rule name from a rule.
Definition jsgf.c:513
logmath.h
Fast integer logarithmic addition operations.
logmath_t
struct logmath_s logmath_t
Integer log math computation class.
Definition logmath.h:108
jsgf_rule_s
Definition jsgf_internal.h:98
jsgf_rule_s::name
char * name
Rule name (NULL for an alternation/grouping).
Definition jsgf_internal.h:100
jsgf_s
Definition jsgf_internal.h:75