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>2015-01-14 14:07:42 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-01-14 14:07:42 +0300
commit05ead45e71916c5763c5c4b6375e2ca6838f3995 (patch)
treec279bd4aacfb31758720ffbaf5aaf62022574a52 /moses/Syntax
parent91cb549ccf09fc33122f3d531f47c38ad0e99b3d (diff)
beautify
Diffstat (limited to 'moses/Syntax')
-rw-r--r--moses/Syntax/BoundedPriorityContainer.h40
-rw-r--r--moses/Syntax/Cube.cpp4
-rw-r--r--moses/Syntax/Cube.h16
-rw-r--r--moses/Syntax/CubeQueue.h10
-rw-r--r--moses/Syntax/KBestExtractor.cpp51
-rw-r--r--moses/Syntax/KBestExtractor.h12
-rw-r--r--moses/Syntax/Manager.cpp26
-rw-r--r--moses/Syntax/Manager.h14
-rw-r--r--moses/Syntax/NonTerminalMap.h40
-rw-r--r--moses/Syntax/PHyperedge.h3
-rw-r--r--moses/Syntax/PVertex.h5
-rw-r--r--moses/Syntax/RuleTable.h4
-rw-r--r--moses/Syntax/RuleTableFF.h15
-rw-r--r--moses/Syntax/S2T/DerivationWriter.h4
-rw-r--r--moses/Syntax/S2T/Manager-inl.h44
-rw-r--r--moses/Syntax/S2T/Manager.h10
-rw-r--r--moses/Syntax/S2T/OovHandler-inl.h8
-rw-r--r--moses/Syntax/S2T/OovHandler.h4
-rw-r--r--moses/Syntax/S2T/PChart.h17
-rw-r--r--moses/Syntax/S2T/PHyperedgeToSHyperedgeBundle.h7
-rw-r--r--moses/Syntax/S2T/ParserCallback.h40
-rw-r--r--moses/Syntax/S2T/Parsers/Parser.h4
-rw-r--r--moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h49
-rw-r--r--moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h8
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h16
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h6
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.cpp16
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.h10
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/SentenceMap.h2
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.cpp8
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.h4
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/TailLattice.h8
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.cpp6
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.h4
-rw-r--r--moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeSearcher.h6
-rw-r--r--moses/Syntax/S2T/RuleTrie.h4
-rw-r--r--moses/Syntax/S2T/RuleTrieCYKPlus.cpp20
-rw-r--r--moses/Syntax/S2T/RuleTrieCYKPlus.h26
-rw-r--r--moses/Syntax/S2T/RuleTrieCreator.h6
-rw-r--r--moses/Syntax/S2T/RuleTrieLoader.cpp4
-rw-r--r--moses/Syntax/S2T/RuleTrieLoader.h2
-rw-r--r--moses/Syntax/S2T/RuleTrieScope3.cpp10
-rw-r--r--moses/Syntax/S2T/RuleTrieScope3.h42
-rw-r--r--moses/Syntax/S2T/SChart.h13
-rw-r--r--moses/Syntax/SHyperedge.cpp36
-rw-r--r--moses/Syntax/SHyperedge.h3
-rw-r--r--moses/Syntax/SHyperedgeBundle.h3
-rw-r--r--moses/Syntax/SHyperedgeBundleScorer.h7
-rw-r--r--moses/Syntax/SVertex.h3
-rw-r--r--moses/Syntax/SVertexRecombinationOrderer.h11
-rw-r--r--moses/Syntax/SVertexStack.h8
-rw-r--r--moses/Syntax/SymbolEqualityPred.h2
-rw-r--r--moses/Syntax/SymbolHasher.h2
53 files changed, 398 insertions, 325 deletions
diff --git a/moses/Syntax/BoundedPriorityContainer.h b/moses/Syntax/BoundedPriorityContainer.h
index 9afc1b75d..192f9ff2e 100644
--- a/moses/Syntax/BoundedPriorityContainer.h
+++ b/moses/Syntax/BoundedPriorityContainer.h
@@ -24,20 +24,30 @@ namespace Syntax
template<typename T>
class BoundedPriorityContainer
{
- public:
+public:
typedef typename std::vector<T>::iterator Iterator;
typedef typename std::vector<T>::const_iterator ConstIterator;
BoundedPriorityContainer(std::size_t);
- Iterator Begin() { return m_elements.begin(); }
- Iterator End() { return m_elements.begin()+m_size; }
+ Iterator Begin() {
+ return m_elements.begin();
+ }
+ Iterator End() {
+ return m_elements.begin()+m_size;
+ }
- ConstIterator Begin() const { return m_elements.begin(); }
- ConstIterator End() const { return m_elements.begin()+m_size; }
+ ConstIterator Begin() const {
+ return m_elements.begin();
+ }
+ ConstIterator End() const {
+ return m_elements.begin()+m_size;
+ }
// Return the number of elements currently held.
- std::size_t Size() const { return m_size; }
+ std::size_t Size() const {
+ return m_size;
+ }
// 'Lazily' clear the container by setting the size to 0 (allowing elements
// to be overwritten).
@@ -46,7 +56,12 @@ class BoundedPriorityContainer
// TODO Alternative, is to clear m_queue by assigning an empty queue value
// TODO but that might incur an alloc-related overhead when the new underlying
// TODO has to be regrown.
- void LazyClear() { m_size = 0; while (!m_queue.empty()) { m_queue.pop(); } }
+ void LazyClear() {
+ m_size = 0;
+ while (!m_queue.empty()) {
+ m_queue.pop();
+ }
+ }
// Insert the given object iff
// i) the container is not full yet, or
@@ -67,17 +82,16 @@ class BoundedPriorityContainer
// Determine if an object with the given priority would be accepted for
// insertion based on the current contents of the container.
- bool WouldAccept(float priority)
- {
+ bool WouldAccept(float priority) {
return m_size < m_limit || priority > m_queue.top().first;
}
- private:
+private:
typedef std::pair<float, int> PriorityIndexPair;
class PriorityIndexPairOrderer
{
- public:
+ public:
bool operator()(const PriorityIndexPair &p,
const PriorityIndexPair &q) const {
return p.first > q.first;
@@ -87,8 +101,8 @@ class BoundedPriorityContainer
// Min-priority queue. The queue stores the indices of the elements, not
// the elements themselves to keep down the costs of heap maintenance.
typedef std::priority_queue<PriorityIndexPair,
- std::vector<PriorityIndexPair>,
- PriorityIndexPairOrderer> Queue;
+ std::vector<PriorityIndexPair>,
+ PriorityIndexPairOrderer> Queue;
// The elements are stored in a vector. Note that the size of this vector
// can be greater than m_size (after a call to LazyClear).
diff --git a/moses/Syntax/Cube.cpp b/moses/Syntax/Cube.cpp
index 4fcf50829..7b7f4cb91 100644
--- a/moses/Syntax/Cube.cpp
+++ b/moses/Syntax/Cube.cpp
@@ -14,7 +14,7 @@ namespace Syntax
{
Cube::Cube(const SHyperedgeBundle &bundle)
- : m_bundle(bundle)
+ : m_bundle(bundle)
{
// Create the SHyperedge for the 'corner' of the cube.
std::vector<int> coordinates(bundle.stacks.size()+1, 0);
@@ -94,7 +94,7 @@ SHyperedge *Cube::CreateHyperedge(const std::vector<int> &coordinates)
head->best = hyperedge;
head->pvertex = 0; // FIXME???
head->state.resize(
- StatefulFeatureFunction::GetStatefulFeatureFunctions().size());
+ StatefulFeatureFunction::GetStatefulFeatureFunctions().size());
hyperedge->head = head;
hyperedge->tail.resize(coordinates.size()-1);
diff --git a/moses/Syntax/Cube.h b/moses/Syntax/Cube.h
index a28440834..a887b2fbb 100644
--- a/moses/Syntax/Cube.h
+++ b/moses/Syntax/Cube.h
@@ -19,31 +19,35 @@ namespace Syntax
// best-first order.
class Cube
{
- public:
+public:
Cube(const SHyperedgeBundle &);
~Cube();
SHyperedge *Pop();
- SHyperedge *Top() const { return m_queue.top().first; }
+ SHyperedge *Top() const {
+ return m_queue.top().first;
+ }
- bool IsEmpty() const { return m_queue.empty(); }
+ bool IsEmpty() const {
+ return m_queue.empty();
+ }
- private:
+private:
typedef boost::unordered_set<std::vector<int> > CoordinateSet;
typedef std::pair<SHyperedge *, const std::vector<int> *> QueueItem;
class QueueItemOrderer
{
- public:
+ public:
bool operator()(const QueueItem &p, const QueueItem &q) const {
return p.first->score < q.first->score;
}
};
typedef std::priority_queue<QueueItem, std::vector<QueueItem>,
- QueueItemOrderer> Queue;
+ QueueItemOrderer> Queue;
SHyperedge *CreateHyperedge(const std::vector<int> &);
void CreateNeighbour(const std::vector<int> &);
diff --git a/moses/Syntax/CubeQueue.h b/moses/Syntax/CubeQueue.h
index 304e59409..e168d0465 100644
--- a/moses/Syntax/CubeQueue.h
+++ b/moses/Syntax/CubeQueue.h
@@ -14,7 +14,7 @@ namespace Syntax
class CubeQueue
{
- public:
+public:
template<typename InputIterator>
CubeQueue(InputIterator, InputIterator);
@@ -22,12 +22,14 @@ class CubeQueue
SHyperedge *Pop();
- bool IsEmpty() const { return m_queue.empty(); }
+ bool IsEmpty() const {
+ return m_queue.empty();
+ }
- private:
+private:
class CubeOrderer
{
- public:
+ public:
bool operator()(const Cube *p, const Cube *q) const {
return p->Top()->score < q->Top()->score;
}
diff --git a/moses/Syntax/KBestExtractor.cpp b/moses/Syntax/KBestExtractor.cpp
index 335d80409..66939ca17 100644
--- a/moses/Syntax/KBestExtractor.cpp
+++ b/moses/Syntax/KBestExtractor.cpp
@@ -14,8 +14,8 @@ namespace Syntax
// Extract the k-best list from the search graph.
void KBestExtractor::Extract(
- const std::vector<boost::shared_ptr<SVertex> > &topLevelVertices,
- std::size_t k, KBestVec &kBestList)
+ const std::vector<boost::shared_ptr<SVertex> > &topLevelVertices,
+ std::size_t k, KBestVec &kBestList)
{
kBestList.clear();
if (topLevelVertices.empty()) {
@@ -25,7 +25,7 @@ void KBestExtractor::Extract(
// Create a new SVertex, supremeVertex, that has the best top-level SVertex as
// its predecessor and has the same score.
std::vector<boost::shared_ptr<SVertex> >::const_iterator p =
- topLevelVertices.begin();
+ topLevelVertices.begin();
SVertex &bestTopLevelVertex = **p;
boost::scoped_ptr<SVertex> supremeVertex(new SVertex());
supremeVertex->pvertex = 0;
@@ -61,8 +61,8 @@ void KBestExtractor::Extract(
// each derivation.
kBestList.reserve(targetVertex->kBestList.size());
for (std::vector<boost::weak_ptr<Derivation> >::const_iterator
- q = targetVertex->kBestList.begin();
- q != targetVertex->kBestList.end(); ++q) {
+ q = targetVertex->kBestList.begin();
+ q != targetVertex->kBestList.end(); ++q) {
const boost::shared_ptr<Derivation> d(*q);
assert(d);
assert(d->subderivations.size() == 1);
@@ -94,24 +94,24 @@ Phrase KBestExtractor::GetOutputPhrase(const Derivation &d)
}
// FIXME
UTIL_THROW2("placeholders are not currently supported by the S2T decoder");
-/*
- std::set<std::size_t> sourcePosSet =
- phrase.GetAlignTerm().GetAlignmentsForTarget(pos);
- if (sourcePosSet.size() == 1) {
- const std::vector<const Word*> *ruleSourceFromInputPath =
- hypo.GetTranslationOption().GetSourceRuleFromInputPath();
- UTIL_THROW_IF2(ruleSourceFromInputPath == NULL,
- "Source Words in of the rules hasn't been filled out");
- std::size_t sourcePos = *sourcePosSet.begin();
- const Word *sourceWord = ruleSourceFromInputPath->at(sourcePos);
- UTIL_THROW_IF2(sourceWord == NULL,
- "Null source word at position " << sourcePos);
- const Factor *factor = sourceWord->GetFactor(placeholderFactor);
- if (factor) {
- ret.Back()[0] = factor;
- }
- }
-*/
+ /*
+ std::set<std::size_t> sourcePosSet =
+ phrase.GetAlignTerm().GetAlignmentsForTarget(pos);
+ if (sourcePosSet.size() == 1) {
+ const std::vector<const Word*> *ruleSourceFromInputPath =
+ hypo.GetTranslationOption().GetSourceRuleFromInputPath();
+ UTIL_THROW_IF2(ruleSourceFromInputPath == NULL,
+ "Source Words in of the rules hasn't been filled out");
+ std::size_t sourcePos = *sourcePosSet.begin();
+ const Word *sourceWord = ruleSourceFromInputPath->at(sourcePos);
+ UTIL_THROW_IF2(sourceWord == NULL,
+ "Null source word at position " << sourcePos);
+ const Factor *factor = sourceWord->GetFactor(placeholderFactor);
+ if (factor) {
+ ret.Back()[0] = factor;
+ }
+ }
+ */
}
}
@@ -140,8 +140,7 @@ TreePointer KBestExtractor::GetOutputTree(const Derivation &d)
mytree->Combine(previous_trees);
return mytree;
- }
- else {
+ } else {
UTIL_THROW2("Error: TreeStructureFeature active, but no internal tree structure found");
}
}
@@ -180,7 +179,7 @@ KBestExtractor::FindOrCreateVertex(const SVertex &v)
}
boost::shared_ptr<Derivation> bestDerivation(new Derivation(bestEdge));
#ifndef NDEBUG
- std::pair<DerivationSet::iterator, bool> q =
+ std::pair<DerivationSet::iterator, bool> q =
#endif
m_derivations.insert(bestDerivation);
assert(q.second);
diff --git a/moses/Syntax/KBestExtractor.h b/moses/Syntax/KBestExtractor.h
index 248d26c01..15cf0e3c8 100644
--- a/moses/Syntax/KBestExtractor.h
+++ b/moses/Syntax/KBestExtractor.h
@@ -28,7 +28,7 @@ namespace Syntax
//
class KBestExtractor
{
- public:
+public:
struct KVertex;
struct KHyperedge {
@@ -61,8 +61,8 @@ class KBestExtractor
struct KVertex {
typedef std::priority_queue<boost::weak_ptr<Derivation>,
- std::vector<boost::weak_ptr<Derivation> >,
- DerivationOrderer> DerivationQueue;
+ std::vector<boost::weak_ptr<Derivation> >,
+ DerivationOrderer> DerivationQueue;
KVertex(const SVertex &v) : svertex(v), visited(false) {}
@@ -82,9 +82,9 @@ class KBestExtractor
static Phrase GetOutputPhrase(const Derivation &);
static TreePointer GetOutputTree(const Derivation &);
- private:
+private:
typedef boost::unordered_map<const SVertex *,
- boost::shared_ptr<KVertex> > VertexMap;
+ boost::shared_ptr<KVertex> > VertexMap;
struct DerivationHasher {
std::size_t operator()(const boost::shared_ptr<Derivation> &d) const {
@@ -104,7 +104,7 @@ class KBestExtractor
};
typedef boost::unordered_set<boost::shared_ptr<Derivation>, DerivationHasher,
- DerivationEqualityPred> DerivationSet;
+ DerivationEqualityPred> DerivationSet;
boost::shared_ptr<KVertex> FindOrCreateVertex(const SVertex &);
void GetCandidates(boost::shared_ptr<KVertex>, std::size_t);
diff --git a/moses/Syntax/Manager.cpp b/moses/Syntax/Manager.cpp
index 5db9e66fb..10ee4217e 100644
--- a/moses/Syntax/Manager.cpp
+++ b/moses/Syntax/Manager.cpp
@@ -13,7 +13,7 @@ namespace Syntax
{
Manager::Manager(const InputType &source)
- : Moses::BaseManager(source)
+ : Moses::BaseManager(source)
{
}
@@ -37,7 +37,7 @@ void Manager::OutputBest(OutputCollector *collector) const
Phrase yield = GetOneBestTargetYield(*best);
// delete 1st & last
UTIL_THROW_IF2(yield.GetSize() < 2,
- "Output phrase should have contained at least 2 words (beginning and end-of-sentence)");
+ "Output phrase should have contained at least 2 words (beginning and end-of-sentence)");
yield.RemoveWord(0);
yield.RemoveWord(yield.GetSize()-1);
out << yield.GetStringRep(StaticData::Instance().GetOutputFactorOrder());
@@ -66,7 +66,7 @@ void Manager::OutputUnknowns(OutputCollector *collector) const
std::ostringstream out;
for (std::set<Moses::Word>::const_iterator p = m_oovs.begin();
- p != m_oovs.end(); ++p) {
+ p != m_oovs.end(); ++p) {
out << *p;
}
out << std::endl;
@@ -95,7 +95,7 @@ void Manager::OutputNBestList(OutputCollector *collector,
bool PrintNBestTrees = staticData.PrintNBestTrees();
for (KBestExtractor::KBestVec::const_iterator p = nBestList.begin();
- p != nBestList.end(); ++p) {
+ p != nBestList.end(); ++p) {
const KBestExtractor::Derivation &derivation = **p;
// get the derivation's target-side yield
@@ -103,7 +103,7 @@ void Manager::OutputNBestList(OutputCollector *collector,
// delete <s> and </s>
UTIL_THROW_IF2(outputPhrase.GetSize() < 2,
- "Output phrase should have contained at least 2 words (beginning and end-of-sentence)");
+ "Output phrase should have contained at least 2 words (beginning and end-of-sentence)");
outputPhrase.RemoveWord(0);
outputPhrase.RemoveWord(outputPhrase.GetSize() - 1);
@@ -120,7 +120,7 @@ void Manager::OutputNBestList(OutputCollector *collector,
Alignments align;
OutputAlignmentNBest(align, derivation, 0);
for (Alignments::const_iterator q = align.begin(); q != align.end();
- ++q) {
+ ++q) {
out << q->first << "-" << q->second << " ";
}
}
@@ -139,9 +139,9 @@ void Manager::OutputNBestList(OutputCollector *collector,
}
std::size_t Manager::OutputAlignmentNBest(
- Alignments &retAlign,
- const KBestExtractor::Derivation &derivation,
- std::size_t startTarget) const
+ Alignments &retAlign,
+ const KBestExtractor::Derivation &derivation,
+ std::size_t startTarget) const
{
const SHyperedge &shyperedge = derivation.edge->shyperedge;
@@ -160,10 +160,10 @@ std::size_t Manager::OutputAlignmentNBest(
const AlignmentInfo &aiNonTerm = shyperedge.translation->GetAlignNonTerm();
std::vector<std::size_t> sourceInd2pos = aiNonTerm.GetSourceIndex2PosMap();
const AlignmentInfo::NonTermIndexMap &targetPos2SourceInd =
- aiNonTerm.GetNonTermIndexMap();
+ aiNonTerm.GetNonTermIndexMap();
UTIL_THROW_IF2(sourceInd2pos.size() != derivation.subderivations.size(),
- "Error");
+ "Error");
std::size_t targetInd = 0;
for (std::size_t targetPos = 0; targetPos < tp.GetSize(); ++targetPos) {
@@ -184,7 +184,7 @@ std::size_t Manager::OutputAlignmentNBest(
// Recursively look thru child hypos
std::size_t currStartTarget = startTarget + totalTargetSize;
std::size_t targetSize = OutputAlignmentNBest(retAlign, subderivation,
- currStartTarget);
+ currStartTarget);
targetOffsets[targetPos] = targetSize;
totalTargetSize += targetSize;
@@ -225,7 +225,7 @@ std::size_t Manager::CalcSourceSize(const KBestExtractor::Derivation &d) const
std::size_t ret = shyperedge.head->pvertex->span.GetNumWordsCovered();
for (std::size_t i = 0; i < shyperedge.tail.size(); ++i) {
std::size_t childSize =
- shyperedge.tail[i]->pvertex->span.GetNumWordsCovered();
+ shyperedge.tail[i]->pvertex->span.GetNumWordsCovered();
ret -= (childSize - 1);
}
return ret;
diff --git a/moses/Syntax/Manager.h b/moses/Syntax/Manager.h
index 108791b19..8d814f604 100644
--- a/moses/Syntax/Manager.h
+++ b/moses/Syntax/Manager.h
@@ -13,7 +13,7 @@ namespace Syntax
// Common base class for Moses::Syntax managers.
class Manager : public BaseManager
{
- public:
+public:
Manager(const InputType &);
// Virtual functions from Moses::BaseManager that are implemented the same
@@ -26,7 +26,7 @@ class Manager : public BaseManager
// managers.
void OutputAlignment(OutputCollector *collector) const {}
void OutputDetailedTreeFragmentsTranslationReport(
- OutputCollector *collector) const {}
+ OutputCollector *collector) const {}
void OutputLatticeSamples(OutputCollector *collector) const {}
void OutputSearchGraph(OutputCollector *collector) const {}
void OutputSearchGraphHypergraph() const {}
@@ -38,15 +38,15 @@ class Manager : public BaseManager
// Syntax-specific virtual functions that derived classes must implement.
virtual void ExtractKBest(
- std::size_t k,
- std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
- bool onlyDistinct=false) const = 0;
+ std::size_t k,
+ std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
+ bool onlyDistinct=false) const = 0;
virtual const SHyperedge *GetBestSHyperedge() const = 0;
- protected:
+protected:
std::set<Word> m_oovs;
- private:
+private:
// Syntax-specific helper functions used to implement OutputNBest.
void OutputNBestList(OutputCollector *collector,
const KBestExtractor::KBestVec &nBestList,
diff --git a/moses/Syntax/NonTerminalMap.h b/moses/Syntax/NonTerminalMap.h
index ff7ce2508..b645212c5 100644
--- a/moses/Syntax/NonTerminalMap.h
+++ b/moses/Syntax/NonTerminalMap.h
@@ -23,42 +23,56 @@ namespace Syntax
template<typename T>
class NonTerminalMap
{
- private:
+private:
typedef boost::unordered_map<Word, T, SymbolHasher, SymbolEqualityPred> Map;
typedef std::vector<T*> Vec;
- public:
+public:
typedef typename Map::iterator Iterator;
typedef typename Map::const_iterator ConstIterator;
NonTerminalMap()
- : m_vec(FactorCollection::Instance().GetNumNonTerminals(), NULL) {}
+ : m_vec(FactorCollection::Instance().GetNumNonTerminals(), NULL) {}
- Iterator Begin() { return m_map.begin(); }
- Iterator End() { return m_map.end(); }
+ Iterator Begin() {
+ return m_map.begin();
+ }
+ Iterator End() {
+ return m_map.end();
+ }
- ConstIterator Begin() const { return m_map.begin(); }
- ConstIterator End() const { return m_map.end(); }
+ ConstIterator Begin() const {
+ return m_map.begin();
+ }
+ ConstIterator End() const {
+ return m_map.end();
+ }
- std::size_t Size() const { return m_map.size(); }
+ std::size_t Size() const {
+ return m_map.size();
+ }
- bool IsEmpty() const { return m_map.empty(); }
+ bool IsEmpty() const {
+ return m_map.empty();
+ }
std::pair<Iterator, bool> Insert(const Word &, const T &);
- T *Find(const Word &w) const { return m_vec[w[0]->GetId()]; }
+ T *Find(const Word &w) const {
+ return m_vec[w[0]->GetId()];
+ }
- private:
+private:
Map m_map;
Vec m_vec;
};
template<typename T>
std::pair<typename NonTerminalMap<T>::Iterator, bool> NonTerminalMap<T>::Insert(
- const Word &key, const T &value)
+ const Word &key, const T &value)
{
std::pair<typename Map::iterator, bool> result =
- m_map.insert(typename Map::value_type(key, value));
+ m_map.insert(typename Map::value_type(key, value));
if (result.second) {
T *p = &(result.first->second);
std::size_t i = key[0]->GetId();
diff --git a/moses/Syntax/PHyperedge.h b/moses/Syntax/PHyperedge.h
index 8f236fcb8..ff24e4fc7 100644
--- a/moses/Syntax/PHyperedge.h
+++ b/moses/Syntax/PHyperedge.h
@@ -11,8 +11,7 @@ namespace Syntax
struct PVertex;
-struct PHyperedge
-{
+struct PHyperedge {
PVertex *head;
std::vector<PVertex*> tail;
const TargetPhraseCollection *translations;
diff --git a/moses/Syntax/PVertex.h b/moses/Syntax/PVertex.h
index d82309c82..3a7a960c7 100644
--- a/moses/Syntax/PVertex.h
+++ b/moses/Syntax/PVertex.h
@@ -8,9 +8,8 @@ namespace Moses
namespace Syntax
{
-struct PVertex
-{
- public:
+struct PVertex {
+public:
PVertex(const WordsRange &wr, const Word &w) : span(wr), symbol(w) {}
WordsRange span;
diff --git a/moses/Syntax/RuleTable.h b/moses/Syntax/RuleTable.h
index 90a25d63c..8e20817dc 100644
--- a/moses/Syntax/RuleTable.h
+++ b/moses/Syntax/RuleTable.h
@@ -11,12 +11,12 @@ class RuleTableFF;
// grammar, like a trie (for S2T) or a DFA (for T2S).
class RuleTable
{
- public:
+public:
RuleTable(const RuleTableFF *ff) : m_ff(ff) {}
virtual ~RuleTable() {}
- protected:
+protected:
const RuleTableFF *m_ff;
};
diff --git a/moses/Syntax/RuleTableFF.h b/moses/Syntax/RuleTableFF.h
index 0e6040612..4d6132e86 100644
--- a/moses/Syntax/RuleTableFF.h
+++ b/moses/Syntax/RuleTableFF.h
@@ -21,7 +21,7 @@ class RuleTable;
// anything except provide somewhere to store the weights and parameter values.
class RuleTableFF : public PhraseDictionary
{
- public:
+public:
RuleTableFF(const std::string &);
// FIXME Delete m_table?
@@ -29,18 +29,21 @@ class RuleTableFF : public PhraseDictionary
void Load();
- const RuleTable *GetTable() const { return m_table; }
+ const RuleTable *GetTable() const {
+ return m_table;
+ }
- static const std::vector<RuleTableFF*> &Instances() { return s_instances; }
+ static const std::vector<RuleTableFF*> &Instances() {
+ return s_instances;
+ }
ChartRuleLookupManager *CreateRuleLookupManager(
- const ChartParser &, const ChartCellCollectionBase &, std::size_t)
- {
+ const ChartParser &, const ChartCellCollectionBase &, std::size_t) {
assert(false);
return 0;
}
- private:
+private:
static std::vector<RuleTableFF*> s_instances;
const RuleTable *m_table;
diff --git a/moses/Syntax/S2T/DerivationWriter.h b/moses/Syntax/S2T/DerivationWriter.h
index 706490ce0..af0e5f521 100644
--- a/moses/Syntax/S2T/DerivationWriter.h
+++ b/moses/Syntax/S2T/DerivationWriter.h
@@ -21,14 +21,14 @@ namespace S2T
// TODO should be revisited when other the decoders are implemented.
class DerivationWriter
{
- public:
+public:
// 1-best version.
static void Write(const SHyperedge&, std::size_t, std::ostream &);
// k-best version.
static void Write(const KBestExtractor::Derivation &, std::size_t,
std::ostream &);
- private:
+private:
static void WriteLine(const SHyperedge &, std::size_t, std::ostream &);
static void WriteSymbol(const Word &, std::ostream &);
};
diff --git a/moses/Syntax/S2T/Manager-inl.h b/moses/Syntax/S2T/Manager-inl.h
index 4d0136fe1..5bdb33f1e 100644
--- a/moses/Syntax/S2T/Manager-inl.h
+++ b/moses/Syntax/S2T/Manager-inl.h
@@ -31,9 +31,9 @@ namespace S2T
template<typename Parser>
Manager<Parser>::Manager(const InputType &source)
- : Syntax::Manager(source)
- , m_pchart(source.GetSize(), Parser::RequiresCompressedChart())
- , m_schart(source.GetSize())
+ : Syntax::Manager(source)
+ , m_pchart(source.GetSize(), Parser::RequiresCompressedChart())
+ , m_schart(source.GetSize())
{
}
@@ -100,7 +100,7 @@ void Manager<Parser>::InitializeParsers(PChart &pchart,
m_oovRuleTrie = oovHandler.SynthesizeRuleTrie(m_oovs.begin(), m_oovs.end());
// Create a parser for the OOV rule trie.
boost::shared_ptr<Parser> parser(
- new Parser(pchart, *m_oovRuleTrie, maxOovWidth));
+ new Parser(pchart, *m_oovRuleTrie, maxOovWidth));
m_parsers.push_back(parser);
}
}
@@ -197,14 +197,14 @@ void Manager<Parser>::Decode()
// Retrieve the (pruned) set of SHyperedgeBundles from the callback.
const BoundedPriorityContainer<SHyperedgeBundle> &bundles =
- callback.GetContainer();
+ callback.GetContainer();
// Use cube pruning to extract SHyperedges from SHyperedgeBundles.
// Collect the SHyperedges into buffers, one for each category.
CubeQueue cubeQueue(bundles.Begin(), bundles.End());
std::size_t count = 0;
typedef boost::unordered_map<Word, std::vector<SHyperedge*>,
- SymbolHasher, SymbolEqualityPred > BufferMap;
+ SymbolHasher, SymbolEqualityPred > BufferMap;
BufferMap buffers;
while (count < popLimit && !cubeQueue.IsEmpty()) {
SHyperedge *hyperedge = cubeQueue.Pop();
@@ -228,7 +228,7 @@ void Manager<Parser>::Decode()
const Word &category = p->first;
const std::vector<SHyperedge*> &buffer = p->second;
std::pair<SChart::Cell::NMap::Iterator, bool> ret =
- scell.nonTerminalStacks.Insert(category, SVertexStack());
+ scell.nonTerminalStacks.Insert(category, SVertexStack());
assert(ret.second);
SVertexStack &stack = ret.first->second;
RecombineAndSort(buffer, stack);
@@ -269,9 +269,9 @@ const SHyperedge *Manager<Parser>::GetBestSHyperedge() const
template<typename Parser>
void Manager<Parser>::ExtractKBest(
- std::size_t k,
- std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
- bool onlyDistinct) const
+ std::size_t k,
+ std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
+ bool onlyDistinct) const
{
kBestList.clear();
if (k == 0 || m_source.GetSize() == 0) {
@@ -326,18 +326,18 @@ template<typename Parser>
void Manager<Parser>::PrunePChart(const SChart::Cell &scell,
PChart::Cell &pcell)
{
-/* FIXME
- PChart::Cell::VertexMap::iterator p = pcell.vertices.begin();
- while (p != pcell.vertices.end()) {
- const Word &category = p->first;
- if (scell.stacks.find(category) == scell.stacks.end()) {
- PChart::Cell::VertexMap::iterator q = p++;
- pcell.vertices.erase(q);
- } else {
- ++p;
+ /* FIXME
+ PChart::Cell::VertexMap::iterator p = pcell.vertices.begin();
+ while (p != pcell.vertices.end()) {
+ const Word &category = p->first;
+ if (scell.stacks.find(category) == scell.stacks.end()) {
+ PChart::Cell::VertexMap::iterator q = p++;
+ pcell.vertices.erase(q);
+ } else {
+ ++p;
+ }
}
- }
-*/
+ */
}
template<typename Parser>
@@ -390,7 +390,7 @@ void Manager<Parser>::RecombineAndSort(const std::vector<SHyperedge*> &buffer,
template<typename Parser>
void Manager<Parser>::OutputDetailedTranslationReport(
- OutputCollector *collector) const
+ OutputCollector *collector) const
{
const SHyperedge *best = GetBestSHyperedge();
if (best == NULL || collector == NULL) {
diff --git a/moses/Syntax/S2T/Manager.h b/moses/Syntax/S2T/Manager.h
index 47cca43d6..0961c8e77 100644
--- a/moses/Syntax/S2T/Manager.h
+++ b/moses/Syntax/S2T/Manager.h
@@ -29,7 +29,7 @@ namespace S2T
template<typename Parser>
class Manager : public Syntax::Manager
{
- public:
+public:
Manager(const InputType &);
void Decode();
@@ -38,13 +38,13 @@ class Manager : public Syntax::Manager
const SHyperedge *GetBestSHyperedge() const;
void ExtractKBest(
- std::size_t k,
- std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
- bool onlyDistinct=false) const;
+ std::size_t k,
+ std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
+ bool onlyDistinct=false) const;
void OutputDetailedTranslationReport(OutputCollector *collector) const;
- private:
+private:
void FindOovs(const PChart &, std::set<Word> &, std::size_t);
void InitializeCharts();
diff --git a/moses/Syntax/S2T/OovHandler-inl.h b/moses/Syntax/S2T/OovHandler-inl.h
index e700f65c5..76eed861e 100644
--- a/moses/Syntax/S2T/OovHandler-inl.h
+++ b/moses/Syntax/S2T/OovHandler-inl.h
@@ -13,7 +13,7 @@ namespace S2T
template<typename RuleTrie>
template<typename InputIterator>
boost::shared_ptr<RuleTrie> OovHandler<RuleTrie>::SynthesizeRuleTrie(
- InputIterator first, InputIterator last)
+ InputIterator first, InputIterator last)
{
const UnknownLHSList &lhsList = StaticData::Instance().GetUnknownLHS();
@@ -33,7 +33,7 @@ boost::shared_ptr<RuleTrie> OovHandler<RuleTrie>::SynthesizeRuleTrie(
Word *tgtLHS = SynthesizeTargetLhs(targetLhsStr);
TargetPhrase *tp = SynthesizeTargetPhrase(oov, *srcPhrase, *tgtLHS, prob);
TargetPhraseCollection &tpc = GetOrCreateTargetPhraseCollection(
- *trie, *srcPhrase, *tp, NULL); // TODO Check NULL is valid argument
+ *trie, *srcPhrase, *tp, NULL); // TODO Check NULL is valid argument
tpc.Add(tp);
}
}
@@ -63,12 +63,12 @@ Word *OovHandler<RuleTrie>::SynthesizeTargetLhs(const std::string &lhsStr)
template<typename RuleTrie>
TargetPhrase *OovHandler<RuleTrie>::SynthesizeTargetPhrase(
- const Word &oov, const Phrase &srcPhrase, const Word &targetLhs, float prob)
+ const Word &oov, const Phrase &srcPhrase, const Word &targetLhs, float prob)
{
const StaticData &staticData = StaticData::Instance();
const UnknownWordPenaltyProducer &unknownWordPenaltyProducer =
- UnknownWordPenaltyProducer::Instance();
+ UnknownWordPenaltyProducer::Instance();
TargetPhrase *targetPhrase = new TargetPhrase();
Word &targetWord = targetPhrase->AddWord();
diff --git a/moses/Syntax/S2T/OovHandler.h b/moses/Syntax/S2T/OovHandler.h
index 4b0133413..5d484d2fd 100644
--- a/moses/Syntax/S2T/OovHandler.h
+++ b/moses/Syntax/S2T/OovHandler.h
@@ -21,7 +21,7 @@ namespace S2T
template<typename RuleTrie>
class OovHandler : public RuleTrieCreator
{
- public:
+public:
OovHandler(const RuleTableFF &ff) : m_ruleTableFF(ff) {}
// Synthesize a RuleTrie given a sequence of OOV words. The sequence is
@@ -30,7 +30,7 @@ class OovHandler : public RuleTrieCreator
template<typename InputIterator>
boost::shared_ptr<RuleTrie> SynthesizeRuleTrie(InputIterator, InputIterator);
- private:
+private:
const RuleTableFF &m_ruleTableFF;
bool ShouldDrop(const Word &);
diff --git a/moses/Syntax/S2T/PChart.h b/moses/Syntax/S2T/PChart.h
index 8f719eebb..0bd3148b3 100644
--- a/moses/Syntax/S2T/PChart.h
+++ b/moses/Syntax/S2T/PChart.h
@@ -19,11 +19,10 @@ namespace S2T
class PChart
{
- public:
- struct Cell
- {
+public:
+ struct Cell {
typedef boost::unordered_map<Word, PVertex, SymbolHasher,
- SymbolEqualityPred> TMap;
+ SymbolEqualityPred> TMap;
typedef NonTerminalMap<PVertex> NMap;
// Collection of terminal vertices (keyed by terminal symbol).
TMap terminalVertices;
@@ -42,7 +41,9 @@ class PChart
~PChart();
- std::size_t GetWidth() const { return m_cells.size(); }
+ std::size_t GetWidth() const {
+ return m_cells.size();
+ }
const Cell &GetCell(std::size_t start, std::size_t end) const {
return m_cells[start][end];
@@ -57,13 +58,13 @@ class PChart
if (!v.symbol.IsNonTerminal()) {
Cell::TMap::value_type x(v.symbol, v);
std::pair<Cell::TMap::iterator, bool> ret =
- cell.terminalVertices.insert(x);
+ cell.terminalVertices.insert(x);
return ret.first->second;
}
// If v is a non-terminal vertex add it to the cell's nonTerminalVertices
// map and update the compressed chart (if enabled).
std::pair<Cell::NMap::Iterator, bool> result =
- cell.nonTerminalVertices.Insert(v.symbol, v);
+ cell.nonTerminalVertices.Insert(v.symbol, v);
if (result.second && m_compressedChart) {
CompressedItem item;
item.end = end;
@@ -77,7 +78,7 @@ class PChart
return (*m_compressedChart)[start];
}
- private:
+private:
typedef std::vector<CompressedMatrix> CompressedChart;
std::vector<std::vector<Cell> > m_cells;
diff --git a/moses/Syntax/S2T/PHyperedgeToSHyperedgeBundle.h b/moses/Syntax/S2T/PHyperedgeToSHyperedgeBundle.h
index dd0be3ae9..924d9c976 100644
--- a/moses/Syntax/S2T/PHyperedgeToSHyperedgeBundle.h
+++ b/moses/Syntax/S2T/PHyperedgeToSHyperedgeBundle.h
@@ -15,8 +15,9 @@ namespace S2T
// Given a PHyperedge object and SChart produces a SHyperedgeBundle object.
inline void PHyperedgeToSHyperedgeBundle(const PHyperedge &hyperedge,
- const SChart &schart,
- SHyperedgeBundle &bundle) {
+ const SChart &schart,
+ SHyperedgeBundle &bundle)
+{
bundle.translations = hyperedge.translations;
bundle.stacks.clear();
for (std::vector<PVertex*>::const_iterator p = hyperedge.tail.begin();
@@ -31,7 +32,7 @@ inline void PHyperedgeToSHyperedgeBundle(const PHyperedge &hyperedge,
stack = cell.nonTerminalStacks.Find(symbol);
} else {
const SChart::Cell::TMap::const_iterator q =
- cell.terminalStacks.find(symbol);
+ cell.terminalStacks.find(symbol);
assert(q != cell.terminalStacks.end());
stack = &(q->second);
}
diff --git a/moses/Syntax/S2T/ParserCallback.h b/moses/Syntax/S2T/ParserCallback.h
index b18a85eae..f9db51601 100644
--- a/moses/Syntax/S2T/ParserCallback.h
+++ b/moses/Syntax/S2T/ParserCallback.h
@@ -15,14 +15,15 @@ namespace Syntax
namespace S2T
{
-class StandardParserCallback {
- private:
+class StandardParserCallback
+{
+private:
typedef BoundedPriorityContainer<SHyperedgeBundle> Container;
- public:
+public:
StandardParserCallback(const SChart &schart, std::size_t ruleLimit)
- : m_schart(schart)
- , m_container(ruleLimit) {}
+ : m_schart(schart)
+ , m_container(ruleLimit) {}
void operator()(const PHyperedge &hyperedge) {
PHyperedgeToSHyperedgeBundle(hyperedge, m_schart, m_tmpBundle);
@@ -30,25 +31,30 @@ class StandardParserCallback {
m_container.SwapIn(m_tmpBundle, score);
}
- void InitForRange(const WordsRange &range) { m_container.LazyClear(); }
+ void InitForRange(const WordsRange &range) {
+ m_container.LazyClear();
+ }
- const Container &GetContainer() { return m_container; }
+ const Container &GetContainer() {
+ return m_container;
+ }
- private:
+private:
const SChart &m_schart;
SHyperedgeBundle m_tmpBundle;
BoundedPriorityContainer<SHyperedgeBundle> m_container;
};
-class EagerParserCallback {
- private:
+class EagerParserCallback
+{
+private:
typedef BoundedPriorityContainer<SHyperedgeBundle> Container;
- public:
+public:
EagerParserCallback(const SChart &schart, std::size_t ruleLimit)
- : m_schart(schart)
- , m_containers(schart.GetWidth(), Container(ruleLimit))
- , m_prevStart(std::numeric_limits<std::size_t>::max()) {}
+ : m_schart(schart)
+ , m_containers(schart.GetWidth(), Container(ruleLimit))
+ , m_prevStart(std::numeric_limits<std::size_t>::max()) {}
void operator()(const PHyperedge &hyperedge, std::size_t end) {
PHyperedgeToSHyperedgeBundle(hyperedge, m_schart, m_tmpBundle);
@@ -68,9 +74,11 @@ class EagerParserCallback {
}
}
- const Container &GetContainer() { return m_containers[m_end]; }
+ const Container &GetContainer() {
+ return m_containers[m_end];
+ }
- private:
+private:
const SChart &m_schart;
SHyperedgeBundle m_tmpBundle;
std::vector<Container> m_containers;
diff --git a/moses/Syntax/S2T/Parsers/Parser.h b/moses/Syntax/S2T/Parsers/Parser.h
index b13a8d502..785fb66f9 100644
--- a/moses/Syntax/S2T/Parsers/Parser.h
+++ b/moses/Syntax/S2T/Parsers/Parser.h
@@ -13,7 +13,7 @@ class PChart;
template<typename Callback>
class Parser
{
- public:
+public:
typedef Callback CallbackType;
Parser(PChart &chart) : m_chart(chart) {}
@@ -21,7 +21,7 @@ class Parser
virtual ~Parser() {}
virtual void EnumerateHyperedges(const WordsRange &, Callback &) = 0;
- protected:
+protected:
PChart &m_chart;
};
diff --git a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h
index b275a93ee..ad3972404 100644
--- a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h
+++ b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h
@@ -11,21 +11,21 @@ namespace S2T
template<typename Callback>
RecursiveCYKPlusParser<Callback>::RecursiveCYKPlusParser(
- PChart &chart,
- const RuleTrie &trie,
- std::size_t maxChartSpan)
- : Parser<Callback>(chart)
- , m_ruleTable(trie)
- , m_maxChartSpan(maxChartSpan)
- , m_callback(NULL)
+ PChart &chart,
+ const RuleTrie &trie,
+ std::size_t maxChartSpan)
+ : Parser<Callback>(chart)
+ , m_ruleTable(trie)
+ , m_maxChartSpan(maxChartSpan)
+ , m_callback(NULL)
{
m_hyperedge.head = 0;
}
template<typename Callback>
void RecursiveCYKPlusParser<Callback>::EnumerateHyperedges(
- const WordsRange &range,
- Callback &callback)
+ const WordsRange &range,
+ Callback &callback)
{
const std::size_t start = range.GetStartPos();
const std::size_t end = range.GetEndPos();
@@ -49,16 +49,17 @@ void RecursiveCYKPlusParser<Callback>::EnumerateHyperedges(
// with a non-terminal over a span between [start,minEnd] and [start,maxEnd].
template<typename Callback>
void RecursiveCYKPlusParser<Callback>::GetNonTerminalExtensions(
- const RuleTrie::Node &node,
- std::size_t start,
- std::size_t minEnd,
- std::size_t maxEnd) {
+ const RuleTrie::Node &node,
+ std::size_t start,
+ std::size_t minEnd,
+ std::size_t maxEnd)
+{
// Non-terminal labels in node's outgoing edge set.
const RuleTrie::Node::SymbolMap &nonTermMap = node.GetNonTerminalMap();
// Compressed matrix from PChart.
const PChart::CompressedMatrix &matrix =
- Base::m_chart.GetCompressedMatrix(start);
+ Base::m_chart.GetCompressedMatrix(start);
// Loop over possible expansions of the rule.
RuleTrie::Node::SymbolMap::const_iterator p;
@@ -66,7 +67,7 @@ void RecursiveCYKPlusParser<Callback>::GetNonTerminalExtensions(
for (p = nonTermMap.begin(); p != p_end; ++p) {
const Word &nonTerm = p->first;
const std::vector<PChart::CompressedItem> &items =
- matrix[nonTerm[0]->GetId()];
+ matrix[nonTerm[0]->GetId()];
for (std::vector<PChart::CompressedItem>::const_iterator q = items.begin();
q != items.end(); ++q) {
if (q->end >= minEnd && q->end <= maxEnd) {
@@ -81,12 +82,13 @@ void RecursiveCYKPlusParser<Callback>::GetNonTerminalExtensions(
// with a terminal over span [start,end].
template<typename Callback>
void RecursiveCYKPlusParser<Callback>::GetTerminalExtension(
- const RuleTrie::Node &node,
- std::size_t start,
- std::size_t end) {
+ const RuleTrie::Node &node,
+ std::size_t start,
+ std::size_t end)
+{
const PChart::Cell::TMap &vertexMap =
- Base::m_chart.GetCell(start, end).terminalVertices;
+ Base::m_chart.GetCell(start, end).terminalVertices;
if (vertexMap.empty()) {
return;
}
@@ -122,9 +124,10 @@ void RecursiveCYKPlusParser<Callback>::GetTerminalExtension(
// non-empty), and try to find expansions that have this partial rule as prefix.
template<typename Callback>
void RecursiveCYKPlusParser<Callback>::AddAndExtend(
- const RuleTrie::Node &node,
- std::size_t end,
- const PVertex &vertex) {
+ const RuleTrie::Node &node,
+ std::size_t end,
+ const PVertex &vertex)
+{
// FIXME Sort out const-ness.
m_hyperedge.tail.push_back(const_cast<PVertex *>(&vertex));
@@ -153,7 +156,7 @@ void RecursiveCYKPlusParser<Callback>::AddAndExtend(
template<typename Callback>
bool RecursiveCYKPlusParser<Callback>::IsNonLexicalUnary(
- const PHyperedge &hyperedge) const
+ const PHyperedge &hyperedge) const
{
return hyperedge.tail.size() == 1 &&
hyperedge.tail[0]->symbol.IsNonTerminal();
diff --git a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h
index 264d43eea..2b8edbfd1 100644
--- a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h
+++ b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h
@@ -22,12 +22,14 @@ namespace S2T
template<typename Callback>
class RecursiveCYKPlusParser : public Parser<Callback>
{
- public:
+public:
typedef Parser<Callback> Base;
typedef RuleTrieCYKPlus RuleTrie;
// TODO Make this configurable?
- static bool RequiresCompressedChart() { return true; }
+ static bool RequiresCompressedChart() {
+ return true;
+ }
RecursiveCYKPlusParser(PChart &, const RuleTrie &, std::size_t);
@@ -35,7 +37,7 @@ class RecursiveCYKPlusParser : public Parser<Callback>
void EnumerateHyperedges(const WordsRange &, Callback &);
- private:
+private:
void GetTerminalExtension(const RuleTrie::Node &, std::size_t, std::size_t);
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h
index d55f7e842..f50cee3a0 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h
@@ -23,10 +23,10 @@ namespace S2T
template<typename Callback>
Scope3Parser<Callback>::Scope3Parser(PChart &chart, const RuleTrie &trie,
std::size_t maxChartSpan)
- : Parser<Callback>(chart)
- , m_ruleTable(trie)
- , m_maxChartSpan(maxChartSpan)
- , m_latticeBuilder(chart)
+ : Parser<Callback>(chart)
+ , m_ruleTable(trie)
+ , m_maxChartSpan(maxChartSpan)
+ , m_latticeBuilder(chart)
{
Init();
}
@@ -39,7 +39,7 @@ Scope3Parser<Callback>::~Scope3Parser()
template<typename Callback>
void Scope3Parser<Callback>::EnumerateHyperedges(const WordsRange &range,
- Callback &callback)
+ Callback &callback)
{
const std::size_t start = range.GetStartPos();
const std::size_t end = range.GetEndPos();
@@ -65,7 +65,7 @@ void Scope3Parser<Callback>::EnumerateHyperedges(const WordsRange &range,
// Ask the grammar for the mapping from label sequences to target phrase
// collections for this pattern.
const RuleTrie::Node::LabelMap &labelMap =
- patNode->m_node->GetLabelMap();
+ patNode->m_node->GetLabelMap();
// For each label sequence, search the lattice for the set of PHyperedge
// tails.
@@ -146,7 +146,7 @@ void Scope3Parser<Callback>::FillSentenceMap(SentenceMap &sentMap)
template<typename Callback>
void Scope3Parser<Callback>::RecordPatternApplicationSpans(
- const PatternApplicationTrie &patNode)
+ const PatternApplicationTrie &patNode)
{
if (patNode.m_node->HasRules()) {
int s1 = -1;
@@ -175,7 +175,7 @@ void Scope3Parser<Callback>::RecordPatternApplicationSpans(
}
for (std::vector<PatternApplicationTrie*>::const_iterator p =
- patNode.m_children.begin(); p != patNode.m_children.end(); ++p) {
+ patNode.m_children.begin(); p != patNode.m_children.end(); ++p) {
RecordPatternApplicationSpans(**p);
}
}
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h
index d3104d9b1..df2989d62 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h
@@ -33,7 +33,9 @@ public:
typedef RuleTrieScope3 RuleTrie;
// TODO Make this configurable?
- static bool RequiresCompressedChart() { return false; }
+ static bool RequiresCompressedChart() {
+ return false;
+ }
Scope3Parser(PChart &, const RuleTrie &, std::size_t);
@@ -60,7 +62,7 @@ private:
/* m_patSpans[i][j] records the set of all PAT nodes for span [i,i+j]
i.e. j is the width of the span */
std::vector<std::vector<
- std::vector<const PatternApplicationTrie *> > > m_patSpans;
+ std::vector<const PatternApplicationTrie *> > > m_patSpans;
};
} // namespace S2T
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.cpp b/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.cpp
index 218cd4017..f580c254a 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.cpp
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.cpp
@@ -9,7 +9,8 @@ namespace Syntax
namespace S2T
{
-int PatternApplicationTrie::Depth() const {
+int PatternApplicationTrie::Depth() const
+{
if (m_parent) {
return m_parent->Depth() + 1;
}
@@ -77,8 +78,8 @@ PatternApplicationTrie::GetLowestTerminalNode() const
// may be unknown). This function determines the range of possible start
// values for the partially-applied pattern.
void PatternApplicationTrie::DetermineStartRange(int sentenceLength,
- int &minStart,
- int &maxStart) const
+ int &minStart,
+ int &maxStart) const
{
// Find the leftmost terminal symbol, if any.
const PatternApplicationTrie *n = GetHighestTerminalNode();
@@ -108,8 +109,8 @@ void PatternApplicationTrie::DetermineStartRange(int sentenceLength,
// may be unknown). This function determines the range of possible end values
// for the partially-applied pattern.
void PatternApplicationTrie::DetermineEndRange(int sentenceLength,
- int &minEnd,
- int &maxEnd) const
+ int &minEnd,
+ int &maxEnd) const
{
// Find the rightmost terminal symbol, if any.
const PatternApplicationTrie *n = GetLowestTerminalNode();
@@ -154,7 +155,7 @@ void PatternApplicationTrie::Extend(const RuleTrieScope3::Node &node,
(followsGap && start > (std::size_t)minPos) ||
minPos == -1) {
PatternApplicationTrie *subTrie =
- new PatternApplicationTrie(start, end, child, v, this);
+ new PatternApplicationTrie(start, end, child, v, this);
subTrie->Extend(child, end+1, sentMap, false);
m_children.push_back(subTrie);
}
@@ -174,7 +175,8 @@ void PatternApplicationTrie::Extend(const RuleTrieScope3::Node &node,
}
void PatternApplicationTrie::ReadOffPatternApplicationKey(
- PatternApplicationKey &key) const {
+ PatternApplicationKey &key) const
+{
const int depth = Depth();
key.resize(depth);
const PatternApplicationTrie *p = this;
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.h b/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.h
index 0ad371367..1869c0bfd 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/PatternApplicationTrie.h
@@ -19,7 +19,7 @@ struct PatternApplicationTrie;
typedef std::vector<const PatternApplicationTrie*> PatternApplicationKey;
struct PatternApplicationTrie {
- public:
+public:
PatternApplicationTrie(int start, int end, const RuleTrieScope3::Node &node,
const PVertex *pvertex, PatternApplicationTrie *parent)
: m_start(start)
@@ -36,8 +36,12 @@ struct PatternApplicationTrie {
int Depth() const;
- bool IsGapNode() const { return m_end == -1; }
- bool IsTerminalNode() const { return m_end != -1; }
+ bool IsGapNode() const {
+ return m_end == -1;
+ }
+ bool IsTerminalNode() const {
+ return m_end != -1;
+ }
const PatternApplicationTrie *GetHighestTerminalNode() const;
const PatternApplicationTrie *GetLowestTerminalNode() const;
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/SentenceMap.h b/moses/Syntax/S2T/Parsers/Scope3Parser/SentenceMap.h
index 8e6aae9f1..522b56618 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/SentenceMap.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/SentenceMap.h
@@ -20,7 +20,7 @@ namespace S2T
// FIXME Check SymbolHasher does the right thing here
typedef boost::unordered_map<Word, std::vector<const PVertex *>, SymbolHasher,
- SymbolEqualityPred> SentenceMap;
+ SymbolEqualityPred> SentenceMap;
} // namespace S2T
} // namespace Syntax
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.cpp b/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.cpp
index 0eb615db8..8b1f203be 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.cpp
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.cpp
@@ -18,7 +18,7 @@ void SymbolRangeCalculator::Calc(const PatternApplicationKey &key,
// Fill in ranges for terminals and set ranges to -1 for non-terminals.
void SymbolRangeCalculator::FillInTerminalRanges(
- const PatternApplicationKey &key, std::vector<SymbolRange> &ranges)
+ const PatternApplicationKey &key, std::vector<SymbolRange> &ranges)
{
ranges.resize(key.size());
for (std::size_t i = 0; i < key.size(); ++i) {
@@ -34,7 +34,7 @@ void SymbolRangeCalculator::FillInTerminalRanges(
}
void SymbolRangeCalculator::FillInAuxSymbolInfo(
- const std::vector<SymbolRange> &ranges)
+ const std::vector<SymbolRange> &ranges)
{
m_auxSymbolInfo.resize(ranges.size());
@@ -81,8 +81,8 @@ void SymbolRangeCalculator::FillInAuxSymbolInfo(
}
void SymbolRangeCalculator::FillInGapRanges(const PatternApplicationKey &key,
- int spanStart, int spanEnd,
- std::vector<SymbolRange> &ranges)
+ int spanStart, int spanEnd,
+ std::vector<SymbolRange> &ranges)
{
for (std::size_t i = 0; i < key.size(); ++i) {
const PatternApplicationTrie *patNode = key[i];
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.h b/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.h
index 341fb9bb4..c9bbcb02d 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/SymbolRangeCalculator.h
@@ -14,11 +14,11 @@ namespace S2T
class SymbolRangeCalculator
{
- public:
+public:
void Calc(const PatternApplicationKey &, int, int,
std::vector<SymbolRange> &);
- private:
+private:
// Provides contextual information used in determining a symbol's range.
struct AuxSymbolInfo {
int distanceToNextTerminal;
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLattice.h b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLattice.h
index 9ee16b186..88685e81e 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLattice.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLattice.h
@@ -11,7 +11,7 @@ namespace S2T
{
/* Lattice in which a full path corresponds to the tail of a PHyperedge.
- * For an entry x[i][j][k][l] in a TailLattice x:
+ * For an entry x[i][j][k][l] in a TailLattice x:
*
* i = offset from start of rule pattern
*
@@ -23,9 +23,9 @@ namespace S2T
* l = label index (zero for terminals, otherwise as in RuleTrieScope3::Node)
*/
typedef std::vector<
- std::vector<
- std::vector<
- std::vector<const PVertex *> > > > TailLattice;
+std::vector<
+std::vector<
+std::vector<const PVertex *> > > > TailLattice;
} // namespace S2T
} // namespace Syntax
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.cpp b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.cpp
index 6b31090fc..3921ecfa0 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.cpp
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.cpp
@@ -25,7 +25,7 @@ void TailLatticeBuilder::Build(
const RuleTrieScope3::Node *utrieNode = key.back()->m_node;
const RuleTrieScope3::Node::LabelTable &labelTable =
- utrieNode->GetLabelTable();
+ utrieNode->GetLabelTable();
std::size_t nonTermIndex = 0;
@@ -52,7 +52,7 @@ void TailLatticeBuilder::Build(
p != labelVec.end(); ++p, ++q) {
const Word &label = *p;
const PVertex *v =
- m_chart.GetCell(s, e).nonTerminalVertices.Find(label);
+ m_chart.GetCell(s, e).nonTerminalVertices.Find(label);
lattice[offset][nonTermIndex+1][width].push_back(v);
*q = (*q || static_cast<bool>(v));
}
@@ -81,7 +81,7 @@ void TailLatticeBuilder::ExtendAndClear(
const RuleTrieScope3::Node *utrieNode = key.back()->m_node;
const RuleTrieScope3::Node::LabelTable &labelTable =
- utrieNode->GetLabelTable();
+ utrieNode->GetLabelTable();
std::size_t nonTermIndex = 0;
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.h b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.h
index c61df8a40..9297e5eba 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeBuilder.h
@@ -17,7 +17,7 @@ namespace S2T
class TailLatticeBuilder
{
- public:
+public:
TailLatticeBuilder(PChart &chart) : m_chart(chart) {}
// Given a key from a PatternApplicationTrie and the valid ranges of its
@@ -26,7 +26,7 @@ class TailLatticeBuilder
const std::vector<SymbolRange> &,
TailLattice &, std::vector<std::vector<bool> > &);
- private:
+private:
// Auxiliary function used by Build. Enlarges a TailLattice, if necessary,
// and clears the innermost vectors.
void ExtendAndClear(const std::vector<const PatternApplicationTrie *> &,
diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeSearcher.h b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeSearcher.h
index a2897ce73..79bd91148 100644
--- a/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeSearcher.h
+++ b/moses/Syntax/S2T/Parsers/Scope3Parser/TailLatticeSearcher.h
@@ -17,7 +17,7 @@ namespace S2T
template<typename Callback>
class TailLatticeSearcher
{
- public:
+public:
TailLatticeSearcher(const TailLattice &lattice,
const PatternApplicationKey &key,
const std::vector<SymbolRange> &ranges)
@@ -35,7 +35,7 @@ class TailLatticeSearcher
SearchInner(0, 0, 0);
}
- private:
+private:
void SearchInner(int offset, std::size_t i, std::size_t nonTermIndex) {
assert(m_hyperedge.tail.size() == i);
@@ -61,7 +61,7 @@ class TailLatticeSearcher
const int maxWidth = range.maxEnd - absStart + 1;
const std::vector<std::vector<const PVertex *> > &innerVec =
- m_lattice[offset][nonTermIndex+1];
+ m_lattice[offset][nonTermIndex+1];
std::size_t labelIndex = (*m_labels)[nonTermIndex];
diff --git a/moses/Syntax/S2T/RuleTrie.h b/moses/Syntax/S2T/RuleTrie.h
index 8f6dcbb80..27b0bc838 100644
--- a/moses/Syntax/S2T/RuleTrie.h
+++ b/moses/Syntax/S2T/RuleTrie.h
@@ -20,12 +20,12 @@ namespace S2T
// Base class for parser-specific trie types.
class RuleTrie : public RuleTable
{
- public:
+public:
RuleTrie(const RuleTableFF *ff) : RuleTable(ff) {}
virtual bool HasPreterminalRule(const Word &) const = 0;
- private:
+private:
friend class RuleTrieCreator;
virtual TargetPhraseCollection &GetOrCreateTargetPhraseCollection(
diff --git a/moses/Syntax/S2T/RuleTrieCYKPlus.cpp b/moses/Syntax/S2T/RuleTrieCYKPlus.cpp
index cda2bf6e7..05f8758e9 100644
--- a/moses/Syntax/S2T/RuleTrieCYKPlus.cpp
+++ b/moses/Syntax/S2T/RuleTrieCYKPlus.cpp
@@ -53,7 +53,7 @@ void RuleTrieCYKPlus::Node::Sort(std::size_t tableLimit)
}
RuleTrieCYKPlus::Node *RuleTrieCYKPlus::Node::GetOrCreateChild(
- const Word &sourceTerm)
+ const Word &sourceTerm)
{
return &m_sourceTermMap[sourceTerm];
}
@@ -61,40 +61,40 @@ RuleTrieCYKPlus::Node *RuleTrieCYKPlus::Node::GetOrCreateChild(
RuleTrieCYKPlus::Node *RuleTrieCYKPlus::Node::GetOrCreateNonTerminalChild(const Word &targetNonTerm)
{
UTIL_THROW_IF2(!targetNonTerm.IsNonTerminal(),
- "Not a non-terminal: " << targetNonTerm);
+ "Not a non-terminal: " << targetNonTerm);
return &m_nonTermMap[targetNonTerm];
}
const RuleTrieCYKPlus::Node *RuleTrieCYKPlus::Node::GetChild(
- const Word &sourceTerm) const
+ const Word &sourceTerm) const
{
UTIL_THROW_IF2(sourceTerm.IsNonTerminal(),
- "Not a terminal: " << sourceTerm);
+ "Not a terminal: " << sourceTerm);
SymbolMap::const_iterator p = m_sourceTermMap.find(sourceTerm);
return (p == m_sourceTermMap.end()) ? NULL : &p->second;
}
const RuleTrieCYKPlus::Node *RuleTrieCYKPlus::Node::GetNonTerminalChild(
- const Word &targetNonTerm) const
+ const Word &targetNonTerm) const
{
UTIL_THROW_IF2(!targetNonTerm.IsNonTerminal(),
- "Not a non-terminal: " << targetNonTerm);
+ "Not a non-terminal: " << targetNonTerm);
SymbolMap::const_iterator p = m_nonTermMap.find(targetNonTerm);
return (p == m_nonTermMap.end()) ? NULL : &p->second;
}
TargetPhraseCollection &RuleTrieCYKPlus::GetOrCreateTargetPhraseCollection(
- const Phrase &source, const TargetPhrase &target, const Word *sourceLHS)
+ const Phrase &source, const TargetPhrase &target, const Word *sourceLHS)
{
Node &currNode = GetOrCreateNode(source, target, sourceLHS);
return currNode.GetTargetPhraseCollection();
}
RuleTrieCYKPlus::Node &RuleTrieCYKPlus::GetOrCreateNode(
- const Phrase &source, const TargetPhrase &target, const Word *sourceLHS)
+ const Phrase &source, const TargetPhrase &target, const Word *sourceLHS)
{
const std::size_t size = source.GetSize();
@@ -107,9 +107,9 @@ RuleTrieCYKPlus::Node &RuleTrieCYKPlus::GetOrCreateNode(
if (word.IsNonTerminal()) {
UTIL_THROW_IF2(iterAlign == alignmentInfo.end(),
- "No alignment for non-term at position " << pos);
+ "No alignment for non-term at position " << pos);
UTIL_THROW_IF2(iterAlign->first != pos,
- "Alignment info incorrect at position " << pos);
+ "Alignment info incorrect at position " << pos);
std::size_t targetNonTermInd = iterAlign->second;
++iterAlign;
const Word &targetNonTerm = target.GetWord(targetNonTermInd);
diff --git a/moses/Syntax/S2T/RuleTrieCYKPlus.h b/moses/Syntax/S2T/RuleTrieCYKPlus.h
index 83ea55b87..11cf4c199 100644
--- a/moses/Syntax/S2T/RuleTrieCYKPlus.h
+++ b/moses/Syntax/S2T/RuleTrieCYKPlus.h
@@ -26,18 +26,20 @@ namespace S2T
class RuleTrieCYKPlus : public RuleTrie
{
- public:
+public:
class Node
{
- public:
+ public:
typedef boost::unordered_map<Word, Node, SymbolHasher,
- SymbolEqualityPred> SymbolMap;
+ SymbolEqualityPred> SymbolMap;
bool IsLeaf() const {
return m_sourceTermMap.empty() && m_nonTermMap.empty();
}
- bool HasRules() const { return !m_targetPhraseCollection.IsEmpty(); }
+ bool HasRules() const {
+ return !m_targetPhraseCollection.IsEmpty();
+ }
void Prune(std::size_t tableLimit);
void Sort(std::size_t tableLimit);
@@ -56,11 +58,15 @@ class RuleTrieCYKPlus : public RuleTrie
return m_targetPhraseCollection;
}
- const SymbolMap &GetTerminalMap() const { return m_sourceTermMap; }
+ const SymbolMap &GetTerminalMap() const {
+ return m_sourceTermMap;
+ }
- const SymbolMap &GetNonTerminalMap() const { return m_nonTermMap; }
+ const SymbolMap &GetNonTerminalMap() const {
+ return m_nonTermMap;
+ }
- private:
+ private:
SymbolMap m_sourceTermMap;
SymbolMap m_nonTermMap;
TargetPhraseCollection m_targetPhraseCollection;
@@ -68,11 +74,13 @@ class RuleTrieCYKPlus : public RuleTrie
RuleTrieCYKPlus(const RuleTableFF *ff) : RuleTrie(ff) {}
- const Node &GetRootNode() const { return m_root; }
+ const Node &GetRootNode() const {
+ return m_root;
+ }
bool HasPreterminalRule(const Word &) const;
- private:
+private:
TargetPhraseCollection &GetOrCreateTargetPhraseCollection(
const Phrase &source, const TargetPhrase &target, const Word *sourceLHS);
diff --git a/moses/Syntax/S2T/RuleTrieCreator.h b/moses/Syntax/S2T/RuleTrieCreator.h
index 1fe99e609..e49a2cbde 100644
--- a/moses/Syntax/S2T/RuleTrieCreator.h
+++ b/moses/Syntax/S2T/RuleTrieCreator.h
@@ -13,7 +13,7 @@ namespace S2T
// OovHandler). RuleTrieCreator is a friend of RuleTrie.
class RuleTrieCreator
{
- protected:
+protected:
// Provide access to RuleTrie's private SortAndPrune function.
void SortAndPrune(RuleTrie &trie, std::size_t limit) {
trie.SortAndPrune(limit);
@@ -22,8 +22,8 @@ class RuleTrieCreator
// Provide access to RuleTrie's private GetOrCreateTargetPhraseCollection
// function.
TargetPhraseCollection &GetOrCreateTargetPhraseCollection(
- RuleTrie &trie, const Phrase &source, const TargetPhrase &target,
- const Word *sourceLHS) {
+ RuleTrie &trie, const Phrase &source, const TargetPhrase &target,
+ const Word *sourceLHS) {
return trie.GetOrCreateTargetPhraseCollection(source, target, sourceLHS);
}
};
diff --git a/moses/Syntax/S2T/RuleTrieLoader.cpp b/moses/Syntax/S2T/RuleTrieLoader.cpp
index 3abe667ef..b9f7484ad 100644
--- a/moses/Syntax/S2T/RuleTrieLoader.cpp
+++ b/moses/Syntax/S2T/RuleTrieLoader.cpp
@@ -90,7 +90,7 @@ bool RuleTrieLoader::Load(const std::vector<FactorType> &input,
const size_t numScoreComponents = ff.GetNumScoreComponents();
if (scoreVector.size() != numScoreComponents) {
UTIL_THROW2("Size of scoreVector != number (" << scoreVector.size() << "!="
- << numScoreComponents << ") of score components on line " << count);
+ << numScoreComponents << ") of score components on line " << count);
}
// parse source & find pt node
@@ -126,7 +126,7 @@ bool RuleTrieLoader::Load(const std::vector<FactorType> &input,
targetPhrase->EvaluateInIsolation(sourcePhrase, ff.GetFeaturesToApply());
TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(
- trie, sourcePhrase, *targetPhrase, sourceLHS);
+ trie, sourcePhrase, *targetPhrase, sourceLHS);
phraseColl.Add(targetPhrase);
// not implemented correctly in memory pt. just delete it for now
diff --git a/moses/Syntax/S2T/RuleTrieLoader.h b/moses/Syntax/S2T/RuleTrieLoader.h
index c625f91d6..855f1d2a8 100644
--- a/moses/Syntax/S2T/RuleTrieLoader.h
+++ b/moses/Syntax/S2T/RuleTrieLoader.h
@@ -18,7 +18,7 @@ namespace S2T
class RuleTrieLoader : public RuleTrieCreator
{
- public:
+public:
bool Load(const std::vector<FactorType> &input,
const std::vector<FactorType> &output,
const std::string &inFile,
diff --git a/moses/Syntax/S2T/RuleTrieScope3.cpp b/moses/Syntax/S2T/RuleTrieScope3.cpp
index a16cbefdc..7318f09d6 100644
--- a/moses/Syntax/S2T/RuleTrieScope3.cpp
+++ b/moses/Syntax/S2T/RuleTrieScope3.cpp
@@ -55,7 +55,7 @@ void RuleTrieScope3::Node::Sort(std::size_t tableLimit)
}
RuleTrieScope3::Node *RuleTrieScope3::Node::GetOrCreateTerminalChild(
- const Word &sourceTerm)
+ const Word &sourceTerm)
{
assert(!sourceTerm.IsNonTerminal());
std::pair<TerminalMap::iterator, bool> result;
@@ -66,7 +66,7 @@ RuleTrieScope3::Node *RuleTrieScope3::Node::GetOrCreateTerminalChild(
}
RuleTrieScope3::Node *RuleTrieScope3::Node::GetOrCreateNonTerminalChild(
- const Word &targetNonTerm)
+ const Word &targetNonTerm)
{
assert(targetNonTerm.IsNonTerminal());
if (m_gapNode == NULL) {
@@ -77,7 +77,7 @@ RuleTrieScope3::Node *RuleTrieScope3::Node::GetOrCreateNonTerminalChild(
TargetPhraseCollection &
RuleTrieScope3::Node::GetOrCreateTargetPhraseCollection(
- const TargetPhrase &target)
+ const TargetPhrase &target)
{
const AlignmentInfo &alignmentInfo = target.GetAlignNonTerm();
const std::size_t rank = alignmentInfo.GetSize();
@@ -99,14 +99,14 @@ RuleTrieScope3::Node::GetOrCreateTargetPhraseCollection(
}
TargetPhraseCollection &RuleTrieScope3::GetOrCreateTargetPhraseCollection(
- const Phrase &source, const TargetPhrase &target, const Word *sourceLHS)
+ const Phrase &source, const TargetPhrase &target, const Word *sourceLHS)
{
Node &currNode = GetOrCreateNode(source, target, sourceLHS);
return currNode.GetOrCreateTargetPhraseCollection(target);
}
RuleTrieScope3::Node &RuleTrieScope3::GetOrCreateNode(
- const Phrase &source, const TargetPhrase &target, const Word */*sourceLHS*/)
+ const Phrase &source, const TargetPhrase &target, const Word */*sourceLHS*/)
{
const std::size_t size = source.GetSize();
diff --git a/moses/Syntax/S2T/RuleTrieScope3.h b/moses/Syntax/S2T/RuleTrieScope3.h
index 6dd38a4f1..5909b6509 100644
--- a/moses/Syntax/S2T/RuleTrieScope3.h
+++ b/moses/Syntax/S2T/RuleTrieScope3.h
@@ -25,27 +25,37 @@ namespace S2T
class RuleTrieScope3 : public RuleTrie
{
- public:
+public:
class Node
{
- public:
+ public:
typedef std::vector<std::vector<Word> > LabelTable;
typedef boost::unordered_map<Word, Node, SymbolHasher,
- SymbolEqualityPred> TerminalMap;
+ SymbolEqualityPred> TerminalMap;
typedef boost::unordered_map<std::vector<int>,
TargetPhraseCollection> LabelMap;
- ~Node() { delete m_gapNode; }
+ ~Node() {
+ delete m_gapNode;
+ }
- const LabelTable &GetLabelTable() const { return m_labelTable; }
+ const LabelTable &GetLabelTable() const {
+ return m_labelTable;
+ }
- const LabelMap &GetLabelMap() const { return m_labelMap; }
+ const LabelMap &GetLabelMap() const {
+ return m_labelMap;
+ }
- const TerminalMap &GetTerminalMap() const { return m_terminalMap; }
+ const TerminalMap &GetTerminalMap() const {
+ return m_terminalMap;
+ }
- const Node *GetNonTerminalChild() const { return m_gapNode; }
+ const Node *GetNonTerminalChild() const {
+ return m_gapNode;
+ }
Node *GetOrCreateTerminalChild(const Word &sourceTerm);
@@ -54,14 +64,18 @@ class RuleTrieScope3 : public RuleTrie
TargetPhraseCollection &GetOrCreateTargetPhraseCollection(
const TargetPhrase &);
- bool IsLeaf() const { return m_terminalMap.empty() && m_gapNode == NULL; }
+ bool IsLeaf() const {
+ return m_terminalMap.empty() && m_gapNode == NULL;
+ }
- bool HasRules() const { return !m_labelMap.empty(); }
+ bool HasRules() const {
+ return !m_labelMap.empty();
+ }
void Prune(std::size_t tableLimit);
void Sort(std::size_t tableLimit);
- private:
+ private:
friend class RuleTrieScope3;
Node() : m_gapNode(NULL) {}
@@ -85,11 +99,13 @@ class RuleTrieScope3 : public RuleTrie
RuleTrieScope3(const RuleTableFF *ff) : RuleTrie(ff) {}
- const Node &GetRootNode() const { return m_root; }
+ const Node &GetRootNode() const {
+ return m_root;
+ }
bool HasPreterminalRule(const Word &) const;
- private:
+private:
TargetPhraseCollection &GetOrCreateTargetPhraseCollection(
const Phrase &source, const TargetPhrase &target, const Word *sourceLHS);
diff --git a/moses/Syntax/S2T/SChart.h b/moses/Syntax/S2T/SChart.h
index 62b7d0c2b..ac6404831 100644
--- a/moses/Syntax/S2T/SChart.h
+++ b/moses/Syntax/S2T/SChart.h
@@ -19,11 +19,10 @@ namespace S2T
class SChart
{
- public:
- struct Cell
- {
+public:
+ struct Cell {
typedef boost::unordered_map<Word, SVertexStack, SymbolHasher,
- SymbolEqualityPred> TMap;
+ SymbolEqualityPred> TMap;
typedef NonTerminalMap<SVertexStack> NMap;
TMap terminalStacks;
NMap nonTerminalStacks;
@@ -31,7 +30,9 @@ class SChart
SChart(std::size_t width);
- std::size_t GetWidth() const { return m_cells.size(); }
+ std::size_t GetWidth() const {
+ return m_cells.size();
+ }
const Cell &GetCell(std::size_t start, std::size_t end) const {
return m_cells[start][end];
@@ -41,7 +42,7 @@ class SChart
return m_cells[start][end];
}
- private:
+private:
std::vector<std::vector<Cell> > m_cells;
};
diff --git a/moses/Syntax/SHyperedge.cpp b/moses/Syntax/SHyperedge.cpp
index 0f098c7a4..d91d5e896 100644
--- a/moses/Syntax/SHyperedge.cpp
+++ b/moses/Syntax/SHyperedge.cpp
@@ -32,24 +32,24 @@ Phrase GetOneBestTargetYield(const SHyperedge &h)
}
assert(false);
// FIXME Modify this chunk of code to work for SHyperedge.
-/*
- std::set<std::size_t> sourcePosSet =
- h.translation->GetAlignTerm().GetAlignmentsForTarget(pos);
- if (sourcePosSet.size() == 1) {
- const std::vector<const Word*> *ruleSourceFromInputPath =
- hypo.GetTranslationOption().GetSourceRuleFromInputPath();
- UTIL_THROW_IF2(ruleSourceFromInputPath == NULL,
- "Source Words in of the rules hasn't been filled out");
- std::size_t sourcePos = *sourcePosSet.begin();
- const Word *sourceWord = ruleSourceFromInputPath->at(sourcePos);
- UTIL_THROW_IF2(sourceWord == NULL,
- "Null source word at position " << sourcePos);
- const Factor *factor = sourceWord->GetFactor(placeholderFactor);
- if (factor) {
- ret.Back()[0] = factor;
- }
- }
-*/
+ /*
+ std::set<std::size_t> sourcePosSet =
+ h.translation->GetAlignTerm().GetAlignmentsForTarget(pos);
+ if (sourcePosSet.size() == 1) {
+ const std::vector<const Word*> *ruleSourceFromInputPath =
+ hypo.GetTranslationOption().GetSourceRuleFromInputPath();
+ UTIL_THROW_IF2(ruleSourceFromInputPath == NULL,
+ "Source Words in of the rules hasn't been filled out");
+ std::size_t sourcePos = *sourcePosSet.begin();
+ const Word *sourceWord = ruleSourceFromInputPath->at(sourcePos);
+ UTIL_THROW_IF2(sourceWord == NULL,
+ "Null source word at position " << sourcePos);
+ const Factor *factor = sourceWord->GetFactor(placeholderFactor);
+ if (factor) {
+ ret.Back()[0] = factor;
+ }
+ }
+ */
}
}
return ret;
diff --git a/moses/Syntax/SHyperedge.h b/moses/Syntax/SHyperedge.h
index 6d9128d49..696dbfa20 100644
--- a/moses/Syntax/SHyperedge.h
+++ b/moses/Syntax/SHyperedge.h
@@ -13,8 +13,7 @@ namespace Syntax
struct SVertex;
-struct SHyperedge
-{
+struct SHyperedge {
SVertex *head;
std::vector<SVertex*> tail;
float score;
diff --git a/moses/Syntax/SHyperedgeBundle.h b/moses/Syntax/SHyperedgeBundle.h
index 4a78c5458..f4a07a181 100644
--- a/moses/Syntax/SHyperedgeBundle.h
+++ b/moses/Syntax/SHyperedgeBundle.h
@@ -14,8 +14,7 @@ namespace Syntax
struct PVertex;
-struct SHyperedgeBundle
-{
+struct SHyperedgeBundle {
std::vector<const SVertexStack*> stacks;
const TargetPhraseCollection *translations;
diff --git a/moses/Syntax/SHyperedgeBundleScorer.h b/moses/Syntax/SHyperedgeBundleScorer.h
index 3bf547cfd..cc81812cf 100644
--- a/moses/Syntax/SHyperedgeBundleScorer.h
+++ b/moses/Syntax/SHyperedgeBundleScorer.h
@@ -7,14 +7,13 @@ namespace Moses
namespace Syntax
{
-struct SHyperedgeBundleScorer
-{
- public:
+struct SHyperedgeBundleScorer {
+public:
static float Score(const SHyperedgeBundle &bundle) {
const TargetPhrase &targetPhrase = **(bundle.translations->begin());
float score = targetPhrase.GetFutureScore();
for (std::vector<const SVertexStack*>::const_iterator p =
- bundle.stacks.begin(); p != bundle.stacks.end(); ++p) {
+ bundle.stacks.begin(); p != bundle.stacks.end(); ++p) {
const SVertexStack *stack = *p;
if (stack->front()->best) {
score += stack->front()->best->score;
diff --git a/moses/Syntax/SVertex.h b/moses/Syntax/SVertex.h
index cde14c21a..e596cb442 100644
--- a/moses/Syntax/SVertex.h
+++ b/moses/Syntax/SVertex.h
@@ -17,8 +17,7 @@ struct SHyperedge;
//
// Important: a SVertex owns its incoming SHyperedge objects and its FFState
// objects and will delete them on destruction.
-struct SVertex
-{
+struct SVertex {
~SVertex();
SHyperedge *best;
diff --git a/moses/Syntax/SVertexRecombinationOrderer.h b/moses/Syntax/SVertexRecombinationOrderer.h
index 60686d989..fcabed04a 100644
--- a/moses/Syntax/SVertexRecombinationOrderer.h
+++ b/moses/Syntax/SVertexRecombinationOrderer.h
@@ -9,11 +9,9 @@ namespace Moses
namespace Syntax
{
-struct SVertexRecombinationOrderer
-{
- public:
- bool operator()(const SVertex &x, const SVertex &y) const
- {
+struct SVertexRecombinationOrderer {
+public:
+ bool operator()(const SVertex &x, const SVertex &y) const {
int comp = 0;
for (std::size_t i = 0; i < x.state.size(); ++i) {
if (x.state[i] == NULL || y.state[i] == NULL) {
@@ -28,8 +26,7 @@ struct SVertexRecombinationOrderer
return false;
}
- bool operator()(const SVertex *x, const SVertex *y) const
- {
+ bool operator()(const SVertex *x, const SVertex *y) const {
return operator()(*x, *y);
}
};
diff --git a/moses/Syntax/SVertexStack.h b/moses/Syntax/SVertexStack.h
index 57dc9f247..0feae5cf1 100644
--- a/moses/Syntax/SVertexStack.h
+++ b/moses/Syntax/SVertexStack.h
@@ -14,12 +14,10 @@ namespace Syntax
typedef std::vector<boost::shared_ptr<SVertex> > SVertexStack;
-struct SVertexStackContentOrderer
-{
- public:
+struct SVertexStackContentOrderer {
+public:
bool operator()(const boost::shared_ptr<SVertex> &x,
- const boost::shared_ptr<SVertex> &y)
- {
+ const boost::shared_ptr<SVertex> &y) {
return x->best->score > y->best->score;
}
};
diff --git a/moses/Syntax/SymbolEqualityPred.h b/moses/Syntax/SymbolEqualityPred.h
index e97c4f11b..684d70cee 100644
--- a/moses/Syntax/SymbolEqualityPred.h
+++ b/moses/Syntax/SymbolEqualityPred.h
@@ -12,7 +12,7 @@ namespace Syntax
// *not* work in moses_chart unless this is changed (among other things).
class SymbolEqualityPred
{
- public:
+public:
bool operator()(const Word &s1, const Word &s2) const {
const Factor *f1 = s1[0];
const Factor *f2 = s2[0];
diff --git a/moses/Syntax/SymbolHasher.h b/moses/Syntax/SymbolHasher.h
index b398fdd00..c758d7017 100644
--- a/moses/Syntax/SymbolHasher.h
+++ b/moses/Syntax/SymbolHasher.h
@@ -14,7 +14,7 @@ namespace Syntax
// *not* work in moses_chart unless this is changed (among other things).
class SymbolHasher
{
- public:
+public:
std::size_t operator()(const Word &s) const {
const Factor *f = s[0];
return hash_value(*f);