Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
reranker::StaticSymbolTable Class Reference

A converter from symbols (strings) to int indices. More...

#include <symbol-table.H>

Inheritance diagram for reranker::StaticSymbolTable:
reranker::Symbols

Public Member Functions

virtual const_iterator begin ()
 
virtual const_iterator end ()
 
virtual size_t size () const
 Returns the number of symbols in this table. More...
 
virtual int GetIndex (const string &symbol)
 Converts the specified symbol to a unique integer. More...
 
virtual const string & GetSymbol (int index) const
 Returns the unique symbol for the specified index, or the empty string if the specified index does not map to any symbol in this symbol table. More...
 
virtual void SetIndex (const string &symbol, int index)
 
virtual void Clear ()
 Clears all symbols from this symbol table. More...
 
virtual SymbolsClone () const
 Creates a newly-constructed clone of this Symbols instance that has the same runtime type. More...
 
virtual ostream & Output (ostream &os)
 Outputs the symbol table to the specified output stream in a simple format, one symbol-to-index mapping per line: More...
 
- Public Member Functions inherited from reranker::Symbols
virtual ~Symbols ()
 

Additional Inherited Members

- Public Types inherited from reranker::Symbols
typedef unordered_map< string,
int >::const_iterator 
const_iterator
 
- Static Protected Attributes inherited from reranker::Symbols
static string null_symbol
 

Detailed Description

A converter from symbols (strings) to int indices.

This symbol table implementation always adds symbols to its internal symbol table and never removes them.

Implementation note:
Instances of this class provide the interface to convert symbols to int’s, but underlyingly there is a static map, so multiple instances of this class are all “viewing” the same static data structure, hence the name of this Symbols implementation.

Definition at line 120 of file symbol-table.H.

Member Function Documentation

virtual const_iterator reranker::StaticSymbolTable::begin ( )
inlinevirtual

Implements reranker::Symbols.

Definition at line 122 of file symbol-table.H.

virtual void reranker::StaticSymbolTable::Clear ( )
inlinevirtual

Clears all symbols from this symbol table.

Implements reranker::Symbols.

Definition at line 154 of file symbol-table.H.

virtual Symbols* reranker::StaticSymbolTable::Clone ( ) const
inlinevirtual

Creates a newly-constructed clone of this Symbols instance that has the same runtime type.

The caller will be responsible for destroying the returned instance.

Returns
a clone of this Symbols instance that has the same runtime type

Implements reranker::Symbols.

Definition at line 160 of file symbol-table.H.

virtual const_iterator reranker::StaticSymbolTable::end ( )
inlinevirtual

Implements reranker::Symbols.

Definition at line 123 of file symbol-table.H.

int reranker::StaticSymbolTable::GetIndex ( const string &  symbol)
virtual

Converts the specified symbol to a unique integer.

TODO(dbikel,kbhall): Protect access to static symbol table via a mutex of some kind.

Parameters
symbolthe symbol to convert
Returns
a unique integer for the specified symbol

Implements reranker::Symbols.

Definition at line 54 of file symbol-table.C.

const string & reranker::StaticSymbolTable::GetSymbol ( int  index) const
virtual

Returns the unique symbol for the specified index, or the empty string if the specified index does not map to any symbol in this symbol table.

Implements reranker::Symbols.

Definition at line 67 of file symbol-table.C.

virtual ostream& reranker::StaticSymbolTable::Output ( ostream &  os)
inlinevirtual

Outputs the symbol table to the specified output stream in a simple format, one symbol-to-index mapping per line:

<symbol> <tab> <index>

where

<symbol> ::= an indexed string symbol
<tab> ::= a tab character, '\t'
<index> ::= a unique integer for <symbol>
Parameters
osthe output stream to which to output the symbol table
Returns
the specified output stream

Implements reranker::Symbols.

Definition at line 165 of file symbol-table.H.

virtual void reranker::StaticSymbolTable::SetIndex ( const string &  symbol,
int  index 
)
inlinevirtual

Implements reranker::Symbols.

Definition at line 141 of file symbol-table.H.

virtual size_t reranker::StaticSymbolTable::size ( ) const
inlinevirtual

Returns the number of symbols in this table.

Implements reranker::Symbols.

Definition at line 126 of file symbol-table.H.


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