-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValueInterpolationStrategy.cpp
68 lines (55 loc) · 1.47 KB
/
ValueInterpolationStrategy.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* ValueInterpolationStrategy.cpp
*
* Created on: Nov 14, 2017
* Author: louis
*/
#include "ValueInterpolationStrategy.h"
namespace SLM
{
// d - cd - bcd - b_d - abcd - a_cd - ab_d - a__d
std::string ValueInterpolationWeights::toString() const
{
std::stringstream ss;
ss << w_d << "-" << w_cd << "-" << w_bcd << "-" << w_b_d << "-"
<< w_abcd << "-" << w_a_cd << "-" << w_ab_d << "-" << w_a__d;
return ss.str();
}
ValueInterpolationStrategy::ValueInterpolationStrategy(ValueInterpolationWeights& viw) : weights(viw)
{}
ValueInterpolationStrategy::~ValueInterpolationStrategy()
{}
double ValueInterpolationStrategy::get(const Pattern& context)
{
//std::cout << "\t\t" << context.size() << "-" << weights.toString() << std::endl;
int contextSize = context.size();
if(contextSize == 0)
{
return weights.w_d;
}
if(contextSize == 1)
{
return weights.w_cd;
}
if(contextSize == 2)
{
if(context.isgap(1))
return weights.w_b_d;
return weights.w_bcd;
}
if(contextSize == 3)
{
if(context.isgap(1) && !context.isgap(2))
return weights.w_a_cd;
if(context.isgap(2) && !context.isgap(1))
return weights.w_ab_d;
if(context.isgap(1) && context.isgap(2))
return weights.w_a__d;
return weights.w_abcd;
}
}
std::string ValueInterpolationStrategy::name() const
{
return "value-" + weights.toString();
}
}