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
path: root/moses
diff options
context:
space:
mode:
authorMatthias Huck <huck@i6.informatik.rwth-aachen.de>2015-02-27 05:39:43 +0300
committerMatthias Huck <huck@i6.informatik.rwth-aachen.de>2015-02-27 05:39:43 +0300
commit0d4678577b45a154cf864d99e88f697698078b1b (patch)
tree24d4f8f6fb7db6b7f85f5d0b06c68906da85628c /moses
parent39c0068e4fe4d0451553bbafa3dc94b10d4febc8 (diff)
floor value, glue rules, some cleanup
Diffstat (limited to 'moses')
-rw-r--r--moses/FF/Model1Feature.cpp2
-rw-r--r--moses/FF/Model1Feature.h4
-rw-r--r--moses/FF/SoftSourceSyntacticConstraintsFeature.cpp30
3 files changed, 23 insertions, 13 deletions
diff --git a/moses/FF/Model1Feature.cpp b/moses/FF/Model1Feature.cpp
index b3390d36b..38883c12e 100644
--- a/moses/FF/Model1Feature.cpp
+++ b/moses/FF/Model1Feature.cpp
@@ -203,7 +203,7 @@ void Model1Feature::EvaluateWithSourceContext(const InputType &input
// cache lookup
bool foundInCache = false;
{
- #ifdef WITH_THREADS //try read-only lock
+ #ifdef WITH_THREADS
boost::shared_lock<boost::shared_mutex> read_lock(m_accessLock);
#endif
boost::unordered_map<const InputType*, boost::unordered_map<const Factor*, float> >::const_iterator sentenceCache = m_cache.find(&input);
diff --git a/moses/FF/Model1Feature.h b/moses/FF/Model1Feature.h
index 3ff4c6b96..d526d165a 100644
--- a/moses/FF/Model1Feature.h
+++ b/moses/FF/Model1Feature.h
@@ -6,6 +6,10 @@
#include "StatelessFeatureFunction.h"
#include "moses/Factor.h"
+#ifdef WITH_THREADS
+#include <boost/thread/shared_mutex.hpp>
+#endif
+
namespace Moses
{
diff --git a/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp b/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp
index fb406a048..05a3c92e0 100644
--- a/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp
+++ b/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp
@@ -102,7 +102,7 @@ void SoftSourceSyntacticConstraintsFeature::Load()
void SoftSourceSyntacticConstraintsFeature::LoadSourceLabelSet()
{
- FEATUREVERBOSE(2, "Loading source label set from file " << m_sourceLabelSetFile << std::endl);
+ FEATUREVERBOSE(2, "Loading source label set from file " << m_sourceLabelSetFile << " ...");
InputFileStream inFile(m_sourceLabelSetFile);
FactorCollection &factorCollection = FactorCollection::Instance();
@@ -166,20 +166,21 @@ void SoftSourceSyntacticConstraintsFeature::LoadSourceLabelSet()
// m_XLHSLabel = found->second;
}
}
+ FEATUREVERBOSE2(2, " Done." << std::endl);
}
void SoftSourceSyntacticConstraintsFeature::LoadCoreSourceLabelSet()
{
- FEATUREVERBOSE(2, "Loading core source label set from file " << m_coreSourceLabelSetFile << std::endl);
+ FEATUREVERBOSE(2, "Loading core source label set from file " << m_coreSourceLabelSetFile << " ...");
// read core source label set
LoadLabelSet(m_coreSourceLabelSetFile, m_coreSourceLabels);
+ FEATUREVERBOSE2(2, " Done." << std::endl);
}
void SoftSourceSyntacticConstraintsFeature::LoadLabelSet(std::string &filename,
boost::unordered_set<size_t> &labelSet)
{
- FEATUREVERBOSE(2, "Loading core source label set from file " << m_coreSourceLabelSetFile << std::endl);
InputFileStream inFile(filename);
std::string line;
labelSet.clear();
@@ -203,7 +204,7 @@ void SoftSourceSyntacticConstraintsFeature::LoadLabelSet(std::string &filename,
void SoftSourceSyntacticConstraintsFeature::LoadTargetSourceLeftHandSideJointCountFile()
{
- FEATUREVERBOSE(2, "Loading target/source label joint counts from file " << m_targetSourceLHSJointCountFile << std::endl);
+ FEATUREVERBOSE(2, "Loading target/source label joint counts from file " << m_targetSourceLHSJointCountFile << " ...");
InputFileStream inFile(m_targetSourceLHSJointCountFile);
for (boost::unordered_map<const Factor*, std::vector< std::pair<float,float> >* >::iterator iter=m_labelPairProbabilities.begin();
@@ -251,7 +252,7 @@ void SoftSourceSyntacticConstraintsFeature::LoadTargetSourceLeftHandSideJointCou
std::pair< boost::unordered_map<const Factor*, std::vector< std::pair<float,float> >* >::iterator, bool > insertedJointCount =
m_labelPairProbabilities.insert( std::pair<const Factor*, std::vector< std::pair<float,float> >* >(targetLabelFactor,sourceVector) );
UTIL_THROW_IF2(!insertedJointCount.second, GetScoreProducerDescription()
- << ": Reading target/source label joint counts from file " << m_targetSourceLHSJointCountFile << " failed.");
+ << ": Loading target/source label joint counts from file " << m_targetSourceLHSJointCountFile << " failed.");
}
}
@@ -278,6 +279,7 @@ void SoftSourceSyntacticConstraintsFeature::LoadTargetSourceLeftHandSideJointCou
}
inFile.Close();
+ FEATUREVERBOSE2(2, " Done." << std::endl);
}
@@ -290,18 +292,18 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu
{
assert(stackVec);
- IFFEATUREVERBOSE(2) {
- FEATUREVERBOSE(2, targetPhrase << std::endl);
- FEATUREVERBOSE(2, inputPath << std::endl);
+ IFFEATUREVERBOSE(3) {
+ FEATUREVERBOSE(3, targetPhrase << std::endl);
+ FEATUREVERBOSE(3, inputPath << std::endl);
for (size_t i = 0; i < stackVec->size(); ++i) {
const ChartCellLabel &cell = *stackVec->at(i);
const WordsRange &ntRange = cell.GetCoverage();
- FEATUREVERBOSE(2, "stackVec[ " << i << " ] : " << ntRange.GetStartPos() << " - " << ntRange.GetEndPos() << std::endl);
+ FEATUREVERBOSE(3, "stackVec[ " << i << " ] : " << ntRange.GetStartPos() << " - " << ntRange.GetEndPos() << std::endl);
}
for (AlignmentInfo::const_iterator it=targetPhrase.GetAlignNonTerm().begin();
it!=targetPhrase.GetAlignNonTerm().end(); ++it) {
- FEATUREVERBOSE(2, "alignNonTerm " << it->first << " " << it->second << std::endl);
+ FEATUREVERBOSE(3, "alignNonTerm " << it->first << " " << it->second << std::endl);
}
}
@@ -546,7 +548,7 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu
}
- if ( m_useSparseLabelPairs ) {
+ if ( m_useSparseLabelPairs && !isGlueGrammarRule ) {
// left-hand side label pairs (target NT, source NT)
float t2sLabelsScore = 0.0;
@@ -634,7 +636,11 @@ std::pair<float,float> SoftSourceSyntacticConstraintsFeature::GetLabelPairProbab
if ( found == m_labelPairProbabilities.end() ) {
return std::pair<float,float>(m_floor,m_floor); // floor values
}
- return found->second->at(source);
+ std::pair<float,float> ret = found->second->at(source);
+ if ( ret == std::pair<float,float>(0,0) ) {
+ return std::pair<float,float>(m_floor,m_floor); // floor values
+ }
+ return ret;
}