SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
distance
StringDistance.h
浏览该文件的文档.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2006-2009 Christian Gehl
8
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef _STRINGDISTANCE_H___
12
#define _STRINGDISTANCE_H___
13
14
#include <
shogun/distance/Distance.h
>
15
#include <
shogun/features/StringFeatures.h
>
16
17
namespace
shogun
18
{
20
template
<
class
ST>
class
CStringDistance
:
public
CDistance
21
{
22
public
:
24
CStringDistance
() :
CDistance
() {}
25
32
/* when training data is supplied as both l and r do_init
33
* should be true
34
*/
35
virtual
bool
init(
CFeatures
* l,
CFeatures
* r)
36
{
37
CDistance::init(l,r);
38
39
ASSERT
(l->
get_feature_class
()==
C_STRING
)
40
ASSERT
(r->
get_feature_class
()==
C_STRING
)
41
ASSERT
(l->
get_feature_type
()==this->
get_feature_type
())
42
ASSERT
(r->
get_feature_type
()==this->
get_feature_type
())
43
return
true
;
44
}
45
50
virtual
EFeatureClass
get_feature_class
() {
return
C_STRING
; }
51
56
virtual
EFeatureType
get_feature_type
();
57
63
virtual
const
char
*
get_name
()
const
{
64
return
"StringDistance"
; }
65
70
virtual
void
cleanup
()=0;
71
78
virtual
EDistanceType
get_distance_type
()=0;
79
};
80
85
template
<>
inline
EFeatureType
CStringDistance<float64_t>::get_feature_type
() {
return
F_DREAL
; }
86
91
template
<>
inline
EFeatureType
CStringDistance<uint64_t>::get_feature_type
() {
return
F_ULONG
; }
92
97
template
<>
inline
EFeatureType
CStringDistance<int32_t>::get_feature_type
() {
return
F_INT
; }
98
103
template
<>
inline
EFeatureType
CStringDistance<uint16_t>::get_feature_type
() {
return
F_WORD
; }
104
109
template
<>
inline
EFeatureType
CStringDistance<int16_t>::get_feature_type
() {
return
F_SHORT
; }
110
115
template
<>
inline
EFeatureType
CStringDistance<uint8_t>::get_feature_type
() {
return
F_BYTE
; }
116
121
template
<>
inline
EFeatureType
CStringDistance<char>::get_feature_type
() {
return
F_CHAR
; }
122
123
}
// namespace shogun
124
#endif
125
SHOGUN
机器学习工具包 - 项目文档