00001 #pragma once 00002 00003 #include <string> 00004 #include <algorithm> 00005 #include "VWFeatureSource.h" 00006 #include "moses/Util.h" 00007 00008 namespace Moses 00009 { 00010 00011 class VWFeatureSourcePhraseInternal : public VWFeatureSource 00012 { 00013 public: 00014 VWFeatureSourcePhraseInternal(const std::string &line) 00015 : VWFeatureSource(line) { 00016 ReadParameters(); 00017 00018 // Call this last 00019 VWFeatureBase::UpdateRegister(); 00020 } 00021 00022 void operator()(const InputType &input 00023 , const Range &sourceRange 00024 , Discriminative::Classifier &classifier 00025 , Discriminative::FeatureVector &outFeatures) const { 00026 size_t begin = sourceRange.GetStartPos(); 00027 size_t end = sourceRange.GetEndPos() + 1; 00028 00029 while (begin < end) { 00030 outFeatures.push_back(classifier.AddLabelIndependentFeature("sin^" + GetWord(input, begin++))); 00031 } 00032 } 00033 00034 virtual void SetParameter(const std::string& key, const std::string& value) { 00035 VWFeatureSource::SetParameter(key, value); 00036 } 00037 }; 00038 00039 }