mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 14:32:38 +03:00
9852a0c2ff
This is one of those little chores in managing a long-lived C++ project: standard C headers like stdio.h and math.h now have their own place in the C++ standard as resp. cstdio, cmath, and so on. In this branch the #include names are updated for the phrase-extract/ subdirectory; more branches to follow. C++11 adds cstdint, but to support compilation with the previous standard, that change is left for later.
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include <iostream>
|
|
#include <fstream>
|
|
#include <cassert>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include <queue>
|
|
#include <map>
|
|
#include <cmath>
|
|
|
|
#include "ScoreFeature.h"
|
|
#include "extract-ghkm/Node.h"
|
|
|
|
using namespace MosesTraining;
|
|
using namespace Moses;
|
|
using namespace GHKM;
|
|
|
|
namespace MosesTraining
|
|
{
|
|
|
|
|
|
class InternalStructFeature : public ScoreFeature
|
|
{
|
|
public:
|
|
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;
|
|
|
|
|
|
protected:
|
|
/** 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;
|
|
};
|
|
|
|
class InternalStructFeatureDense : public InternalStructFeature
|
|
{
|
|
public:
|
|
InternalStructFeatureDense()
|
|
:InternalStructFeature() {
|
|
m_type=1;
|
|
} //std::cout<<"InternalStructFeatureDense: Construct "<<m_type<<"\n";}
|
|
protected:
|
|
virtual void add(const std::string *treeFragment,
|
|
float count,
|
|
std::vector<float>& denseValues,
|
|
std::map<std::string,float>& sparseValues) const;
|
|
};
|
|
|
|
class InternalStructFeatureSparse : public InternalStructFeature
|
|
{
|
|
public:
|
|
InternalStructFeatureSparse()
|
|
:InternalStructFeature() {
|
|
m_type=2;
|
|
}// std::cout<<"InternalStructFeatureSparse: Construct "<<m_type<<"\n";}
|
|
protected:
|
|
virtual void add(const std::string *treeFragment,
|
|
float count,
|
|
std::vector<float>& denseValues,
|
|
std::map<std::string,float>& sparseValues) const;
|
|
};
|
|
|
|
}
|