summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/dict.h5
-rw-r--r--utils/fast_sparse_vector.h8
-rw-r--r--utils/fdict.h1
-rw-r--r--utils/sampler.h2
-rw-r--r--utils/weights.cc1
5 files changed, 13 insertions, 4 deletions
diff --git a/utils/dict.h b/utils/dict.h
index 75ea3def..33cca6cf 100644
--- a/utils/dict.h
+++ b/utils/dict.h
@@ -1,7 +1,7 @@
#ifndef DICT_H_
#define DICT_H_
-
+#include <iostream>
#include <cassert>
#include <cstring>
@@ -73,7 +73,8 @@ class Dict {
inline const std::string& Convert(const WordID& id) const {
if (id == 0) return b0_;
- assert(id <= (int)words_.size());
+ //assert(id <= (int)words_.size());
+ if (id < 0 || id > (int)words_.size()) return b0_;
return words_[id-1];
}
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h
index 1301581a..8daaac85 100644
--- a/utils/fast_sparse_vector.h
+++ b/utils/fast_sparse_vector.h
@@ -214,6 +214,14 @@ class FastSparseVector {
}
return *this;
}
+ template <typename O>
+ inline FastSparseVector<O>& plus_eq_v_times_s(const FastSparseVector<O>& other, const O scalar) {
+ const typename FastSparseVector<O>::const_iterator end = other.end();
+ for (typename FastSparseVector<O>::const_iterator it = other.begin(); it != end; ++it) {
+ get_or_create_bin(it->first) += it->second * scalar;
+ }
+ return *this;
+ }
inline FastSparseVector& operator-=(const FastSparseVector& other) {
const typename FastSparseVector::const_iterator end = other.end();
for (typename FastSparseVector::const_iterator it = other.begin(); it != end; ++it) {
diff --git a/utils/fdict.h b/utils/fdict.h
index f0871b9a..9c8d7cde 100644
--- a/utils/fdict.h
+++ b/utils/fdict.h
@@ -33,6 +33,7 @@ struct FD {
hash_ = new PerfectHashFunction(cmph_file);
#endif
}
+>>>>>>> upstream/master
static inline int NumFeats() {
#ifdef HAVE_CMPH
if (hash_) return hash_->number_of_keys();
diff --git a/utils/sampler.h b/utils/sampler.h
index 153e7ef1..cae660d2 100644
--- a/utils/sampler.h
+++ b/utils/sampler.h
@@ -32,7 +32,7 @@ struct RandomNumberGenerator {
std::cerr << "Warning: could not read from /dev/urandom. Seeding from clock" << std::endl;
seed = std::time(NULL);
}
- std::cerr << "Seeding random number sequence to " << seed << std::endl;
+ //std::cerr << "Seeding random number sequence to " << seed << std::endl;
return seed;
}
diff --git a/utils/weights.cc b/utils/weights.cc
index ac407dfb..f1406cbf 100644
--- a/utils/weights.cc
+++ b/utils/weights.cc
@@ -154,4 +154,3 @@ void Weights::ShowLargestFeatures(const vector<weight_t>& w) {
cerr << endl;
}
-