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:
authorHieu Hoang <hieuhoang@gmail.com>2014-09-30 17:22:38 +0400
committerHieu Hoang <hieuhoang@gmail.com>2014-09-30 17:22:38 +0400
commit33ed15ef199a11c0690ff6db2bc2c8f446af3395 (patch)
tree10034981d269b6e01eb523bbce880af16bf1c382
parentc20af584e73873ce4d06b14a7ff793752fb07505 (diff)
move misc common functions into moses/
-rw-r--r--contrib/other-builds/moses-cmd/.project10
-rw-r--r--contrib/other-builds/moses/.project10
-rw-r--r--moses-chart-cmd/Main.cpp38
-rw-r--r--moses-cmd/Main.cpp38
-rw-r--r--moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp2
-rw-r--r--moses/TranslationModel/PhraseDictionaryMultiModelCounts.h2
-rw-r--r--moses/Util.cpp41
-rw-r--r--moses/Util.h4
8 files changed, 56 insertions, 89 deletions
diff --git a/contrib/other-builds/moses-cmd/.project b/contrib/other-builds/moses-cmd/.project
index 432c15321..312c61654 100644
--- a/contrib/other-builds/moses-cmd/.project
+++ b/contrib/other-builds/moses-cmd/.project
@@ -106,15 +106,5 @@
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses-cmd/Main.h</locationURI>
</link>
- <link>
- <name>mbr.cpp</name>
- <type>1</type>
- <locationURI>PARENT-3-PROJECT_LOC/moses-cmd/mbr.cpp</locationURI>
- </link>
- <link>
- <name>mbr.h</name>
- <type>1</type>
- <locationURI>PARENT-3-PROJECT_LOC/moses-cmd/mbr.h</locationURI>
- </link>
</linkedResources>
</projectDescription>
diff --git a/contrib/other-builds/moses/.project b/contrib/other-builds/moses/.project
index 60e801195..22c6bee5e 100644
--- a/contrib/other-builds/moses/.project
+++ b/contrib/other-builds/moses/.project
@@ -1067,6 +1067,16 @@
<locationURI>PARENT-3-PROJECT_LOC/moses/hypergraph.proto</locationURI>
</link>
<link>
+ <name>mbr.cpp</name>
+ <type>1</type>
+ <locationURI>PARENT-3-PROJECT_LOC/moses/mbr.cpp</locationURI>
+ </link>
+ <link>
+ <name>mbr.h</name>
+ <type>1</type>
+ <locationURI>PARENT-3-PROJECT_LOC/moses/mbr.h</locationURI>
+ </link>
+ <link>
<name>rule.proto</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/rule.proto</locationURI>
diff --git a/moses-chart-cmd/Main.cpp b/moses-chart-cmd/Main.cpp
index f3d23e547..74949b2de 100644
--- a/moses-chart-cmd/Main.cpp
+++ b/moses-chart-cmd/Main.cpp
@@ -92,44 +92,6 @@ bool ReadInput(IOWrapperChart &ioWrapper, InputTypeEnum inputType, InputType*& s
}
return (source ? true : false);
}
-static void PrintFeatureWeight(const FeatureFunction* ff)
-{
- cout << ff->GetScoreProducerDescription() << "=";
- size_t numScoreComps = ff->GetNumScoreComponents();
- vector<float> values = StaticData::Instance().GetAllWeights().GetScoresForProducer(ff);
- for (size_t i = 0; i < numScoreComps; ++i) {
- cout << " " << values[i];
- }
- cout << endl;
-
-}
-
-static void ShowWeights()
-{
- fix(cout,6);
- const vector<const StatelessFeatureFunction*>& slf = StatelessFeatureFunction::GetStatelessFeatureFunctions();
- const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
-
- for (size_t i = 0; i < sff.size(); ++i) {
- const StatefulFeatureFunction *ff = sff[i];
- if (ff->IsTuneable()) {
- PrintFeatureWeight(ff);
- }
- else {
- cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
- }
- }
- for (size_t i = 0; i < slf.size(); ++i) {
- const StatelessFeatureFunction *ff = slf[i];
- if (ff->IsTuneable()) {
- PrintFeatureWeight(ff);
- }
- else {
- cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
- }
- }
-}
-
int main(int argc, char* argv[])
{
diff --git a/moses-cmd/Main.cpp b/moses-cmd/Main.cpp
index 8328ddc78..5b3e61515 100644
--- a/moses-cmd/Main.cpp
+++ b/moses-cmd/Main.cpp
@@ -58,44 +58,6 @@ using namespace MosesCmd;
namespace MosesCmd
{
-static void PrintFeatureWeight(const FeatureFunction* ff)
-{
- cout << ff->GetScoreProducerDescription() << "=";
- size_t numScoreComps = ff->GetNumScoreComponents();
- vector<float> values = StaticData::Instance().GetAllWeights().GetScoresForProducer(ff);
- for (size_t i = 0; i < numScoreComps; ++i) {
- cout << " " << values[i];
- }
- cout << endl;
-}
-
-static void ShowWeights()
-{
- //TODO: Find a way of ensuring this order is synced with the nbest
- fix(cout,6);
- const vector<const StatelessFeatureFunction*>& slf = StatelessFeatureFunction::GetStatelessFeatureFunctions();
- const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
-
- for (size_t i = 0; i < sff.size(); ++i) {
- const StatefulFeatureFunction *ff = sff[i];
- if (ff->IsTuneable()) {
- PrintFeatureWeight(ff);
- }
- else {
- cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
- }
- }
- for (size_t i = 0; i < slf.size(); ++i) {
- const StatelessFeatureFunction *ff = slf[i];
- if (ff->IsTuneable()) {
- PrintFeatureWeight(ff);
- }
- else {
- cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
- }
- }
-}
-
void OutputFeatureWeightsForHypergraph(std::ostream &outputSearchGraphStream)
{
outputSearchGraphStream.setf(std::ios::fixed);
diff --git a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp
index 6a3174a59..9a9739de6 100644
--- a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp
+++ b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp
@@ -31,7 +31,7 @@ void OutputVec(const vector<T> &vec)
}
// from phrase-extract/tables-core.cpp
-vector<string> tokenize( const char* input )
+inline vector<string> tokenize( const char* input )
{
vector< string > token;
bool betweenWords = true;
diff --git a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.h b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.h
index 722035d1e..c948b66b2 100644
--- a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.h
+++ b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.h
@@ -30,8 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "moses/UserMessage.h"
#include <exception>
-extern std::vector<std::string> tokenize( const char*);
-
namespace Moses
{
diff --git a/moses/Util.cpp b/moses/Util.cpp
index f92c32dbb..9664c811e 100644
--- a/moses/Util.cpp
+++ b/moses/Util.cpp
@@ -37,6 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "Timer.h"
#include "util/exception.hh"
#include "util/file.hh"
+#include "moses/FF/StatelessFeatureFunction.h"
+#include "moses/FF/StatefulFeatureFunction.h"
+#include "moses/StaticData.h"
using namespace std;
@@ -203,6 +206,44 @@ std::string PassthroughSGML(std::string &line, const std::string tagName, const
return meta;
}
+void PrintFeatureWeight(const FeatureFunction* ff)
+{
+ cout << ff->GetScoreProducerDescription() << "=";
+ size_t numScoreComps = ff->GetNumScoreComponents();
+ vector<float> values = StaticData::Instance().GetAllWeights().GetScoresForProducer(ff);
+ for (size_t i = 0; i < numScoreComps; ++i) {
+ cout << " " << values[i];
+ }
+ cout << endl;
+
}
+void ShowWeights()
+{
+ fix(cout,6);
+ const vector<const StatelessFeatureFunction*>& slf = StatelessFeatureFunction::GetStatelessFeatureFunctions();
+ const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
+
+ for (size_t i = 0; i < sff.size(); ++i) {
+ const StatefulFeatureFunction *ff = sff[i];
+ if (ff->IsTuneable()) {
+ PrintFeatureWeight(ff);
+ }
+ else {
+ cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
+ }
+ }
+ for (size_t i = 0; i < slf.size(); ++i) {
+ const StatelessFeatureFunction *ff = slf[i];
+ if (ff->IsTuneable()) {
+ PrintFeatureWeight(ff);
+ }
+ else {
+ cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
+ }
+ }
+}
+
+} // namespace
+
diff --git a/moses/Util.h b/moses/Util.h
index d4c715ab8..acaa4b53c 100644
--- a/moses/Util.h
+++ b/moses/Util.h
@@ -438,6 +438,10 @@ inline void fix(std::ostream& stream, size_t size)
stream.precision(size);
}
+class FeatureFunction;
+
+void PrintFeatureWeight(const FeatureFunction* ff);
+void ShowWeights();
} // namespace