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

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Williams <philip.williams@mac.com>2015-06-04 16:36:39 +0300
committerPhil Williams <philip.williams@mac.com>2015-06-04 16:36:39 +0300
commitf6ddc452241755733c947723a8618aab7245c8f1 (patch)
tree31845976f6c99a86b370e161ddfbe1613d88939c /phrase-extract
parent6a09042e6abd5dab3d0cf0d358804f7a0ef9ca9a (diff)
Ongoing moses/phrase-extract refactoring
Diffstat (limited to 'phrase-extract')
-rw-r--r--phrase-extract/pcfg-common/Jamfile1
-rw-r--r--phrase-extract/pcfg-common/pcfg.h63
-rw-r--r--phrase-extract/pcfg-common/typedef.h38
-rw-r--r--phrase-extract/pcfg-extract/Jamfile2
-rw-r--r--phrase-extract/pcfg-extract/pcfg_extract.cc5
-rw-r--r--phrase-extract/pcfg-extract/pcfg_extract.h2
-rw-r--r--phrase-extract/pcfg-extract/rule_collection.cc2
-rw-r--r--phrase-extract/pcfg-extract/rule_collection.h2
-rw-r--r--phrase-extract/pcfg-extract/rule_extractor.h4
-rw-r--r--phrase-extract/pcfg-score/Jamfile2
-rw-r--r--phrase-extract/pcfg-score/pcfg_score.cc5
-rw-r--r--phrase-extract/pcfg-score/pcfg_score.h2
-rw-r--r--phrase-extract/pcfg-score/tree_scorer.h4
-rw-r--r--phrase-extract/syntax-common/pcfg.cc (renamed from phrase-extract/pcfg-common/pcfg.cc)21
-rw-r--r--phrase-extract/syntax-common/pcfg.h38
-rw-r--r--phrase-extract/syntax-common/tool.cc (renamed from phrase-extract/pcfg-common/tool.cc)0
-rw-r--r--phrase-extract/syntax-common/tool.h (renamed from phrase-extract/pcfg-common/tool.h)0
-rw-r--r--phrase-extract/syntax-common/vocabulary.h13
18 files changed, 65 insertions, 139 deletions
diff --git a/phrase-extract/pcfg-common/Jamfile b/phrase-extract/pcfg-common/Jamfile
deleted file mode 100644
index 5669b443e..000000000
--- a/phrase-extract/pcfg-common/Jamfile
+++ /dev/null
@@ -1 +0,0 @@
-lib pcfg_common : [ glob *.cc ] ..//syntax-common ..//deps : <include>.. ;
diff --git a/phrase-extract/pcfg-common/pcfg.h b/phrase-extract/pcfg-common/pcfg.h
deleted file mode 100644
index c5c04cba4..000000000
--- a/phrase-extract/pcfg-common/pcfg.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/***********************************************************************
- Moses - statistical machine translation system
- Copyright (C) 2006-2012 University of Edinburgh
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-***********************************************************************/
-
-#pragma once
-#ifndef PCFG_PCFG_H_
-#define PCFG_PCFG_H_
-
-#include <istream>
-#include <map>
-#include <ostream>
-#include <vector>
-
-#include "typedef.h"
-
-namespace MosesTraining {
-namespace Syntax {
-namespace PCFG {
-
-class Pcfg {
- public:
- typedef std::vector<std::size_t> Key;
- typedef std::map<Key, double> Map;
- typedef Map::iterator iterator;
- typedef Map::const_iterator const_iterator;
-
- Pcfg() {}
-
- iterator begin() { return rules_.begin(); }
- const_iterator begin() const { return rules_.begin(); }
-
- iterator end() { return rules_.end(); }
- const_iterator end() const { return rules_.end(); }
-
- void Add(const Key &, double);
- bool Lookup(const Key &, double &) const;
- void Read(std::istream &, Vocabulary &);
- void Write(const Vocabulary &, std::ostream &) const;
-
- private:
- Map rules_;
-};
-
-} // namespace PCFG
-} // namespace Syntax
-} // namespace MosesTraining
-
-#endif
diff --git a/phrase-extract/pcfg-common/typedef.h b/phrase-extract/pcfg-common/typedef.h
deleted file mode 100644
index 1280b89cf..000000000
--- a/phrase-extract/pcfg-common/typedef.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/***********************************************************************
- Moses - statistical machine translation system
- Copyright (C) 2006-2012 University of Edinburgh
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-***********************************************************************/
-
-#pragma once
-#ifndef PCFG_TYPEDEF_H_
-#define PCFG_TYPEDEF_H_
-
-#include <string>
-
-#include "syntax-common/numbered_set.h"
-
-namespace MosesTraining {
-namespace Syntax {
-namespace PCFG {
-
-typedef NumberedSet<std::string> Vocabulary;
-
-} // namespace PCFG
-} // namespace Syntax
-} // namespace MosesTraining
-
-#endif
diff --git a/phrase-extract/pcfg-extract/Jamfile b/phrase-extract/pcfg-extract/Jamfile
index 2442b967a..2f4ae1e7d 100644
--- a/phrase-extract/pcfg-extract/Jamfile
+++ b/phrase-extract/pcfg-extract/Jamfile
@@ -1 +1 @@
-exe pcfg-extract : [ glob *.cc ] ..//syntax-common ..//pcfg-common ../..//boost_program_options : <include>.. ;
+exe pcfg-extract : [ glob *.cc ] ..//syntax-common ../..//boost_program_options : <include>.. ;
diff --git a/phrase-extract/pcfg-extract/pcfg_extract.cc b/phrase-extract/pcfg-extract/pcfg_extract.cc
index 87419edb7..45eb9ff3d 100644
--- a/phrase-extract/pcfg-extract/pcfg_extract.cc
+++ b/phrase-extract/pcfg-extract/pcfg_extract.cc
@@ -32,13 +32,12 @@
#include <boost/program_options.hpp>
#include "syntax-common/exception.h"
+#include "syntax-common/pcfg.h"
+#include "syntax-common/vocabulary.h"
#include "syntax-common/xml_tree_parser.h"
#include "SyntaxTree.h"
-#include "pcfg-common/pcfg.h"
-#include "pcfg-common/typedef.h"
-
#include "options.h"
#include "rule_collection.h"
#include "rule_extractor.h"
diff --git a/phrase-extract/pcfg-extract/pcfg_extract.h b/phrase-extract/pcfg-extract/pcfg_extract.h
index 5882e45da..3b084acbe 100644
--- a/phrase-extract/pcfg-extract/pcfg_extract.h
+++ b/phrase-extract/pcfg-extract/pcfg_extract.h
@@ -21,7 +21,7 @@
#ifndef PCFG_EXTRACT_PCFG_EXTRACT_H_
#define PCFG_EXTRACT_PCFG_EXTRACT_H_
-#include "pcfg-common/tool.h"
+#include "syntax-common/tool.h"
namespace MosesTraining
{
diff --git a/phrase-extract/pcfg-extract/rule_collection.cc b/phrase-extract/pcfg-extract/rule_collection.cc
index 9db0ce9bf..a814f82d6 100644
--- a/phrase-extract/pcfg-extract/rule_collection.cc
+++ b/phrase-extract/pcfg-extract/rule_collection.cc
@@ -19,7 +19,7 @@
#include "rule_collection.h"
-#include "pcfg-common/pcfg.h"
+#include "syntax-common/pcfg.h"
#include <cmath>
diff --git a/phrase-extract/pcfg-extract/rule_collection.h b/phrase-extract/pcfg-extract/rule_collection.h
index 3d9a9f98b..3bbc32721 100644
--- a/phrase-extract/pcfg-extract/rule_collection.h
+++ b/phrase-extract/pcfg-extract/rule_collection.h
@@ -25,7 +25,7 @@
#include <boost/unordered_map.hpp>
-#include "pcfg-common/pcfg.h"
+#include "syntax-common/pcfg.h"
namespace MosesTraining
{
diff --git a/phrase-extract/pcfg-extract/rule_extractor.h b/phrase-extract/pcfg-extract/rule_extractor.h
index d32d76992..91014747c 100644
--- a/phrase-extract/pcfg-extract/rule_extractor.h
+++ b/phrase-extract/pcfg-extract/rule_extractor.h
@@ -23,7 +23,7 @@
#include "SyntaxTree.h"
-#include "pcfg-common/typedef.h"
+#include "syntax-common/vocabulary.h"
#include "rule_collection.h"
@@ -39,7 +39,7 @@ class RuleExtractor
{
public:
RuleExtractor(Vocabulary &);
- void Extract(const MosesTraining::SyntaxTree &, RuleCollection &) const;
+ void Extract(const SyntaxTree &, RuleCollection &) const;
private:
Vocabulary &non_term_vocab_;
};
diff --git a/phrase-extract/pcfg-score/Jamfile b/phrase-extract/pcfg-score/Jamfile
index 45d46492a..ca321d04c 100644
--- a/phrase-extract/pcfg-score/Jamfile
+++ b/phrase-extract/pcfg-score/Jamfile
@@ -1 +1 @@
-exe pcfg-score : [ glob *.cc ] ..//pcfg-common ../..//boost_program_options : <include>.. ;
+exe pcfg-score : [ glob *.cc ] ..//syntax-common ../..//boost_program_options : <include>.. ;
diff --git a/phrase-extract/pcfg-score/pcfg_score.cc b/phrase-extract/pcfg-score/pcfg_score.cc
index e11f73f70..cec84211a 100644
--- a/phrase-extract/pcfg-score/pcfg_score.cc
+++ b/phrase-extract/pcfg-score/pcfg_score.cc
@@ -36,12 +36,11 @@
#include "SyntaxTree.h"
#include "syntax-common/exception.h"
+#include "syntax-common/pcfg.h"
+#include "syntax-common/vocabulary.h"
#include "syntax-common/xml_tree_parser.h"
#include "syntax-common/xml_tree_writer.h"
-#include "pcfg-common/pcfg.h"
-#include "pcfg-common/typedef.h"
-
namespace MosesTraining
{
namespace Syntax
diff --git a/phrase-extract/pcfg-score/pcfg_score.h b/phrase-extract/pcfg-score/pcfg_score.h
index b0b4a77cd..b691b107f 100644
--- a/phrase-extract/pcfg-score/pcfg_score.h
+++ b/phrase-extract/pcfg-score/pcfg_score.h
@@ -21,7 +21,7 @@
#ifndef PCFG_SCORE_PCFG_SCORE_H_
#define PCFG_SCORE_PCFG_SCORE_H_
-#include "pcfg-common/tool.h"
+#include "syntax-common/tool.h"
namespace MosesTraining
{
diff --git a/phrase-extract/pcfg-score/tree_scorer.h b/phrase-extract/pcfg-score/tree_scorer.h
index cf9fdd1a3..b95d13ddb 100644
--- a/phrase-extract/pcfg-score/tree_scorer.h
+++ b/phrase-extract/pcfg-score/tree_scorer.h
@@ -23,8 +23,8 @@
#include "SyntaxTree.h"
-#include "pcfg-common/pcfg.h"
-#include "pcfg-common/typedef.h"
+#include "syntax-common/vocabulary.h"
+#include "syntax-common/pcfg.h"
namespace MosesTraining
{
diff --git a/phrase-extract/pcfg-common/pcfg.cc b/phrase-extract/syntax-common/pcfg.cc
index 988367c9b..3efe04218 100644
--- a/phrase-extract/pcfg-common/pcfg.cc
+++ b/phrase-extract/syntax-common/pcfg.cc
@@ -1,22 +1,3 @@
-/***********************************************************************
- Moses - statistical machine translation system
- Copyright (C) 2006-2012 University of Edinburgh
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-***********************************************************************/
-
#include "pcfg.h"
#include <cassert>
@@ -28,7 +9,6 @@
namespace MosesTraining {
namespace Syntax {
-namespace PCFG {
void Pcfg::Add(const Key &key, double score) {
rules_[key] = score;
@@ -103,6 +83,5 @@ void Pcfg::Write(const Vocabulary &vocab, std::ostream &output) const {
}
}
-} // namespace PCFG
} // namespace Syntax
} // namespace MosesTraining
diff --git a/phrase-extract/syntax-common/pcfg.h b/phrase-extract/syntax-common/pcfg.h
new file mode 100644
index 000000000..0a731cc7a
--- /dev/null
+++ b/phrase-extract/syntax-common/pcfg.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <istream>
+#include <map>
+#include <ostream>
+#include <vector>
+
+#include "vocabulary.h"
+
+namespace MosesTraining {
+namespace Syntax {
+
+class Pcfg {
+ public:
+ typedef std::vector<std::size_t> Key;
+ typedef std::map<Key, double> Map;
+ typedef Map::iterator iterator;
+ typedef Map::const_iterator const_iterator;
+
+ Pcfg() {}
+
+ iterator begin() { return rules_.begin(); }
+ const_iterator begin() const { return rules_.begin(); }
+
+ iterator end() { return rules_.end(); }
+ const_iterator end() const { return rules_.end(); }
+
+ void Add(const Key &, double);
+ bool Lookup(const Key &, double &) const;
+ void Read(std::istream &, Vocabulary &);
+ void Write(const Vocabulary &, std::ostream &) const;
+
+ private:
+ Map rules_;
+};
+
+} // namespace Syntax
+} // namespace MosesTraining
diff --git a/phrase-extract/pcfg-common/tool.cc b/phrase-extract/syntax-common/tool.cc
index c41eaf9bd..c41eaf9bd 100644
--- a/phrase-extract/pcfg-common/tool.cc
+++ b/phrase-extract/syntax-common/tool.cc
diff --git a/phrase-extract/pcfg-common/tool.h b/phrase-extract/syntax-common/tool.h
index 2c903a11e..2c903a11e 100644
--- a/phrase-extract/pcfg-common/tool.h
+++ b/phrase-extract/syntax-common/tool.h
diff --git a/phrase-extract/syntax-common/vocabulary.h b/phrase-extract/syntax-common/vocabulary.h
new file mode 100644
index 000000000..119767245
--- /dev/null
+++ b/phrase-extract/syntax-common/vocabulary.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <string>
+
+#include "numbered_set.h"
+
+namespace MosesTraining {
+namespace Syntax {
+
+typedef NumberedSet<std::string> Vocabulary;
+
+} // namespace Syntax
+} // namespace MosesTraining