#include <event-map.h>
|
virtual bool | Map (const EventType &event, EventAnswerType *ans) const |
|
virtual void | GetChildren (std::vector< EventMap *> *out) const |
|
virtual void | MultiMap (const EventType &event, std::vector< EventAnswerType > *ans) const |
|
virtual EventMap * | Prune () const |
|
virtual EventMap * | MapValues (const unordered_set< EventKeyType > &keys_to_map, const unordered_map< EventValueType, EventValueType > &value_map) const |
|
| TableEventMap (EventKeyType key, const std::vector< EventMap *> &table) |
| Takes ownership of pointers. More...
|
|
| TableEventMap (EventKeyType key, const std::map< EventValueType, EventMap *> &map_in) |
| Takes ownership of pointers. More...
|
|
| TableEventMap (EventKeyType key, const std::map< EventValueType, EventAnswerType > &map_in) |
| This initializer creates a ConstantEventMap for each value in the map. More...
|
|
virtual void | Write (std::ostream &os, bool binary) |
| Write to stream. More...
|
|
virtual EventMap * | Copy (const std::vector< EventMap *> &new_leaves) const |
|
virtual | ~TableEventMap () |
|
EventMap * | Copy () const |
|
virtual EventAnswerType | MaxResult () const |
|
virtual | ~EventMap () |
|
Definition at line 206 of file event-map.h.
◆ TableEventMap() [1/3]
Takes ownership of pointers.
Definition at line 243 of file event-map.h.
std::vector< EventMap * > table_
◆ TableEventMap() [2/3]
Takes ownership of pointers.
Definition at line 325 of file event-map.cc.
References KALDI_ASSERT, and TableEventMap::table_.
326 if (map_in.size() == 0)
330 table_.resize(highest_val+1, NULL);
331 std::map<EventValueType, EventMap*>::const_iterator iter = map_in.begin(), end = map_in.end();
332 for (; iter != end; ++iter) {
333 KALDI_ASSERT(iter->first >= 0 && iter->first <= highest_val);
334 table_[iter->first] = iter->second;
std::vector< EventMap * > table_
#define KALDI_ASSERT(cond)
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...
◆ TableEventMap() [3/3]
This initializer creates a ConstantEventMap for each value in the map.
Definition at line 339 of file event-map.cc.
References KALDI_ASSERT, and TableEventMap::table_.
340 if (map_in.size() == 0)
344 table_.resize(highest_val+1, NULL);
345 std::map<EventValueType, EventAnswerType>::const_iterator iter = map_in.begin(), end = map_in.end();
346 for (; iter != end; ++iter) {
347 KALDI_ASSERT(iter->first >= 0 && iter->first <= highest_val);
348 table_[iter->first] =
new ConstantEventMap(iter->second);
std::vector< EventMap * > table_
#define KALDI_ASSERT(cond)
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...
◆ ~TableEventMap()
Definition at line 257 of file event-map.h.
References kaldi::DeletePointers().
void DeletePointers(std::vector< A *> *v)
Deletes any non-NULL pointers in the vector v, and sets the corresponding entries of v to NULL...
std::vector< EventMap * > table_
◆ Copy()
Implements EventMap.
Definition at line 252 of file event-map.h.
References EventMap::Copy(), and rnnlm::i.
253 std::vector<EventMap*> new_table_(
table_.size(), NULL);
std::vector< EventMap * > table_
TableEventMap(EventKeyType key, const std::vector< EventMap *> &table)
Takes ownership of pointers.
◆ GetChildren()
virtual void GetChildren |
( |
std::vector< EventMap *> * |
out | ) |
const |
|
inlinevirtual |
◆ KALDI_DISALLOW_COPY_AND_ASSIGN()
◆ Map()
Implements EventMap.
Definition at line 209 of file event-map.h.
Referenced by kaldi::TestEventMap().
213 return table_[tmp]->Map(event, ans);
std::vector< EventMap * > table_
static bool Lookup(const EventType &event, EventKeyType key, EventValueType *ans)
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...
◆ MapValues()
Implements EventMap.
Definition at line 88 of file event-map.cc.
References KALDI_ASSERT, KALDI_ERR, and EventMap::MapValues().
91 std::vector<EventMap*> table;
92 table.reserve(
table_.size());
95 if (
table_[value] != NULL) {
96 EventMap *this_map =
table_[value]->MapValues(keys_to_map, value_map);
99 if (keys_to_map.count(
key_) == 0) mapped_value = value;
101 unordered_map<EventValueType,EventValueType>::const_iterator
102 iter = value_map.find(value);
103 if (iter == value_map.end()) {
104 KALDI_ERR <<
"Could not map value " << value
105 <<
" for key " <<
key_;
107 mapped_value = iter->second;
110 if (static_cast<EventValueType>(table.size()) <= mapped_value)
111 table.resize(mapped_value + 1, NULL);
112 if (table[mapped_value] != NULL)
113 KALDI_ERR <<
"Multiple values map to the same point: this code cannot " 114 <<
"handle this case.";
115 table[mapped_value] = this_map;
std::vector< EventMap * > table_
#define KALDI_ASSERT(cond)
TableEventMap(EventKeyType key, const std::vector< EventMap *> &table)
Takes ownership of pointers.
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...
◆ MultiMap()
Implements EventMap.
Definition at line 224 of file event-map.h.
References rnnlm::i.
std::vector< EventMap * > table_
virtual void MultiMap(const EventType &event, std::vector< EventAnswerType > *ans) const
static bool Lookup(const EventType &event, EventKeyType key, EventValueType *ans)
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...
◆ Prune()
Implements EventMap.
Definition at line 71 of file event-map.cc.
References EventMap::Prune().
72 std::vector<EventMap*> table;
73 table.reserve(
table_.size());
76 if (
table_[value] != NULL) {
77 EventMap *pruned_map =
table_[value]->Prune();
78 if (pruned_map != NULL) {
79 table.resize(value + 1, NULL);
80 table[value] = pruned_map;
84 if (table.empty())
return NULL;
std::vector< EventMap * > table_
int32 EventKeyType
Things of type EventKeyType can take any value.
TableEventMap(EventKeyType key, const std::vector< EventMap *> &table)
Takes ownership of pointers.
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...
◆ Read()
Definition at line 140 of file event-map.cc.
References kaldi::ExpectToken(), EventMap::Read(), and kaldi::ReadBasicType().
Referenced by EventMap::Read().
146 std::vector<EventMap*> table(size);
148 for (
size_t t = 0; t < size; t++) {
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
static EventMap * Read(std::istream &is, bool binary)
a Read function that reads an arbitrary EventMap; also works for NULL pointers.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
int32 EventKeyType
Things of type EventKeyType can take any value.
TableEventMap(EventKeyType key, const std::vector< EventMap *> &table)
Takes ownership of pointers.
◆ Write()
void Write |
( |
std::ostream & |
os, |
|
|
bool |
binary |
|
) |
| |
|
virtual |
Write to stream.
Implements EventMap.
Definition at line 122 of file event-map.cc.
References KALDI_ERR, EventMap::Write(), kaldi::WriteBasicType(), and kaldi::WriteToken().
125 uint32 size =
table_.size();
128 for (
size_t t = 0; t < size; t++) {
133 if (!binary) os <<
'\n';
135 KALDI_ERR <<
"TableEventMap::Write(), could not write to stream.";
std::vector< EventMap * > table_
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
virtual void Write(std::ostream &os, bool binary)=0
Write to stream.
◆ key_
◆ table_
The documentation for this class was generated from the following files: