-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
SortUlongString.h
57 lines (47 loc) · 1.6 KB
/
SortUlongString.h
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
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Soeren Sonnenburg, Yuyu Zhang, Saurabh Goyal
*/
#ifndef _CSORTULONGSTRING__H__
#define _CSORTULONGSTRING__H__
#include <shogun/lib/config.h>
#include <shogun/features/StringFeatures.h>
#include <shogun/preprocessor/StringPreprocessor.h>
#include <shogun/lib/common.h>
namespace shogun
{
/** @brief Preprocessor SortUlongString, sorts the indivual strings in ascending order.
*
* This is useful in conjunction with the CCommUlongStringKernel and will result
* in the spectrum kernel. For this to work the strings have to be mapped into
* a binary higher order representation first (cf. obtain_from_*() functions in
* CStringFeatures)
*/
class CSortUlongString : public CStringPreprocessor<uint64_t>
{
public:
/** default constructor */
CSortUlongString();
/** destructor */
virtual ~CSortUlongString();
/// cleanup
virtual void cleanup();
/// initialize preprocessor from file
virtual bool load(FILE* f);
/// save preprocessor init-data to file
virtual bool save(FILE* f);
/// apply preproc to feature matrix
/// result in feature matrix
/// return pointer to feature_matrix, i.e. f->get_feature_matrix();
virtual bool apply_to_string_features(CFeatures* f);
/// apply preproc on single feature vector
/// result in feature matrix
virtual uint64_t* apply_to_string(uint64_t* f, int32_t &len);
/** @return object name */
virtual const char* get_name() const { return "SortUlongString"; }
/// return a type of preprocessor
virtual EPreprocessorType get_type() const { return P_SORTULONGSTRING; }
};
}
#endif