Edinburgh Speech Tools 2.4-release
EST_SCFG Class Reference

#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 \Ref{EST_Discrete}s. The distinguished symbol is assumed to be the first mother of the first rule in the given grammar.

Definition at line 178 of file EST_SCFG.h.

Constructor & Destructor Documentation

◆ EST_SCFG() [1/2]

EST_SCFG::EST_SCFG ( )

Definition at line 71 of file EST_SCFG.cc.

◆ EST_SCFG() [2/2]

EST_SCFG::EST_SCFG ( LISP  rules)

Initialize from a set of rules.

Definition at line 77 of file EST_SCFG.cc.

◆ ~EST_SCFG()

EST_SCFG::~EST_SCFG ( void  )

Definition at line 84 of file EST_SCFG.cc.

Member Function Documentation

◆ set_rules()

void EST_SCFG::set_rules ( LISP  rules)

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

Definition at line 120 of file EST_SCFG.cc.

◆ get_rules()

LISP EST_SCFG::get_rules ( )

Return rules as LISP list.

Definition at line 169 of file EST_SCFG.cc.

◆ distinguished_symbol()

int EST_SCFG::distinguished_symbol ( ) const
inline

Definition at line 208 of file EST_SCFG.h.

◆ find_terms_nonterms()

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 91 of file EST_SCFG.cc.

◆ nonterminal() [1/2]

EST_String EST_SCFG::nonterminal ( int  p) const
inline

Convert nonterminal index to string form.

Definition at line 214 of file EST_SCFG.h.

◆ terminal() [1/2]

EST_String EST_SCFG::terminal ( int  m) const
inline

Convert terminal index to string form.

Definition at line 216 of file EST_SCFG.h.

◆ nonterminal() [2/2]

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

Convert nonterminal string to index.

Definition at line 218 of file EST_SCFG.h.

◆ terminal() [2/2]

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

Convert terminal string to index.

Definition at line 220 of file EST_SCFG.h.

◆ num_nonterminals()

int EST_SCFG::num_nonterminals ( ) const
inline

Number of nonterminals.

Definition at line 222 of file EST_SCFG.h.

◆ num_terminals()

int EST_SCFG::num_terminals ( ) const
inline

Number of terminals.

Definition at line 224 of file EST_SCFG.h.

◆ prob_B()

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

The rule probability of given binary rule.

Definition at line 226 of file EST_SCFG.h.

◆ prob_U()

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

The rule probability of given unary rule.

Definition at line 228 of file EST_SCFG.h.

◆ set_rule_prob_cache()

void EST_SCFG::set_rule_prob_cache ( )

(re-)set rule probability caches

Definition at line 256 of file EST_SCFG.cc.

◆ load()

EST_read_status EST_SCFG::load ( const EST_String filename)

Load grammar from named file.

Definition at line 193 of file EST_SCFG.cc.

◆ save()

EST_write_status EST_SCFG::save ( const EST_String filename)

Save current grammar to named file.

Definition at line 204 of file EST_SCFG.cc.

Member Data Documentation

◆ rules

SCFGRuleList EST_SCFG::rules

The rules themselves.

Definition at line 207 of file EST_SCFG.h.


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