18 #ifndef FST_SYMBOL_TABLE_OPS_H_ 19 #define FST_SYMBOL_TABLE_OPS_H_ 28 #include <unordered_set> 38 std::unordered_set<typename Arc::Label> seen;
43 const auto sym = (input) ? aiter.Value().ilabel : aiter.Value().olabel;
47 auto pruned = std::make_unique<SymbolTable>(syms.
Name() +
"_pruned");
48 for (
const auto &stitem : syms) {
49 const auto label = stitem.Label();
50 if (seen.count(label)) pruned->
AddSymbol(stitem.Symbol(), label);
52 return pruned.release();
76 bool *right_relabel_output =
nullptr);
92 #endif // FST_SYMBOL_TABLE_OPS_H_ const std::string & Name() const
int64_t AddSymbol(std::string_view symbol, int64_t key)
SymbolTable * CompactSymbolTable(const SymbolTable &syms)
SymbolTable * FstReadSymbols(const std::string &source, bool input)
SymbolTable * PruneSymbolTable(const Fst< Arc > &fst, const SymbolTable &syms, bool input)
SymbolTable * MergeSymbolTable(const SymbolTable &left, const SymbolTable &right, bool *right_relabel_output=nullptr)
bool AddAuxiliarySymbols(const std::string &prefix, int64_t start_label, int64_t nlabels, SymbolTable *syms)