diff options
author | Phil Williams <philip.williams@mac.com> | 2012-05-26 16:13:23 +0400 |
---|---|---|
committer | Phil Williams <philip.williams@mac.com> | 2012-05-26 16:13:23 +0400 |
commit | 82580280bc0b30607b00a55ffe0f22d5665269a3 (patch) | |
tree | ed2765206aa54f1428e6de7a3b218561044b7796 /scripts/training | |
parent | 7b0d04f34193b556af71c8f35c13fcccb9f335a1 (diff) |
Fix compile error by using std::size_t instead of size_t.
Thanks to Tomas Hudik for reporting that.
Diffstat (limited to 'scripts/training')
11 files changed, 24 insertions, 24 deletions
diff --git a/scripts/training/phrase-extract/pcfg-common/numbered_set.h b/scripts/training/phrase-extract/pcfg-common/numbered_set.h index f88d710ed..15e768b4c 100644 --- a/scripts/training/phrase-extract/pcfg-common/numbered_set.h +++ b/scripts/training/phrase-extract/pcfg-common/numbered_set.h @@ -35,7 +35,7 @@ namespace PCFG { // Stores a set of elements of type T, each of which is allocated an integral // ID of type I. IDs are contiguous starting at 0. Individual elements cannot // be removed once inserted (but the whole set can be cleared). -template<typename T, typename I=size_t> +template<typename T, typename I=std::size_t> class NumberedSet { private: typedef boost::unordered_map<T, I> ElementToIdMap; @@ -54,7 +54,7 @@ class NumberedSet { static I NullId() { return std::numeric_limits<I>::max(); } bool Empty() const { return id_to_element_.empty(); } - size_t Size() const { return id_to_element_.size(); } + std::size_t Size() const { return id_to_element_.size(); } // Insert the given object and return its ID. I Insert(const T &); diff --git a/scripts/training/phrase-extract/pcfg-common/pcfg.cc b/scripts/training/phrase-extract/pcfg-common/pcfg.cc index d045b820b..054e20a48 100644 --- a/scripts/training/phrase-extract/pcfg-common/pcfg.cc +++ b/scripts/training/phrase-extract/pcfg-common/pcfg.cc @@ -50,7 +50,7 @@ void Pcfg::Read(std::istream &input, Vocabulary &vocab) { Key key; while (std::getline(input, line)) { // Read LHS. - size_t pos = line.find("|||"); + std::size_t pos = line.find("|||"); if (pos == std::string::npos) { throw Exception("missing first delimiter"); } @@ -58,7 +58,7 @@ void Pcfg::Read(std::istream &input, Vocabulary &vocab) { boost::trim(lhs_string); // Read RHS. - size_t begin = pos+3; + std::size_t begin = pos+3; pos = line.find("|||", begin); if (pos == std::string::npos) { throw Exception("missing second delimiter"); @@ -92,8 +92,8 @@ void Pcfg::Write(const Vocabulary &vocab, std::ostream &output) const { for (const_iterator p = begin(); p != end(); ++p) { const Key &key = p->first; double score = p->second; - std::vector<size_t>::const_iterator q = key.begin(); - std::vector<size_t>::const_iterator end = key.end(); + std::vector<std::size_t>::const_iterator q = key.begin(); + std::vector<std::size_t>::const_iterator end = key.end(); output << vocab.Lookup(*q++) << " |||"; while (q != end) { output << " " << vocab.Lookup(*q++); diff --git a/scripts/training/phrase-extract/pcfg-common/pcfg.h b/scripts/training/phrase-extract/pcfg-common/pcfg.h index 757eea449..b87336584 100644 --- a/scripts/training/phrase-extract/pcfg-common/pcfg.h +++ b/scripts/training/phrase-extract/pcfg-common/pcfg.h @@ -33,7 +33,7 @@ namespace PCFG { class Pcfg { public: - typedef std::vector<size_t> Key; + typedef std::vector<std::size_t> Key; typedef std::map<Key, double> Map; typedef Map::iterator iterator; typedef Map::const_iterator const_iterator; diff --git a/scripts/training/phrase-extract/pcfg-common/syntax_tree.h b/scripts/training/phrase-extract/pcfg-common/syntax_tree.h index 37f72dd58..89c6ec0c3 100644 --- a/scripts/training/phrase-extract/pcfg-common/syntax_tree.h +++ b/scripts/training/phrase-extract/pcfg-common/syntax_tree.h @@ -80,7 +80,7 @@ class SyntaxTree : public SyntaxTreeBase<T, SyntaxTree<T> > { template<typename T, typename DerivedType> SyntaxTreeBase<T, DerivedType>::~SyntaxTreeBase() { - for (size_t i = 0; i < children_.size(); ++i) { + for (std::size_t i = 0; i < children_.size(); ++i) { delete children_[i]; } } diff --git a/scripts/training/phrase-extract/pcfg-common/xml_tree_writer.h b/scripts/training/phrase-extract/pcfg-common/xml_tree_writer.h index c5171a905..6a9a3de05 100644 --- a/scripts/training/phrase-extract/pcfg-common/xml_tree_writer.h +++ b/scripts/training/phrase-extract/pcfg-common/xml_tree_writer.h @@ -101,9 +101,9 @@ void XmlTreeWriter<InputTree>::Write(const InputTree &tree, template<typename InputTree> std::string XmlTreeWriter<InputTree>::Escape(const std::string &s) const { std::string t; - size_t len = s.size(); + std::size_t len = s.size(); t.reserve(len); - for (size_t i = 0; i < len; ++i) { + for (std::size_t i = 0; i < len; ++i) { if (s[i] == '<') { t += "<"; } else if (s[i] == '>') { diff --git a/scripts/training/phrase-extract/pcfg-extract/pcfg_extract.cc b/scripts/training/phrase-extract/pcfg-extract/pcfg_extract.cc index 151c9959c..71c2e31c3 100644 --- a/scripts/training/phrase-extract/pcfg-extract/pcfg_extract.cc +++ b/scripts/training/phrase-extract/pcfg-extract/pcfg_extract.cc @@ -56,7 +56,7 @@ int PcfgExtract::Main(int argc, char *argv[]) { RuleCollection rule_collection; XmlTreeParser parser; std::string line; - size_t line_num = 0; + std::size_t line_num = 0; std::auto_ptr<PcfgTree> tree; while (std::getline(std::cin, line)) { ++line_num; diff --git a/scripts/training/phrase-extract/pcfg-extract/rule_collection.cc b/scripts/training/phrase-extract/pcfg-extract/rule_collection.cc index 503b1a9e6..32b63e0ef 100644 --- a/scripts/training/phrase-extract/pcfg-extract/rule_collection.cc +++ b/scripts/training/phrase-extract/pcfg-extract/rule_collection.cc @@ -26,24 +26,24 @@ namespace Moses { namespace PCFG { -void RuleCollection::Add(size_t lhs, const std::vector<size_t> &rhs) { +void RuleCollection::Add(std::size_t lhs, const std::vector<std::size_t> &rhs) { ++collection_[lhs][rhs]; } void RuleCollection::CreatePcfg(Pcfg &pcfg) { - std::vector<size_t> key; + std::vector<std::size_t> key; for (const_iterator p = begin(); p != end(); ++p) { - size_t lhs = p->first; + std::size_t lhs = p->first; const RhsCountMap &rhs_counts = p->second; - size_t total = 0; + std::size_t total = 0; for (RhsCountMap::const_iterator q = rhs_counts.begin(); q != rhs_counts.end(); ++q) { total += q->second; } for (RhsCountMap::const_iterator q = rhs_counts.begin(); q != rhs_counts.end(); ++q) { - const std::vector<size_t> &rhs = q->first; - size_t count = q->second; + const std::vector<std::size_t> &rhs = q->first; + std::size_t count = q->second; double score = std::log(static_cast<double>(count) / static_cast<double>(total)); key.clear(); diff --git a/scripts/training/phrase-extract/pcfg-extract/rule_collection.h b/scripts/training/phrase-extract/pcfg-extract/rule_collection.h index 1b768dd21..452fa0e97 100644 --- a/scripts/training/phrase-extract/pcfg-extract/rule_collection.h +++ b/scripts/training/phrase-extract/pcfg-extract/rule_collection.h @@ -33,8 +33,8 @@ namespace PCFG { // Contains PCFG rules and their counts. class RuleCollection { public: - typedef boost::unordered_map<std::vector<size_t>, size_t> RhsCountMap; - typedef boost::unordered_map<size_t, RhsCountMap> Map; + typedef boost::unordered_map<std::vector<std::size_t>, std::size_t> RhsCountMap; + typedef boost::unordered_map<std::size_t, RhsCountMap> Map; typedef Map::iterator iterator; typedef Map::const_iterator const_iterator; @@ -46,7 +46,7 @@ class RuleCollection { iterator end() { return collection_.end(); } const_iterator end() const { return collection_.end(); } - void Add(size_t, const std::vector<size_t> &); + void Add(std::size_t, const std::vector<std::size_t> &); void CreatePcfg(Pcfg &); private: diff --git a/scripts/training/phrase-extract/pcfg-extract/rule_extractor.cc b/scripts/training/phrase-extract/pcfg-extract/rule_extractor.cc index 48a82a6d0..217574e7d 100644 --- a/scripts/training/phrase-extract/pcfg-extract/rule_extractor.cc +++ b/scripts/training/phrase-extract/pcfg-extract/rule_extractor.cc @@ -33,8 +33,8 @@ void RuleExtractor::Extract(const PcfgTree &tree, RuleCollection &rc) const { return; } - size_t lhs = non_term_vocab_.Insert(tree.label()); - std::vector<size_t> rhs; + std::size_t lhs = non_term_vocab_.Insert(tree.label()); + std::vector<std::size_t> rhs; const std::vector<PcfgTree *> &children = tree.children(); rhs.reserve(children.size()); diff --git a/scripts/training/phrase-extract/pcfg-score/pcfg_score.cc b/scripts/training/phrase-extract/pcfg-score/pcfg_score.cc index 16691707b..345d7fc60 100644 --- a/scripts/training/phrase-extract/pcfg-score/pcfg_score.cc +++ b/scripts/training/phrase-extract/pcfg-score/pcfg_score.cc @@ -63,7 +63,7 @@ int PcfgScore::Main(int argc, char *argv[]) { XmlTreeParser parser; XmlTreeWriter<PcfgTree> writer; std::string line; - size_t line_num = 0; + std::size_t line_num = 0; std::auto_ptr<PcfgTree> tree; while (std::getline(std::cin, line)) { ++line_num; diff --git a/scripts/training/phrase-extract/pcfg-score/tree_scorer.cc b/scripts/training/phrase-extract/pcfg-score/tree_scorer.cc index 5f695e4fc..f9ce97ae0 100644 --- a/scripts/training/phrase-extract/pcfg-score/tree_scorer.cc +++ b/scripts/training/phrase-extract/pcfg-score/tree_scorer.cc @@ -38,7 +38,7 @@ bool TreeScorer::Score(PcfgTree &root) const { double log_prob = 0.0; - std::vector<size_t> key; + std::vector<std::size_t> key; key.reserve(children.size()+1); key.push_back(non_term_vocab_.Lookup(root.label())); |