#include <stdio.h>
#include <logmath.h>
#include "prim_type.h"
#include "hash_table.h"
#include "s3_arraylist.h"
#include "fsg.h"
Go to the source code of this file.
|
void | s3_cfg_init (s3_cfg_t *_cfg) |
|
void | s3_cfg_close (s3_cfg_t *_cfg) |
|
S3DECODER_EXPORT s3_cfg_t * | s3_cfg_read_simple (const char *_fn) |
|
s3_cfg_t * | s3_cfg_read_srgs (const char *_fn) |
|
void | s3_cfg_write_simple (s3_cfg_t *_cfg, const char *_fn) |
|
S3DECODER_EXPORT s2_fsg_t * | s3_cfg_convert_to_fsg (s3_cfg_t *_cfg, int _max_expansion) |
|
void | s3_cfg_rescore (s3_cfg_t *_cfg, logmath_t *logmath) |
|
s3_cfg_item_t * | s3_cfg_get_term_info (s3_cfg_t *_cfg, s3_cfg_id_t _id) |
|
s3_cfg_state_t * | s3_cfg_create_parse (s3_cfg_t *_cfg) |
|
void | s3_cfg_free_parse (s3_cfg_t *_cfg, s3_cfg_state_t *_parse) |
|
void | s3_cfg_free_parse_tree (s3_cfg_t *_cfg, s3_cfg_state_t *_parse) |
|
s3_cfg_state_t * | s3_cfg_input_term (s3_cfg_t *_cfg, s3_cfg_state_t *_cur, s3_cfg_id_t _term) |
|
s3_cfg_rule_t * | s3_cfg_add_rule (s3_cfg_t *_cfg, s3_cfg_id_t _src, float32 _fake_score, s3_cfg_id_t *_products) |
|
S3DECODER_EXPORT void | s3_cfg_compile_rules (s3_cfg_t *_cfg, logmath_t *logmath) |
|
void | s3_cfg_print_rule (s3_cfg_t *_cfg, s3_cfg_rule_t *_rule, FILE *_out) |
|
void | s3_cfg_print_entry (s3_cfg_t *_cfg, s3_cfg_entry_t *_entry, FILE *_out) |
|
void | s3_cfg_print_parse (s3_cfg_t *_cfg, s3_cfg_entry_t *_parse, FILE *_out) |
|
s3_cfg_id_t | s3_cfg_str2id (s3_cfg_t *_cfg, char *_item) |
|
const char * | s3_cfg_id2str (s3_cfg_t *_cfg, s3_cfg_id_t _id) |
|
◆ S3_CFG_AUTO_PRUNE_RANK
#define S3_CFG_AUTO_PRUNE_RANK 0x00000002 |
◆ S3_CFG_AUTO_PRUNE_SCORE
#define S3_CFG_AUTO_PRUNE_SCORE 0x00000001 |
◆ S3_CFG_EOI_ITEM
#define S3_CFG_EOI_ITEM (0x00000003 | S3_CFG_TERM_BIT) |
◆ S3_CFG_EOI_ITEM_STR
#define S3_CFG_EOI_ITEM_STR "#EOI#" |
◆ S3_CFG_EOR_ITEM
#define S3_CFG_EOR_ITEM (0x00000002 | S3_CFG_TERM_BIT) |
◆ S3_CFG_EOR_ITEM_STR
#define S3_CFG_EOR_ITEM_STR "#EOR#" |
◆ s3_cfg_id2index
◆ S3_CFG_INDEX_MASK
#define S3_CFG_INDEX_MASK 0x7FFFFFFF |
◆ S3_CFG_INITIAL_PARSE_SET_COUNT
#define S3_CFG_INITIAL_PARSE_SET_COUNT 20 |
◆ S3_CFG_INITIAL_RULE_COUNT
#define S3_CFG_INITIAL_RULE_COUNT 1 |
◆ S3_CFG_INITIAL_RULE_SET_COUNT
#define S3_CFG_INITIAL_RULE_SET_COUNT 50 |
◆ S3_CFG_INITIAL_SCORE
#define S3_CFG_INITIAL_SCORE 0.0f |
◆ S3_CFG_INITIAL_STATE_SET_COUNT
#define S3_CFG_INITIAL_STATE_SET_COUNT 20 |
◆ S3_CFG_INITIAL_TERM_COUNT
#define S3_CFG_INITIAL_TERM_COUNT 50 |
◆ S3_CFG_INVALID_ID
#define S3_CFG_INVALID_ID 0x7FFFFFFF |
◆ S3_CFG_INVALID_SCORE
#define S3_CFG_INVALID_SCORE 1.0f |
◆ s3_cfg_is_null_parse
#define s3_cfg_is_null_parse |
( |
|
x | ) |
(x->entries.count == 0) |
◆ s3_cfg_is_terminal
◆ S3_CFG_MAX_ITEM_COUNT
#define S3_CFG_MAX_ITEM_COUNT 20 |
◆ S3_CFG_MAX_ITEM_STR_LEN
#define S3_CFG_MAX_ITEM_STR_LEN 40 |
◆ S3_CFG_MAX_RULE_STR_LEN
#define S3_CFG_MAX_RULE_STR_LEN 1023 |
◆ S3_CFG_NAME_HASH_SIZE
#define S3_CFG_NAME_HASH_SIZE 4091 |
◆ S3_CFG_NIL_ITEM
#define S3_CFG_NIL_ITEM (0x00000004 | S3_CFG_TERM_BIT) |
◆ S3_CFG_NIL_ITEM_STR
#define S3_CFG_NIL_ITEM_STR "#NIL#" |
◆ S3_CFG_NONTERM_PREFIX
#define S3_CFG_NONTERM_PREFIX '$' |
◆ S3_CFG_PARSE_HASH_SIZE
#define S3_CFG_PARSE_HASH_SIZE 251 |
◆ S3_CFG_PSTART_ITEM
#define S3_CFG_PSTART_ITEM 0x00000000 |
◆ S3_CFG_PSTART_ITEM_STR
#define S3_CFG_PSTART_ITEM_STR "$PSTART" |
◆ S3_CFG_START_ITEM
#define S3_CFG_START_ITEM 0x00000001 |
◆ S3_CFG_START_ITEM_STR
#define S3_CFG_START_ITEM_STR "$START" |
◆ S3_CFG_START_RULE
#define S3_CFG_START_RULE { S3_CFG_PSTART_ITEM, 0.0f, { S3_CFG_START_ITEM, S3_CFG_EOR_ITEM }, 1 } |
◆ S3_CFG_TERM_BIT
#define S3_CFG_TERM_BIT 0x80000000 |
◆ s3_cfg_entry_t
◆ s3_cfg_id_t
◆ s3_cfg_rule_t
◆ s3_cfg_state_t
◆ s3_cfg_add_rule()
Add an expansion rule to the CFG parser.
- Parameters
-
_cfg | A CFG parser. |
_src | The source of the expansion. Must be a non-terminal. |
_fake_score | Un-normalized transition scores. |
_products | An array of expansion terms. Terminated by S3_CFG_EOR_ITEM. |
- Returns
- A CFG expansion rule.
◆ s3_cfg_close()
Close a CFG parser and free its contents. The parser structure is not freed (since it was not allocated by init).
- Parameters
-
_cfg | A (pre-allocated) CFG parser. |
◆ s3_cfg_compile_rules()
The consistency of the rule scores must be compiled before the parser can be used.
- Parameters
-
◆ s3_cfg_convert_to_fsg()
Heuristically convert a CFG to a FSG by limiting non-terminal expansions.
- Parameters
-
- Returns
- A FSG.
◆ s3_cfg_create_parse()
Start a CFG parse session.
- Parameters
-
- Returns
- A parse session.
◆ s3_cfg_free_parse()
Free a CFG parse session.
- Parameters
-
_cfg | A CFG parser. |
_parse | A parse session. |
◆ s3_cfg_free_parse_tree()
◆ s3_cfg_get_term_info()
Fetch information on a term.
- Parameters
-
_cfg | A CFG parser. |
_id | A term id. |
- Returns
- Term information.
◆ s3_cfg_id2str()
Convert a term id to its original string representation.
- Parameters
-
_cfg | A CFG parser. |
_id | A term id. |
- Returns
- A string representation of the term.
◆ s3_cfg_init()
Initialize a CFG parser. The parser structure must be allocated outside the function.
- Parameters
-
_cfg | A (pre-allocated) CFG parser. |
◆ s3_cfg_input_term()
Continue a parse session by feeding it an input term.
- Parameters
-
_cfg | A CFG parser. |
_cur | A parse session. |
_term | An input term. Must be a terminal. |
◆ s3_cfg_print_entry()
Print a CFG parse entry. It is a single stage of a single rule expansion. For reference, lookup chart parsers.
- Parameters
-
_cfg | A CFG parser. |
_entry | A CFG parse entry. |
_out | An output stream. |
◆ s3_cfg_print_parse()
Print a parse session. This will print all active entries in the parse, including unfinished parses.
- Parameters
-
_cfg | A CFG parser. |
_parse | A parse session. |
_out | An output stream. |
◆ s3_cfg_print_rule()
Print a CFG expansion rule.
- Parameters
-
_cfg | A CFG parser. |
_rule | A CFG expansion rule. |
_out | An output stream. |
◆ s3_cfg_read_simple()
Read a CFG from a plain-text file. The parser structure must be freed afterwards.
- Parameters
-
- Returns
- A CFG parser.
◆ s3_cfg_read_srgs()
s3_cfg_t* s3_cfg_read_srgs |
( |
const char * |
_fn | ) |
|
Read a CFG from a XML-based SRGS file. The parser structure must be freed afterwards. For more information on SRGS, visit http://www.w3.org/TR/speech-grammar/.
- Parameters
-
- Returns
- A CFG parser.
◆ s3_cfg_rescore()
void s3_cfg_rescore |
( |
s3_cfg_t * |
_cfg, |
|
|
logmath_t * |
logmath |
|
) |
| |
◆ s3_cfg_str2id()
Convert a term string representation to a term id. If the term does not already exist, assign it a new id.
- Parameters
-
_cfg | A CFG parser. |
_item | A term string representation. |
- Returns
- A term id.
◆ s3_cfg_write_simple()
void s3_cfg_write_simple |
( |
s3_cfg_t * |
_cfg, |
|
|
const char * |
_fn |
|
) |
| |
Write the CFG to a plain-text file.
- Parameters
-
_cfg | A CFG parser. |
_fn | An output filename. |
- Returns
- 0 for success. -1 for failure.