Edinburgh Speech Tools  2.1-release
EST_SCFG Class Reference

A class representing a stochastic context free grammar (SCFG). More...

#include <include/EST_SCFG.h>

Inheritance diagram for EST_SCFG:
Collaboration diagram for EST_SCFG:

Public Member Functions

Constructor and initialisation functions
 EST_SCFG ()
 
 EST_SCFG (LISP rules)
 Initialize from a set of rules. More...
 
 ~EST_SCFG ()
 
file i/o functions
EST_read_status load (const EST_String &filename)
 Load grammar from named file. More...
 
EST_write_status save (const EST_String &filename)
 Save current grammar to named file. More...
 

utility functions

SCFGRuleList rules
 The rules themselves. More...
 
void set_rules (LISP rules)
 Set (or reset) rules from external source after construction. More...
 
LISP get_rules ()
 Return rules as LISP list. More...
 
int distinguished_symbol () const
 
void find_terms_nonterms (EST_StrList &nt, EST_StrList &t, LISP rules)
 
EST_String nonterminal (int p) const
 Convert nonterminal index to string form. More...
 
EST_String terminal (int m) const
 Convert terminal index to string form. More...
 
int nonterminal (const EST_String &p) const
 Convert nonterminal string to index. More...
 
int terminal (const EST_String &m) const
 Convert terminal string to index. More...
 
int num_nonterminals () const
 Number of nonterminals. More...
 
int num_terminals () const
 Number of terminals. More...
 
double prob_B (int p, int q, int r) const
 The rule probability of given binary rule. More...
 
double prob_U (int p, int m) const
 The rule probability of given unary rule. More...
 
void set_rule_prob_cache ()
 (re-)set rule probability caches More...
 

Detailed Description

A class representing a stochastic context free grammar (SCFG).

This class includes the representation of the grammar itself and methods for training and testing it against some corpus.

At presnet of grammars in Chomsky Normal Form are supported. That is rules may be binary or unary. If binary the mother an two daughters are nonterminals, if unary the mother must be nonterminal and daughter a terminal symbol.

The terminals and nonterminals symbol sets are derived automatically from the LISP representation of the rules at initialization time and are represented as EST_Discrete. The distinguished symbol is assumed to be the first mother of the first rule in the given grammar.

Definition at line 182 of file EST_SCFG.h.

Constructor & Destructor Documentation

EST_SCFG::EST_SCFG ( )

Definition at line 74 of file EST_SCFG.cc.

EST_SCFG::EST_SCFG ( LISP  rules)

Initialize from a set of rules.

Definition at line 81 of file EST_SCFG.cc.

EST_SCFG::~EST_SCFG ( void  )

Definition at line 88 of file EST_SCFG.cc.

Member Function Documentation

void EST_SCFG::set_rules ( LISP  rules)

Set (or reset) rules from external source after construction.

Definition at line 124 of file EST_SCFG.cc.

LISP EST_SCFG::get_rules ( )

Return rules as LISP list.

Definition at line 173 of file EST_SCFG.cc.

int EST_SCFG::distinguished_symbol ( ) const
inline

Definition at line 212 of file EST_SCFG.h.

void EST_SCFG::find_terms_nonterms ( EST_StrList nt,
EST_StrList t,
LISP  rules 
)

Find the terminals and nonterminals in the given grammar, adding them to the appropriate given string lists.

Definition at line 95 of file EST_SCFG.cc.

EST_String EST_SCFG::nonterminal ( int  p) const
inline

Convert nonterminal index to string form.

Definition at line 218 of file EST_SCFG.h.

EST_String EST_SCFG::terminal ( int  m) const
inline

Convert terminal index to string form.

Definition at line 220 of file EST_SCFG.h.

int EST_SCFG::nonterminal ( const EST_String p) const
inline

Convert nonterminal string to index.

Definition at line 222 of file EST_SCFG.h.

int EST_SCFG::terminal ( const EST_String m) const
inline

Convert terminal string to index.

Definition at line 224 of file EST_SCFG.h.

int EST_SCFG::num_nonterminals ( ) const
inline

Number of nonterminals.

Definition at line 226 of file EST_SCFG.h.

int EST_SCFG::num_terminals ( ) const
inline

Number of terminals.

Definition at line 228 of file EST_SCFG.h.

double EST_SCFG::prob_B ( int  p,
int  q,
int  r 
) const
inline

The rule probability of given binary rule.

Definition at line 230 of file EST_SCFG.h.

double EST_SCFG::prob_U ( int  p,
int  m 
) const
inline

The rule probability of given unary rule.

Definition at line 232 of file EST_SCFG.h.

void EST_SCFG::set_rule_prob_cache ( )

(re-)set rule probability caches

Definition at line 260 of file EST_SCFG.cc.

EST_read_status EST_SCFG::load ( const EST_String filename)

Load grammar from named file.

Definition at line 197 of file EST_SCFG.cc.

EST_write_status EST_SCFG::save ( const EST_String filename)

Save current grammar to named file.

Definition at line 208 of file EST_SCFG.cc.

Member Data Documentation

SCFGRuleList EST_SCFG::rules

The rules themselves.

Definition at line 211 of file EST_SCFG.h.


The documentation for this class was generated from the following files: