23 SG_DEBUG(
"CCanberraWordDistance created")
30 SG_DEBUG(
"CCanberraWordDistance created")
52 bool free_avec, free_bvec;
55 get_feature_vector(idx_a, alen, free_avec);
57 get_feature_vector(idx_b, blen, free_bvec);
64 while (left_idx < alen && right_idx < blen)
66 uint16_t sym=avec[left_idx];
67 if (avec[left_idx]==bvec[right_idx])
69 int32_t old_left_idx=left_idx;
70 int32_t old_right_idx=right_idx;
72 while (left_idx< alen && avec[left_idx]==sym)
75 while (right_idx< blen && bvec[right_idx]==sym)
80 ((left_idx-old_left_idx)-(right_idx-old_right_idx)))/
82 ((left_idx-old_left_idx) + (right_idx-old_right_idx)));
84 else if (avec[left_idx]<bvec[right_idx])
88 while (left_idx< alen && avec[left_idx]==sym)
96 while (right_idx< blen && bvec[right_idx]==sym)
101 while (left_idx < alen)
103 uint16_t sym=avec[left_idx];
106 while (left_idx< alen && avec[left_idx]==sym)
110 while (right_idx < blen)
112 uint16_t sym=bvec[right_idx];
115 while (right_idx< blen && bvec[right_idx]==sym)
119 free_feature_vector(avec, idx_a, free_avec);
121 free_feature_vector(bvec, idx_b, free_bvec);
virtual bool init(CFeatures *l, CFeatures *r)
all of classes and functions are contained in the shogun namespace
CFeatures * lhs
feature vectors to occur on the left hand side
The class Features is the base class of all feature objects.
CFeatures * rhs
feature vectors to occur on the right hand side
virtual ~CCanberraWordDistance()
float64_t compute(int32_t idx_a, int32_t idx_b)
template class StringDistance