Welcome to mirror list, hosted at ThFree Co, Russian Federation.

InternalStructFeature.h « phrase-extract - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bd513a715fa208ba3e4f2e76e1fae4e3a1c6bed4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <fstream>
#include <assert.h>
#include <stdlib.h>
#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();
	/** Return true if the two phrase pairs are equal from the point of this feature. Assume
	      that they already compare true according to PhraseAlignment.equals()
	   **/
	bool equals(const PhraseAlignment& lhs, const PhraseAlignment& rhs) const;
	/** Add the values for this feature function. */
	void add(const ScoreFeatureContext& context,
	                   std::vector<float>& denseValues,
	                   std::map<std::string,float>& sparseValues) const;


protected:
	/** Overriden in subclass */
	 virtual void add(std::string *internalStruct,
	                   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(std::string *internalStruct,
		             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(std::string *internalStruct,
		             std::vector<float>& denseValues,
		             std::map<std::string,float>& sparseValues) const;
};

}