blob: 4a4ced3421f7fe65ff8f33ddcffe2c473168a775 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include "suffix_array_sampler.h"
#include "data_array.h"
#include "phrase_location.h"
#include "suffix_array.h"
namespace extractor {
SuffixArrayRangeSampler::SuffixArrayRangeSampler(
shared_ptr<SuffixArray> source_suffix_array, int max_samples) :
BackoffSampler(source_suffix_array->GetData(), max_samples),
source_suffix_array(source_suffix_array) {}
SuffixArrayRangeSampler::SuffixArrayRangeSampler() {}
int SuffixArrayRangeSampler::GetNumSubpatterns(const PhraseLocation&) const {
return 1;
}
int SuffixArrayRangeSampler::GetRangeLow(
const PhraseLocation& location) const {
return location.sa_low;
}
int SuffixArrayRangeSampler::GetRangeHigh(
const PhraseLocation& location) const {
return location.sa_high;
}
int SuffixArrayRangeSampler::GetPosition(
const PhraseLocation&, int position) const {
return source_suffix_array->GetSuffix(position);
}
void SuffixArrayRangeSampler::AppendMatching(
vector<int>& samples, int index, const PhraseLocation&) const {
samples.push_back(source_suffix_array->GetSuffix(index));
}
} // namespace extractor
|