mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-06 19:49:41 +03:00
1 seen position set
This commit is contained in:
parent
d5af3d1bc5
commit
17837f7b22
@ -19,7 +19,7 @@
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.1097293041." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.329828208" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.MachO64" id="cdt.managedbuild.targetPlatform.gnu.cross.389137927" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/moses2}/Debug" id="cdt.managedbuild.builder.gnu.cross.2144359329" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/moses2}/Debug" id="cdt.managedbuild.builder.gnu.cross.2144359329" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1430831084" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.354944414" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.639588389" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
|
@ -60,22 +60,24 @@ std::ostream& operator<<(std::ostream &out, const CubeEdge &obj)
|
||||
}
|
||||
|
||||
bool
|
||||
CubeEdge::SeenPosition(const size_t x, const size_t y) const
|
||||
CubeEdge::SeenPosition(const size_t x, const size_t y, SeenPositions &seenPositions) const
|
||||
{
|
||||
boost::unordered_set< int >::iterator iter = m_seenPosition.find((x<<16) + y);
|
||||
return (iter != m_seenPosition.end());
|
||||
std::pair<const CubeEdge*, int> val(this, (x<<16) + y);
|
||||
boost::unordered_set< std::pair<const CubeEdge*, int> >::iterator iter = seenPositions.find(val);
|
||||
return (iter != seenPositions.end());
|
||||
}
|
||||
|
||||
void
|
||||
CubeEdge::SetSeenPosition(const size_t x, const size_t y)
|
||||
CubeEdge::SetSeenPosition(const size_t x, const size_t y, SeenPositions &seenPositions) const
|
||||
{
|
||||
//UTIL_THROW_IF2(x >= (1<<17), "Error");
|
||||
//UTIL_THROW_IF2(y >= (1<<17), "Error");
|
||||
|
||||
m_seenPosition.insert((x<<16) + y);
|
||||
std::pair<const CubeEdge*, int> val(this, (x<<16) + y);
|
||||
seenPositions.insert(val);
|
||||
}
|
||||
|
||||
void CubeEdge::CreateFirst(Manager &mgr, Queue &queue)
|
||||
void CubeEdge::CreateFirst(Manager &mgr, Queue &queue, SeenPositions &seenPositions)
|
||||
{
|
||||
assert(hypos.size());
|
||||
assert(tps.GetSize());
|
||||
@ -84,27 +86,27 @@ void CubeEdge::CreateFirst(Manager &mgr, Queue &queue)
|
||||
|
||||
QueueItem *newEle = new (pool.Allocate<QueueItem>()) QueueItem(mgr, *this, 0, 0);
|
||||
queue.push(newEle);
|
||||
SetSeenPosition(0, 0);
|
||||
SetSeenPosition(0, 0, seenPositions);
|
||||
}
|
||||
|
||||
void CubeEdge::CreateNext(Manager &mgr, const QueueItem *ele, Queue &queue)
|
||||
void CubeEdge::CreateNext(Manager &mgr, const QueueItem *ele, Queue &queue, SeenPositions &seenPositions)
|
||||
{
|
||||
MemPool &pool = mgr.GetPool();
|
||||
|
||||
size_t hypoIndex = ele->hypoIndex + 1;
|
||||
if (hypoIndex < hypos.size() && !SeenPosition(hypoIndex, ele->tpIndex)) {
|
||||
if (hypoIndex < hypos.size() && !SeenPosition(hypoIndex, ele->tpIndex, seenPositions)) {
|
||||
QueueItem *newEle = new (pool.Allocate<QueueItem>()) QueueItem(mgr, *this, hypoIndex, ele->tpIndex);
|
||||
queue.push(newEle);
|
||||
|
||||
SetSeenPosition(hypoIndex, ele->tpIndex);
|
||||
SetSeenPosition(hypoIndex, ele->tpIndex, seenPositions);
|
||||
}
|
||||
|
||||
size_t tpIndex = ele->tpIndex + 1;
|
||||
if (tpIndex < tps.GetSize() && !SeenPosition(ele->hypoIndex, tpIndex)) {
|
||||
if (tpIndex < tps.GetSize() && !SeenPosition(ele->hypoIndex, tpIndex, seenPositions)) {
|
||||
QueueItem *newEle = new (pool.Allocate<QueueItem>()) QueueItem(mgr, *this, ele->hypoIndex, tpIndex);
|
||||
queue.push(newEle);
|
||||
|
||||
SetSeenPosition(ele->hypoIndex, tpIndex);
|
||||
SetSeenPosition(ele->hypoIndex, tpIndex, seenPositions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
typedef std::priority_queue<QueueItem*,
|
||||
std::vector<QueueItem*>,
|
||||
QueueItemOrderer> Queue;
|
||||
typedef boost::unordered_set< std::pair<const CubeEdge*, int> > SeenPositions;
|
||||
|
||||
const Hypotheses &hypos;
|
||||
const InputPath &path;
|
||||
@ -70,15 +71,14 @@ public:
|
||||
const Bitmap &newBitmap);
|
||||
void Finalize();
|
||||
|
||||
bool SeenPosition(const size_t x, const size_t y) const;
|
||||
void SetSeenPosition(const size_t x, const size_t y);
|
||||
bool SeenPosition(const size_t x, const size_t y, SeenPositions &seenPositions) const;
|
||||
void SetSeenPosition(const size_t x, const size_t y, SeenPositions &seenPositions) const;
|
||||
|
||||
void CreateFirst(Manager &mgr, Queue &queue);
|
||||
void CreateNext(Manager &mgr, const QueueItem *ele, Queue &queue);
|
||||
void CreateFirst(Manager &mgr, Queue &queue, SeenPositions &seenPositions);
|
||||
void CreateNext(Manager &mgr, const QueueItem *ele, Queue &queue, SeenPositions &seenPositions);
|
||||
|
||||
|
||||
protected:
|
||||
boost::unordered_set< int > m_seenPosition;
|
||||
|
||||
};
|
||||
|
||||
|
@ -74,12 +74,14 @@ void Search::Decode(size_t stackInd)
|
||||
std::vector<QueueItem*> &queueContainer = Container(m_queue);
|
||||
queueContainer.clear();
|
||||
|
||||
m_seenPositions.clear();
|
||||
|
||||
// add top hypo from every edge into queue
|
||||
CubeEdges &edges = m_cubeEdges[stackInd];
|
||||
|
||||
BOOST_FOREACH(CubeEdge *edge, edges) {
|
||||
//cerr << "edge=" << *edge << endl;
|
||||
edge->CreateFirst(m_mgr, m_queue);
|
||||
edge->CreateFirst(m_mgr, m_queue, m_seenPositions);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -105,7 +107,7 @@ void Search::Decode(size_t stackInd)
|
||||
m_stacks.Add(hypo, m_mgr.GetHypoRecycle());
|
||||
|
||||
CubeEdge &edge = ele->edge;
|
||||
edge.CreateNext(m_mgr, ele, m_queue);
|
||||
edge.CreateNext(m_mgr, ele, m_queue, m_seenPositions);
|
||||
|
||||
++pops;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ protected:
|
||||
// CUBE PRUNING
|
||||
// decoding
|
||||
CubeEdge::Queue m_queue;
|
||||
CubeEdge::SeenPositions m_seenPositions;
|
||||
|
||||
void Decode(size_t stackInd);
|
||||
void PostDecode(size_t stackInd);
|
||||
|
Loading…
Reference in New Issue
Block a user