mosesdecoder/phrase-extract/InternalStructFeature.h

65 lines
1.7 KiB
C
Raw Normal View History

2013-09-12 20:46:40 +04:00
#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
2013-09-12 20:46:40 +04:00
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include "ScoreFeature.h"
#include "extract-ghkm/Node.h"
namespace MosesTraining
{
class InternalStructFeature : public ScoreFeature
{
public:
2014-05-19 17:35:08 +04:00
InternalStructFeature() : m_type(0) {};
/** Add the values for this feature function. */
void add(const ScoreFeatureContext& context,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const;
2013-09-12 20:46:40 +04:00
protected:
2014-05-19 17:35:08 +04:00
/** Overridden in subclass */
virtual void add(const std::string *treeFragment,
float count,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const = 0;
int m_type;
2013-09-12 20:46:40 +04:00
};
class InternalStructFeatureDense : public InternalStructFeature
{
public:
2014-01-15 19:49:57 +04:00
InternalStructFeatureDense()
:InternalStructFeature() {
m_type=1;
} //std::cout<<"InternalStructFeatureDense: Construct "<<m_type<<"\n";}
2013-09-12 20:46:40 +04:00
protected:
2014-05-19 17:35:08 +04:00
virtual void add(const std::string *treeFragment,
float count,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const;
2013-09-12 20:46:40 +04:00
};
class InternalStructFeatureSparse : public InternalStructFeature
{
public:
2014-01-15 19:49:57 +04:00
InternalStructFeatureSparse()
:InternalStructFeature() {
m_type=2;
}// std::cout<<"InternalStructFeatureSparse: Construct "<<m_type<<"\n";}
2013-09-12 20:46:40 +04:00
protected:
2014-05-19 17:35:08 +04:00
virtual void add(const std::string *treeFragment,
float count,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const;
2013-09-12 20:46:40 +04:00
};
}