From 11e72d664201ec28000d37b0b77215da80b464f3 Mon Sep 17 00:00:00 2001 From: Wuwei Lin Date: Mon, 21 May 2018 13:31:52 +0800 Subject: [PATCH] Split template implementation of string preproc --- .../preprocessor/StringPreprocessor.cpp | 116 ++++++++++++++++++ src/shogun/preprocessor/StringPreprocessor.h | 76 ------------ 2 files changed, 116 insertions(+), 76 deletions(-) create mode 100644 src/shogun/preprocessor/StringPreprocessor.cpp diff --git a/src/shogun/preprocessor/StringPreprocessor.cpp b/src/shogun/preprocessor/StringPreprocessor.cpp new file mode 100644 index 00000000000..67ad4389ac0 --- /dev/null +++ b/src/shogun/preprocessor/StringPreprocessor.cpp @@ -0,0 +1,116 @@ +/* + * This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Wuwei Lin + */ + +#include + +namespace shogun +{ + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_ULONG; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_LONG; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_UINT; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_INT; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_WORD; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_WORD; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_BYTE; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_BYTE; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_CHAR; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_BOOL; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_SHORTREAL; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_DREAL; + } + + template <> + inline EFeatureType CStringPreprocessor::get_feature_type() + { + return F_LONGREAL; + } + + template + CFeatures* CStringPreprocessor::apply(CFeatures* features, bool inplace) + { + REQUIRE( + features->get_feature_class() == C_STRING, + "Provided features (%d) " + "has to be of C_STRING (%d) class!\n", + features->get_feature_class(), C_STRING); + + apply_to_string_features(features); + return features; + } + + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; + template class CStringPreprocessor; +} diff --git a/src/shogun/preprocessor/StringPreprocessor.h b/src/shogun/preprocessor/StringPreprocessor.h index 14d47689c05..f0ba8efa4ca 100644 --- a/src/shogun/preprocessor/StringPreprocessor.h +++ b/src/shogun/preprocessor/StringPreprocessor.h @@ -61,81 +61,5 @@ template class CStringPreprocessor : public CPreprocessor }; -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_ULONG; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_LONG; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_UINT; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_INT; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_WORD; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_WORD; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_BYTE; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_BYTE; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_CHAR; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_BOOL; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_SHORTREAL; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_DREAL; -} - -template<> inline EFeatureType CStringPreprocessor::get_feature_type() -{ - return F_LONGREAL; -} - -template -CFeatures* CStringPreprocessor::apply(CFeatures* features, bool inplace) -{ - REQUIRE(features->get_feature_class()==C_STRING, "Provided features (%d) " - "has to be of C_STRING (%d) class!\n", - features->get_feature_class(), C_STRING); - - apply_to_string_features(features); - return features; -} - } #endif