SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SortWordString.cpp
Go to the documentation of this file.
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) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
15 
16 using namespace shogun;
17 
19 : CStringPreprocessor<uint16_t>()
20 {
21 }
22 
24 {
25 }
26 
28 bool CSortWordString::init(CFeatures* f)
29 {
32 
33  return true;
34 }
35 
38 {
39 }
40 
42 bool CSortWordString::load(FILE* f)
43 {
46  return false;
47 }
48 
50 bool CSortWordString::save(FILE* f)
51 {
54  return false;
55 }
56 
61 {
62  int32_t i;
63  int32_t num_vec=((CStringFeatures<uint16_t>*)f)->get_num_vectors() ;
64 
65  for (i=0; i<num_vec; i++)
66  {
67  int32_t len = 0 ;
68  bool free_vec;
69  uint16_t* vec = ((CStringFeatures<uint16_t>*)f)->get_feature_vector(i, len, free_vec);
70  ASSERT(!free_vec) // won't work with non-in-memory string features
71 
72  //CMath::qsort(vec, len);
73  CMath::radix_sort(vec, len);
74 
75  }
76  return true ;
77 }
78 
80 uint16_t* CSortWordString::apply_to_string(uint16_t* f, int32_t& len)
81 {
82  uint16_t* vec=SG_MALLOC(uint16_t, len);
83  int32_t i=0;
84 
85  for (i=0; i<len; i++)
86  vec[i]=f[i];
87 
88  //CMath::qsort(vec, len);
89  CMath::radix_sort(vec, len);
90 
91  return vec;
92 }

SHOGUN Machine Learning Toolbox - Documentation