@@ -54,7 +54,7 @@ template <class Weights> class ActivateUnigram {
54
54
Weights *modify_;
55
55
};
56
56
57
- // Find the lower order entry, inserting blanks along the way as necessary.
57
+ // Find the lower order entry, inserting blanks along the way as necessary.
58
58
template <class Value > void FindLower (
59
59
const std::vector<uint64_t > &keys,
60
60
typename Value::Weights &unigram,
@@ -64,7 +64,7 @@ template <class Value> void FindLower(
64
64
typename Value::ProbingEntry entry;
65
65
// Backoff will always be 0.0. We'll get the probability and rest in another pass.
66
66
entry.value .backoff = kNoExtensionBackoff ;
67
- // Go back and find the longest right-aligned entry, informing it that it extends left. Normally this will match immediately, but sometimes SRI is dumb.
67
+ // Go back and find the longest right-aligned entry, informing it that it extends left. Normally this will match immediately, but sometimes SRI is dumb.
68
68
for (int lower = keys.size () - 2 ; ; --lower) {
69
69
if (lower == -1 ) {
70
70
between.push_back (&unigram);
@@ -77,11 +77,11 @@ template <class Value> void FindLower(
77
77
}
78
78
}
79
79
80
- // Between usually has single entry, the value to adjust. But sometimes SRI stupidly pruned entries so it has unitialized blank values to be set here.
80
+ // Between usually has single entry, the value to adjust. But sometimes SRI stupidly pruned entries so it has unitialized blank values to be set here.
81
81
template <class Added , class Build > void AdjustLower (
82
82
const Added &added,
83
83
const Build &build,
84
- std::vector<typename Build::Value::Weights *> &between,
84
+ std::vector<typename Build::Value::Weights *> &between,
85
85
const unsigned int n,
86
86
const std::vector<WordIndex> &vocab_ids,
87
87
typename Build::Value::Weights *unigrams,
@@ -93,14 +93,14 @@ template <class Added, class Build> void AdjustLower(
93
93
}
94
94
typedef util::ProbingHashTable<typename Value::ProbingEntry, util::IdentityHash> Middle;
95
95
float prob = -fabs (between.back ()->prob );
96
- // Order of the n-gram on which probabilities are based.
96
+ // Order of the n-gram on which probabilities are based.
97
97
unsigned char basis = n - between.size ();
98
98
assert (basis != 0 );
99
99
typename Build::Value::Weights **change = &between.back ();
100
100
// Skip the basis.
101
101
--change;
102
102
if (basis == 1 ) {
103
- // Hallucinate a bigram based on a unigram's backoff and a unigram probability.
103
+ // Hallucinate a bigram based on a unigram's backoff and a unigram probability.
104
104
float &backoff = unigrams[vocab_ids[1 ]].backoff ;
105
105
SetExtension (backoff);
106
106
prob += backoff;
@@ -128,14 +128,14 @@ template <class Added, class Build> void AdjustLower(
128
128
typename std::vector<typename Value::Weights *>::const_iterator i (between.begin ());
129
129
build.MarkExtends (**i, added);
130
130
const typename Value::Weights *longer = *i;
131
- // Everything has probability but is not marked as extending.
131
+ // Everything has probability but is not marked as extending.
132
132
for (++i; i != between.end (); ++i) {
133
133
build.MarkExtends (**i, *longer);
134
134
longer = *i;
135
135
}
136
136
}
137
137
138
- // Continue marking lower entries even they know that they extend left. This is used for upper/lower bounds.
138
+ // Continue marking lower entries even they know that they extend left. This is used for upper/lower bounds.
139
139
template <class Build > void MarkLower (
140
140
const std::vector<uint64_t > &keys,
141
141
const Build &build,
@@ -145,7 +145,7 @@ template <class Build> void MarkLower(
145
145
const typename Build::Value::Weights &longer) {
146
146
if (start_order == 0 ) return ;
147
147
typename util::ProbingHashTable<typename Build::Value::ProbingEntry, util::IdentityHash>::MutableIterator iter;
148
- // Hopefully the compiler will realize that if MarkExtends always returns false, it can simplify this code.
148
+ // Hopefully the compiler will realize that if MarkExtends always returns false, it can simplify this code.
149
149
for (int even_lower = start_order - 2 /* index in middle */ ; ; --even_lower) {
150
150
if (even_lower == -1 ) {
151
151
build.MarkExtends (unigram, longer);
@@ -168,7 +168,6 @@ template <class Build, class Activate, class Store> void ReadNGrams(
168
168
Store &store,
169
169
PositiveProbWarn &warn) {
170
170
typedef typename Build::Value Value;
171
- typedef util::ProbingHashTable<typename Value::ProbingEntry, util::IdentityHash> Middle;
172
171
assert (n >= 2 );
173
172
ReadNGramHeader (f, n);
174
173
@@ -186,7 +185,7 @@ template <class Build, class Activate, class Store> void ReadNGrams(
186
185
for (unsigned int h = 1 ; h < n - 1 ; ++h) {
187
186
keys[h] = detail::CombineWordHash (keys[h-1 ], vocab_ids[h+1 ]);
188
187
}
189
- // Initially the sign bit is on, indicating it does not extend left. Most already have this but there might +0.0.
188
+ // Initially the sign bit is on, indicating it does not extend left. Most already have this but there might +0.0.
190
189
util::SetSign (entry.value .prob );
191
190
entry.key = keys[n-2 ];
192
191
@@ -203,7 +202,7 @@ template <class Build, class Activate, class Store> void ReadNGrams(
203
202
204
203
} // namespace
205
204
namespace detail {
206
-
205
+
207
206
template <class Value > uint8_t *HashedSearch<Value>::SetupMemory(uint8_t *start, const std::vector<uint64_t > &counts, const Config &config) {
208
207
std::size_t allocated = Unigram::Size (counts[0 ]);
209
208
unigram_ = Unigram (start, counts[0 ], allocated);
0 commit comments