From 64aea22425305d1a2c1e4c046e8d89f5f1536fd8 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Thu, 16 Jun 2016 14:20:28 +0100 Subject: [PATCH 1/5] Enabled c++0x flag for gcc. --- Jamroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jamroot b/Jamroot index 4118248c1..c8b28445e 100644 --- a/Jamroot +++ b/Jamroot @@ -111,7 +111,7 @@ external-lib z ; #lib dl : : static:static shared:shared ; #requirements += dl ; -#requirements += -std=c++0x ; +requirements += -std=c++0x ; # Allow moses to report the git commit hash of the version used for compilation moses_githash = [ _shell "git describe --dirty" ] ; From 14d7df229f20f5220b52233aad4ae2cf85679fc6 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Thu, 16 Jun 2016 14:22:10 +0100 Subject: [PATCH 2/5] Changed paths for vowpalwabbit to include directly from build directory. --- vw/Jamfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vw/Jamfile b/vw/Jamfile index 0eda14c9a..2e8547ae0 100644 --- a/vw/Jamfile +++ b/vw/Jamfile @@ -6,11 +6,11 @@ boost 103600 ; # VW local with-vw = [ option.get "with-vw" ] ; if $(with-vw) { - lib vw : : $(with-vw)/lib ; - lib allreduce : : $(with-vw)/lib ; + lib vw : : $(with-vw)/vowpalwabbit ; + lib allreduce : : $(with-vw)/vowpalwabbit ; - obj ClassifierFactory.o : ClassifierFactory.cpp headers : $(with-vw)/include/vowpalwabbit ; - obj VWPredictor.o : VWPredictor.cpp headers : $(with-vw)/include/vowpalwabbit ; + obj ClassifierFactory.o : ClassifierFactory.cpp headers : $(with-vw)/vowpalwabbit ; + obj VWPredictor.o : VWPredictor.cpp headers : $(with-vw)/vowpalwabbit ; alias vw_objects : VWPredictor.o ClassifierFactory.o vw allreduce : : : boost_program_options ; lib classifier : [ glob *.cpp : VWPredictor.cpp ClassifierFactory.cpp ] vw_objects headers ; From 5282ad667c4fd6e0fe111e3e982c950c5e4af6b3 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Thu, 16 Jun 2016 14:22:58 +0100 Subject: [PATCH 3/5] Global scope for VW training. --- moses-cmd/MainVW.cpp | 13 ++++++------- moses/TrainingTask.h | 12 ++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/moses-cmd/MainVW.cpp b/moses-cmd/MainVW.cpp index 2f313df01..0e611b139 100644 --- a/moses-cmd/MainVW.cpp +++ b/moses-cmd/MainVW.cpp @@ -51,12 +51,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "hypergraph.pb.h" #endif -#ifdef PT_UG -#include -#include "moses/TranslationModel/UG/mmsapt.h" -#include "moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.h" -#endif - using namespace std; using namespace Moses; @@ -76,6 +70,9 @@ void OutputFeatureWeightsForHypergraph(std::ostream &outputSearchGraphStream) /** main function of the command line version of the decoder **/ int main(int argc, char const** argv) { + //setting in the Staticdata a link between the thread id of this process and a NULL tasksptr + // StaticData::InstanceNonConst().SetTask(); // => moved into StaticData constructor + try { #ifdef HAVE_PROTOBUF @@ -141,11 +138,13 @@ int main(int argc, char const** argv) } #ifdef WITH_THREADS +#pragma message ("Compiling with Threads.") ThreadPool pool(staticData.ThreadCount()); #endif // main loop over set of input sentences + boost::shared_ptr scope(new ContextScope); boost::shared_ptr source; while ((source = ioWrapper->ReadInput()) != NULL) { IFVERBOSE(1) { @@ -154,7 +153,7 @@ int main(int argc, char const** argv) // set up task of training one sentence boost::shared_ptr task; - task = TrainingTask::create(source, ioWrapper); + task = TrainingTask::create(source, ioWrapper, scope); // execute task #ifdef WITH_THREADS diff --git a/moses/TrainingTask.h b/moses/TrainingTask.h index 4d2152920..eed6d7d4b 100644 --- a/moses/TrainingTask.h +++ b/moses/TrainingTask.h @@ -39,6 +39,18 @@ public: boost::shared_ptr const& ioWrapper) { boost::shared_ptr ret(new TrainingTask(source, ioWrapper)); ret->m_self = ret; + ret->m_scope.reset(new ContextScope); + return ret; + } + + // factory function + static boost::shared_ptr + create(boost::shared_ptr const& source, + boost::shared_ptr const& ioWrapper, + boost::shared_ptr const& scope) { + boost::shared_ptr ret(new TrainingTask(source, ioWrapper)); + ret->m_self = ret; + ret->m_scope = scope; return ret; } From 08138b44a7ddcab141530496899e334a5d500110 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Sat, 4 Mar 2017 13:21:18 +0000 Subject: [PATCH 4/5] Bug fix in scripts/generic/bsbleu.py. --- scripts/generic/bsbleu.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/generic/bsbleu.py b/scripts/generic/bsbleu.py index f3c99747f..d40a28e6e 100755 --- a/scripts/generic/bsbleu.py +++ b/scripts/generic/bsbleu.py @@ -64,22 +64,29 @@ class BleuScore: self.lower = None self.upper = None self.median = None - self.bootstrap = [ - self.score([randint(0, len(hyp.snt) - 1) for s in hyp.snt]) - for i in xrange(1000)] - self.bootstrap.sort() self.actual = self.score([i for i in xrange(len(hyp.snt))]) + if bootstrap: + self.bootstrap = [self.score([randint(0, len(hyp.snt) - 1) + for s in hyp.snt]) + for i in xrange(bootstrap)] + self.bootstrap.sort() + else: + self.bootstrap = [self.actual] + pass def score(self, sample): hits = [0 for i in xrange(self.max_n)] self.hyplen = 0 self.reflen = 0 + self.total = [0 for i in hits] for i in sample: self.hyplen += len(self.hyp.snt[i]) self.reflen += len(self.ref.snt[i]) for n in xrange(self.max_n): hits[n] += self.hits[i][n] - self.prec = [float(hits[n]) / (self.hyplen - n * len(sample)) + self.total[n] += max(len(self.hyp.snt[i]) - n, 0) + pass + self.prec = [float(hits[n]) / self.total[n] for n in xrange(self.max_n)] ret = sum([math.log(x) for x in self.prec]) / self.max_n self.BP = min( From 743a63b6d3fdabcc3be3f79cc34edf344b30d6b7 Mon Sep 17 00:00:00 2001 From: MosesAdmin Date: Sun, 5 Mar 2017 00:00:41 +0000 Subject: [PATCH 5/5] daily automatic beautifier --- moses-cmd/MainVW.cpp | 2 +- moses/TrainingTask.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/moses-cmd/MainVW.cpp b/moses-cmd/MainVW.cpp index 0e611b139..694dcee8a 100644 --- a/moses-cmd/MainVW.cpp +++ b/moses-cmd/MainVW.cpp @@ -72,7 +72,7 @@ int main(int argc, char const** argv) { //setting in the Staticdata a link between the thread id of this process and a NULL tasksptr // StaticData::InstanceNonConst().SetTask(); // => moved into StaticData constructor - + try { #ifdef HAVE_PROTOBUF diff --git a/moses/TrainingTask.h b/moses/TrainingTask.h index eed6d7d4b..83933691d 100644 --- a/moses/TrainingTask.h +++ b/moses/TrainingTask.h @@ -47,7 +47,7 @@ public: static boost::shared_ptr create(boost::shared_ptr const& source, boost::shared_ptr const& ioWrapper, - boost::shared_ptr const& scope) { + boost::shared_ptr const& scope) { boost::shared_ptr ret(new TrainingTask(source, ioWrapper)); ret->m_self = ret; ret->m_scope = scope;