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

RuleTableParser.h « compact-rule-table « training « scripts - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5599e63de8d431e073944069c006ba022d2ba17b (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
#pragma once
#ifndef RULETABLEPARSER_H_INCLUDED_
#define RULETABLEPARSER_H_INCLUDED_

#include <istream>
#include <set>
#include <string>
#include <utility>
#include <vector>

namespace moses {

class RuleTableParser {
 public:
  struct Entry {
    std::string sourceLhs;
    std::vector<std::string> sourceRhs;
    std::string targetLhs;
    std::vector<std::string> targetRhs;
    std::vector<std::string> scores;
    std::set<std::pair<int, int> > alignments;
    std::vector<std::string> counts;
    std::string tail;
  };

  RuleTableParser();
  RuleTableParser(std::istream &);

  const Entry &operator*() const { return m_value; }
  const Entry *operator->() const { return &m_value; }

  RuleTableParser &operator++();
  RuleTableParser operator++(int);

  friend bool operator==(const RuleTableParser &, const RuleTableParser &);
  friend bool operator!=(const RuleTableParser &, const RuleTableParser &);

 private:
  Entry m_value;
  std::istream *m_input;
  std::string m_line;
  std::vector<std::string> tmpStringVec;

  void parseLine(const std::string &);
  static void trimPairedSymbolFromLeft(std::string &);
  static void trimPairedSymbolFromRight(std::string &);
};

}  // namespace moses

#endif