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

CountsPhraseProperty.h « PP « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f313708557d9a52965eb9f06edb802ecef6b1ff (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

#pragma once

#include "moses/PP/PhraseProperty.h"
#include "util/exception.hh"
#include <string>
#include <list>

namespace Moses
{

//    A simple phrase property class to access the three phrase count values.
//
//    The counts are usually not needed during decoding and are not loaded
//    from the phrase table. This is just a workaround that can make them
//    available to features which have a use for them.
//
//    If you need access to the counts, copy the two marginal counts and the
//    joint count into an additional information property with key "Counts",
//    e.g. using awk:
//
//    $ zcat phrase-table.gz | awk -F' \|\|\| '  '{printf("%s {{Counts %s}}\n",$0,$5);}' | gzip -c > phrase-table.withCountsPP.gz
//
//    CountsPhraseProperty reads them from the phrase table and provides
//    methods GetSourceMarginal(), GetTargetMarginal(), GetJointCount().


class CountsPhraseProperty : public PhraseProperty
{
  friend std::ostream& operator<<(std::ostream &, const CountsPhraseProperty &);

public:

  CountsPhraseProperty() {};

  virtual void ProcessValue(const std::string &value);

  size_t GetSourceMarginal() const {
    return m_sourceMarginal;
  }

  size_t GetTargetMarginal() const {
    return m_targetMarginal;
  }

  float GetJointCount() const {
    return m_jointCount;
  }

  virtual const std::string *GetValueString() const {
    UTIL_THROW2("CountsPhraseProperty: value string not available in this phrase property");
    return NULL;
  };

protected:

  float m_sourceMarginal, m_targetMarginal, m_jointCount;

};

} // namespace Moses