Public Member Functions | Static Public Member Functions | Static Public Attributes

fst::SymbolTable Class Reference

namespace internal More...

#include <fst/symbol-table.h>

Collaboration diagram for fst::SymbolTable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SymbolTable ()
 Constructs symbol table with an unspecified name.
 SymbolTable (const string &name)
 Constructs symbol table with a unique name.
virtual ~SymbolTable ()
virtual SymbolTableCopy () const
virtual int64 AddSymbol (const string &symbol, int64 key)
virtual int64 AddSymbol (const string &symbol)
virtual void AddTable (const SymbolTable &table)
virtual void RemoveSymbol (int64 key)
virtual const string & Name () const
 Returns the name of the symbol table.
virtual void SetName (const string &new_name)
 Sets the name of the symbol table.
virtual string CheckSum () const
virtual string LabeledCheckSum () const
 Same as CheckSum(), but returns an label-dependent version.
virtual bool Write (std::ostream &strm) const
bool Write (const string &filename) const
virtual bool WriteText (std::ostream &strm, const SymbolTableTextOptions &opts=SymbolTableTextOptions()) const
 Dump a text representation of the symbol table via a stream.
bool WriteText (const string &filename) const
 Dump an 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 bool Member (int64 key) const
virtual bool Member (const string &symbol) const
virtual int64 AvailableKey () const
virtual size_t NumSymbols () const
virtual int64 GetNthKey (ssize_t pos) const

Static Public Member Functions

static SymbolTableReadText (std::istream &strm, const string &name, const SymbolTableTextOptions &opts=SymbolTableTextOptions())
static SymbolTableReadText (const string &filename, const SymbolTableTextOptions &opts=SymbolTableTextOptions())
 Reads a text representation of the symbol table.
static SymbolTableRead (std::istream &strm, const SymbolTableReadOptions &opts)
static SymbolTableRead (std::istream &strm, const string &source)
 Reads a binary dump of the symbol table from a stream.
static SymbolTableRead (const string &filename)
 Reads a binary dump of the symbol table.

Static Public Attributes

static constexpr int64 kNoSymbol = -1
 namespace internal

Detailed Description

namespace internal

Symbol (string) to integer (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 217 of file symbol-table.h.


Constructor & Destructor Documentation

fst::SymbolTable::SymbolTable (  )  [inline]

Constructs symbol table with an unspecified name.

Definition at line 222 of file symbol-table.h.

fst::SymbolTable::SymbolTable ( const string &  name  )  [inline, explicit]

Constructs symbol table with a unique name.

Definition at line 226 of file symbol-table.h.

virtual fst::SymbolTable::~SymbolTable (  )  [inline, virtual]

Definition at line 229 of file symbol-table.h.


Member Function Documentation

virtual int64 fst::SymbolTable::AddSymbol ( const string &  symbol,
int64  key 
) [inline, virtual]

Adds 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 290 of file symbol-table.h.

virtual int64 fst::SymbolTable::AddSymbol ( const string &  symbol  )  [inline, virtual]

Adds a symbol to the table. The associated value key is automatically assigned by the symbol table.

Definition at line 297 of file symbol-table.h.

void fst::SymbolTable::AddTable ( const SymbolTable table  )  [virtual]

Adds 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 226 of file symbol-table.cc.

virtual int64 fst::SymbolTable::AvailableKey (  )  const [inline, virtual]

Returns the current available key (i.e., highest key + 1) in the symbol table.

Definition at line 376 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. Deprecated.

Definition at line 325 of file symbol-table.h.

virtual SymbolTable* fst::SymbolTable::Copy (  )  const [inline, virtual]

-------------------------------------------------------- Derivable Interface (final) -------------------------------------------------------- Creates a reference counted copy.

Definition at line 286 of file symbol-table.h.

virtual string fst::SymbolTable::Find ( int64  key  )  const [inline, virtual]

Returns the string associated with the key. If the key is out of range (<0, >max), returns an empty string.

Definition at line 358 of file symbol-table.h.

virtual int64 fst::SymbolTable::Find ( const string &  symbol  )  const [inline, virtual]

Returns the key associated with the symbol. If the symbol does not exist, SymbolTable::kNoSymbol is returned.

Definition at line 362 of file symbol-table.h.

virtual int64 fst::SymbolTable::Find ( const char *  symbol  )  const [inline, virtual]

Returns the key associated with the symbol. If the symbol does not exist, SymbolTable::kNoSymbol is returned.

Definition at line 366 of file symbol-table.h.

virtual int64 fst::SymbolTable::GetNthKey ( ssize_t  pos  )  const [inline, virtual]

Definition at line 382 of file symbol-table.h.

virtual string fst::SymbolTable::LabeledCheckSum (  )  const [inline, virtual]

Same as CheckSum(), but returns an label-dependent version.

Definition at line 328 of file symbol-table.h.

virtual bool fst::SymbolTable::Member ( int64  key  )  const [inline, virtual]

Definition at line 368 of file symbol-table.h.

virtual bool fst::SymbolTable::Member ( const string &  symbol  )  const [inline, virtual]

Definition at line 370 of file symbol-table.h.

virtual const string& fst::SymbolTable::Name (  )  const [inline, virtual]

Returns the name of the symbol table.

Definition at line 315 of file symbol-table.h.

virtual size_t fst::SymbolTable::NumSymbols (  )  const [inline, virtual]

Returns the current number of symbols in table (not necessarily equal to AvailableKey()).

Definition at line 380 of file symbol-table.h.

static SymbolTable* fst::SymbolTable::Read ( std::istream &  strm,
const string &  source 
) [inline, static]

Reads a binary dump of the symbol table from a stream.

Definition at line 264 of file symbol-table.h.

static SymbolTable* fst::SymbolTable::Read ( const string &  filename  )  [inline, static]

Reads a binary dump of the symbol table.

Definition at line 272 of file symbol-table.h.

static SymbolTable* fst::SymbolTable::Read ( std::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 257 of file symbol-table.h.

static SymbolTable* fst::SymbolTable::ReadText ( const string &  filename,
const SymbolTableTextOptions opts = SymbolTableTextOptions() 
) [inline, static]

Reads a text representation of the symbol table.

Definition at line 245 of file symbol-table.h.

static SymbolTable* fst::SymbolTable::ReadText ( std::istream &  strm,
const string &  name,
const SymbolTableTextOptions opts = SymbolTableTextOptions() 
) [inline, static]

Reads a text representation of the symbol table from an istream. Pass a name to give the resulting SymbolTable.

Definition at line 233 of file symbol-table.h.

virtual void fst::SymbolTable::RemoveSymbol ( int64  key  )  [inline, virtual]

Definition at line 309 of file symbol-table.h.

virtual void fst::SymbolTable::SetName ( const string &  new_name  )  [inline, virtual]

Sets the name of the symbol table.

Definition at line 318 of file symbol-table.h.

virtual bool fst::SymbolTable::Write ( std::ostream &  strm  )  const [inline, virtual]

Definition at line 330 of file symbol-table.h.

bool fst::SymbolTable::Write ( const string &  filename  )  const [inline]

Definition at line 332 of file symbol-table.h.

bool fst::SymbolTable::WriteText ( std::ostream &  strm,
const SymbolTableTextOptions opts = SymbolTableTextOptions() 
) const [virtual]

Dump a text representation of the symbol table via a stream.

Definition at line 233 of file symbol-table.cc.

bool fst::SymbolTable::WriteText ( const string &  filename  )  const [inline]

Dump an text representation of the symbol table.

Definition at line 347 of file symbol-table.h.


Member Data Documentation

constexpr int64 fst::SymbolTable::kNoSymbol = -1 [static]

namespace internal

Definition at line 219 of file symbol-table.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines