00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021 #ifndef PCFG_EXTRACT_RULE_COLLECTION_H_
00022 #define PCFG_EXTRACT_RULE_COLLECTION_H_
00023
00024 #include <vector>
00025
00026 #include <boost/unordered_map.hpp>
00027
00028 #include "syntax-common/pcfg.h"
00029
00030 namespace MosesTraining
00031 {
00032 namespace Syntax
00033 {
00034 namespace PCFG
00035 {
00036
00037
00038 class RuleCollection
00039 {
00040 public:
00041 typedef boost::unordered_map<std::vector<std::size_t>, std::size_t> RhsCountMap;
00042 typedef boost::unordered_map<std::size_t, RhsCountMap> Map;
00043 typedef Map::iterator iterator;
00044 typedef Map::const_iterator const_iterator;
00045
00046 RuleCollection() {}
00047
00048 iterator begin() {
00049 return collection_.begin();
00050 }
00051 const_iterator begin() const {
00052 return collection_.begin();
00053 }
00054
00055 iterator end() {
00056 return collection_.end();
00057 }
00058 const_iterator end() const {
00059 return collection_.end();
00060 }
00061
00062 void Add(std::size_t, const std::vector<std::size_t> &);
00063 void CreatePcfg(Pcfg &);
00064
00065 private:
00066 Map collection_;
00067 };
00068
00069 }
00070 }
00071 }
00072
00073 #endif