#include <include/EST_SCFG.h>
Public Member Functions | |
Constructor and initialisation functions | |
EST_SCFG () | |
EST_SCFG (LISP rules) | |
Initialize from a set of rules. | |
~EST_SCFG () | |
file i/o functions | |
EST_read_status | load (const EST_String &filename) |
Load grammar from named file. | |
EST_write_status | save (const EST_String &filename) |
Save current grammar to named file. | |
utility functions | |
SCFGRuleList | rules |
The rules themselves. | |
void | set_rules (LISP rules) |
Set (or reset) rules from external source after construction. | |
LISP | get_rules () |
Return rules as LISP list. | |
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. | |
EST_String | terminal (int m) const |
Convert terminal index to string form. | |
int | nonterminal (const EST_String &p) const |
Convert nonterminal string to index. | |
int | terminal (const EST_String &m) const |
Convert terminal string to index. | |
int | num_nonterminals () const |
Number of nonterminals. | |
int | num_terminals () const |
Number of terminals. | |
double | prob_B (int p, int q, int r) const |
The rule probability of given binary rule. | |
double | prob_U (int p, int m) const |
The rule probability of given unary rule. | |
void | set_rule_prob_cache () |
(re-)set rule probability caches | |
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}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.
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.