38 #include <unordered_map>
45 using std::unordered_map;
50 unordered_map<string, int> StaticSymbolTable::symbols_;
51 unordered_map<int, string> StaticSymbolTable::indices_to_symbols_;
55 unordered_map<string, int>::iterator it = symbols_.find(symbol);
56 if (it == symbols_.end()) {
57 size_t new_index = symbols_.size();
58 symbols_[symbol] = new_index;
59 indices_to_symbols_[new_index] = symbol;
68 unordered_map<int, string>::const_iterator it =
69 indices_to_symbols_.find(index);
75 unordered_map<string, int>::iterator it = symbols_.find(symbol);
76 if (it == symbols_.end()) {
77 size_t new_index = symbols_.size();
78 symbols_[symbol] = new_index;
79 indices_to_symbols_[new_index] = symbol;
88 unordered_map<int, string>::const_iterator it =
89 indices_to_symbols_.find(index);
virtual int GetIndex(const string &symbol)
Returns the unique index for the specified symbol.
Provides the reranker::Symbols interface as well as the reranker::StaticSymbolTable implementation...
static string null_symbol
virtual const string & GetSymbol(int index) const
Returns the unique symbol for the specified index, or the empty string if the specified index does no...
virtual int GetIndex(const string &symbol)
Converts the specified symbol to a unique integer.
virtual const string & GetSymbol(int index) const
Returns the unique symbol for the specified index, or the empty string if the specified index does no...