#include <include/EST_SCFG.h>
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... | |
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.
EST_SCFG::EST_SCFG | ( | ) |
Definition at line 71 of file EST_SCFG.cc.
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 | ( | void | ) |
Definition at line 84 of file EST_SCFG.cc.
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.
LISP EST_SCFG::get_rules | ( | ) |
Return rules as LISP list.
Definition at line 169 of file EST_SCFG.cc.
|
inline |
Definition at line 208 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.
|
inline |
Convert nonterminal index to string form.
Definition at line 214 of file EST_SCFG.h.
|
inline |
Convert terminal index to string form.
Definition at line 216 of file EST_SCFG.h.
|
inline |
Convert nonterminal string to index.
Definition at line 218 of file EST_SCFG.h.
|
inline |
Convert terminal string to index.
Definition at line 220 of file EST_SCFG.h.
|
inline |
Number of nonterminals.
Definition at line 222 of file EST_SCFG.h.
|
inline |
Number of terminals.
Definition at line 224 of file EST_SCFG.h.
|
inline |
The rule probability of given binary rule.
Definition at line 226 of file EST_SCFG.h.
|
inline |
The rule probability of given unary rule.
Definition at line 228 of file EST_SCFG.h.
void EST_SCFG::set_rule_prob_cache | ( | ) |
(re-)set rule probability caches
Definition at line 256 of file EST_SCFG.cc.
EST_read_status EST_SCFG::load | ( | const EST_String & | filename | ) |
Load grammar from named file.
Definition at line 193 of file EST_SCFG.cc.
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.
SCFGRuleList EST_SCFG::rules |
The rules themselves.
Definition at line 207 of file EST_SCFG.h.