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: 66d61c6f9b826dfe5086f424af0a2b5e3c19cb29 (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
#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <string>
#include <queue>
#include <map>
#include <cmath>

#include "ScoreFeature.h"
#include "extract-ghkm/Node.h"

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;
};

}