00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2008 Soeren Sonnenburg 00008 * Written (W) 1999-2008 Gunnar Raetsch 00009 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #include "preproc/SortWord.h" 00013 #include "preproc/SimplePreProc.h" 00014 #include "features/Features.h" 00015 #include "lib/Mathematics.h" 00016 #include "features/WordFeatures.h" 00017 00018 CSortWord::CSortWord() 00019 : CSimplePreProc<WORD>("SortWord", "SRTW") 00020 { 00021 } 00022 00023 CSortWord::~CSortWord() 00024 { 00025 } 00026 00028 bool CSortWord::init(CFeatures* f) 00029 { 00030 ASSERT(f->get_feature_class()==C_SIMPLE); 00031 ASSERT(f->get_feature_type()==F_WORD); 00032 00033 return true; 00034 } 00035 00037 void CSortWord::cleanup() 00038 { 00039 } 00040 00042 bool CSortWord::load(FILE* f) 00043 { 00044 return false; 00045 } 00046 00048 bool CSortWord::save(FILE* f) 00049 { 00050 return false; 00051 } 00052 00056 WORD* CSortWord::apply_to_feature_matrix(CFeatures* f) 00057 { 00058 INT i; 00059 INT num_vec; 00060 INT num_feat; 00061 WORD* matrix=((CWordFeatures*) f)->get_feature_matrix(num_feat, num_vec); 00062 00063 for (i=0; i<num_vec; i++) 00064 { 00065 WORD* vec=&matrix[i*num_feat]; 00066 //CMath::qsort(vec, num_feat); 00067 CMath::radix_sort(vec, num_feat); 00068 } 00069 return matrix; 00070 } 00071 00074 WORD* CSortWord::apply_to_feature_vector(WORD* f, INT& len) 00075 { 00076 WORD* vec=new WORD[len]; 00077 INT i=0; 00078 00079 for (i=0; i<len; i++) 00080 vec[i]=f[i]; 00081 00082 //CMath::qsort(vec, len); 00083 CMath::radix_sort(vec, len); 00084 00085 return vec; 00086 } 00087 00089 bool CSortWord::load_init_data(FILE* src) 00090 { 00091 return true; 00092 } 00093 00095 bool CSortWord::save_init_data(FILE* dst) 00096 { 00097 return true; 00098 }