Symbol (string) to int and reverse mapping. More...
#include <fst/symbol-table.h>

Public Member Functions | |
| SymbolTable (const string &name) | |
| Construct symbol table with a unique name. | |
| SymbolTable (const SymbolTable &table) | |
| Create a reference counted copy. | |
| virtual | ~SymbolTable () |
| virtual SymbolTable * | Copy () const |
| virtual int64 | AddSymbol (const string &symbol, int64 key) |
| virtual int64 | AddSymbol (const string &symbol) |
| virtual void | AddTable (const SymbolTable &table) |
| virtual const string & | Name () const |
| return the name of the symbol table | |
| virtual string | CheckSum () const |
| virtual string | LabeledCheckSum () const |
| Same as CheckSum(), but this returns an label-dependent version. | |
| virtual bool | Write (ostream &strm) const |
| bool | Write (const string &filename) const |
| virtual bool | WriteText (ostream &strm) const |
| Dump an ascii text representation of the symbol table via a stream. | |
| bool | WriteText (const string &filename) const |
| Dump an ascii text representation of the symbol table. | |
| virtual string | Find (int64 key) const |
| virtual int64 | Find (const string &symbol) const |
| virtual int64 | Find (const char *symbol) const |
| virtual int64 | AvailableKey (void) const |
| virtual size_t | NumSymbols (void) const |
| virtual int64 | GetNthKey (ssize_t pos) const |
Static Public Member Functions | |
| static SymbolTable * | ReadText (istream &strm, const string &name, bool allow_negative=false) |
| static SymbolTable * | ReadText (const string &filename, bool allow_negative=false) |
| read an ascii representation of the symbol table | |
| static SymbolTable * | Read (istream &strm, const SymbolTableReadOptions &opts) |
| static SymbolTable * | Read (istream &strm, const string &source) |
| read a binary dump of the symbol table from a stream | |
| static SymbolTable * | Read (const string &filename) |
| read a binary dump of the symbol table | |
Static Public Attributes | |
| static const int64 | kNoSymbol = -1 |
Symbol (string) to int and reverse mapping.
The SymbolTable implements the mappings of labels to strings and reverse. SymbolTables are used to describe the alphabet of the input and output labels for arcs in a Finite State Transducer.
SymbolTables are reference counted and can therefore be shared across multiple machines. For example a language model grammar G, with a SymbolTable for the words in the language model can share this symbol table with the lexical representation L o G.
Definition at line 209 of file symbol-table.h.
| fst::SymbolTable::SymbolTable | ( | const string & | name | ) | [inline] |
Construct symbol table with a unique name.
Definition at line 214 of file symbol-table.h.
| fst::SymbolTable::SymbolTable | ( | const SymbolTable & | table | ) | [inline] |
Create a reference counted copy.
Definition at line 217 of file symbol-table.h.
| virtual fst::SymbolTable::~SymbolTable | ( | ) | [inline, virtual] |
Derefence implentation object. When reference count hits 0, delete implementation.
Definition at line 223 of file symbol-table.h.
Add a symbol with given key to table. A symbol table also keeps track of the last available key (highest key value in the symbol table).
Definition at line 292 of file symbol-table.h.
| virtual int64 fst::SymbolTable::AddSymbol | ( | const string & | symbol | ) | [inline, virtual] |
Add a symbol to the table. The associated value key is automatically assigned by the symbol table.
Definition at line 299 of file symbol-table.h.
| void fst::SymbolTable::AddTable | ( | const SymbolTable & | table | ) | [virtual] |
Add another symbol table to this table. All key values will be offset by the current available key (highest key value in the symbol table). Note string symbols with the same key value with still have the same key value after the symbol table has been merged, but a different value. Adding symbol tables do not result in changes in the base table.
Definition at line 222 of file symbol-table.cc.
| virtual int64 fst::SymbolTable::AvailableKey | ( | void | ) | const [inline, virtual] |
Return the current available key (i.e highest key number+1) in the symbol table
Definition at line 373 of file symbol-table.h.
| virtual string fst::SymbolTable::CheckSum | ( | ) | const [inline, virtual] |
Return the label-agnostic MD5 check-sum for this table. All new symbols added to the table will result in an updated checksum.
Definition at line 318 of file symbol-table.h.
| virtual SymbolTable* fst::SymbolTable::Copy | ( | ) | const [inline, virtual] |
-------------------------------------------------------- Derivable Interface (final) -------------------------------------------------------- create a reference counted copy
Definition at line 285 of file symbol-table.h.
| virtual int64 fst::SymbolTable::Find | ( | const char * | symbol | ) | const [inline, virtual] |
Return the key associated with the symbol. If the symbol does not exists, log error and return SymbolTable::kNoSymbol
Definition at line 367 of file symbol-table.h.
| virtual string fst::SymbolTable::Find | ( | int64 | key | ) | const [inline, virtual] |
Return the string associated with the key. If the key is out of range (<0, >max), log error and return an empty string.
Definition at line 355 of file symbol-table.h.
| virtual int64 fst::SymbolTable::Find | ( | const string & | symbol | ) | const [inline, virtual] |
Return the key associated with the symbol. If the symbol does not exists, log error and return SymbolTable::kNoSymbol
Definition at line 361 of file symbol-table.h.
| virtual int64 fst::SymbolTable::GetNthKey | ( | ssize_t | pos | ) | const [inline, virtual] |
Definition at line 383 of file symbol-table.h.
| virtual string fst::SymbolTable::LabeledCheckSum | ( | ) | const [inline, virtual] |
Same as CheckSum(), but this returns an label-dependent version.
Definition at line 323 of file symbol-table.h.
| virtual const string& fst::SymbolTable::Name | ( | ) | const [inline, virtual] |
return the name of the symbol table
Definition at line 312 of file symbol-table.h.
| virtual size_t fst::SymbolTable::NumSymbols | ( | void | ) | const [inline, virtual] |
Return the current number of symbols in table (not necessarily equal to AvailableKey())
Definition at line 379 of file symbol-table.h.
| static SymbolTable* fst::SymbolTable::Read | ( | const string & | filename | ) | [inline, static] |
read a binary dump of the symbol table
Definition at line 272 of file symbol-table.h.
| static SymbolTable* fst::SymbolTable::Read | ( | istream & | strm, | |
| const string & | source | |||
| ) | [inline, static] |
read a binary dump of the symbol table from a stream
Definition at line 265 of file symbol-table.h.
| static SymbolTable* fst::SymbolTable::Read | ( | istream & | strm, | |
| const SymbolTableReadOptions & | opts | |||
| ) | [inline, static] |
WARNING: Reading via symbol table read options should not be used. This is a temporary work around.
Definition at line 255 of file symbol-table.h.
| static SymbolTable* fst::SymbolTable::ReadText | ( | const string & | filename, | |
| bool | allow_negative = false | |||
| ) | [inline, static] |
read an ascii representation of the symbol table
Definition at line 242 of file symbol-table.h.
| static SymbolTable* fst::SymbolTable::ReadText | ( | istream & | strm, | |
| const string & | name, | |||
| bool | allow_negative = false | |||
| ) | [inline, static] |
Read an ascii representation of the symbol table from an istream. Pass a name to give the resulting SymbolTable.
Definition at line 229 of file symbol-table.h.
| virtual bool fst::SymbolTable::Write | ( | ostream & | strm | ) | const [inline, virtual] |
Definition at line 327 of file symbol-table.h.
| bool fst::SymbolTable::Write | ( | const string & | filename | ) | const [inline] |
Definition at line 331 of file symbol-table.h.
| bool fst::SymbolTable::WriteText | ( | const string & | filename | ) | const [inline] |
Dump an ascii text representation of the symbol table.
Definition at line 344 of file symbol-table.h.
| bool fst::SymbolTable::WriteText | ( | ostream & | strm | ) | const [virtual] |
Dump an ascii text representation of the symbol table via a stream.
Definition at line 227 of file symbol-table.cc.
const int64 fst::SymbolTable::kNoSymbol = -1 [static] |
Definition at line 211 of file symbol-table.h.
1.7.1