subphrase stored as start + length, not start + end

This commit is contained in:
Hieu Hoang 2016-03-03 23:56:36 +00:00
parent 4b0b01679f
commit f29f4c5d5f
10 changed files with 19 additions and 19 deletions

View File

@ -37,7 +37,7 @@ public:
return !( (*this) == compare );
}
virtual std::string GetString(const FactorList &factorTypes) const;
virtual SubPhrase GetSubPhrase(size_t start, size_t end) const = 0;
virtual SubPhrase GetSubPhrase(size_t start, size_t size) const = 0;
};
////////////////////////////////////////////////////////////////////////

View File

@ -42,7 +42,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
break;
}
SubPhrase subPhrase = input.GetSubPhrase(startPos, endPos);
SubPhrase subPhrase = input.GetSubPhrase(startPos, phaseSize);
Range range(startPos, endPos);
InputPath *path = new (pool.Allocate<InputPath>()) InputPath(pool, subPhrase, range, numPt, prefixPath);

View File

@ -34,9 +34,9 @@ public:
size_t GetSize() const
{ return m_size; }
SubPhrase GetSubPhrase(size_t start, size_t end) const
SubPhrase GetSubPhrase(size_t start, size_t size) const
{
SubPhrase ret(*this, start, end);
SubPhrase ret(*this, start, size);
return ret;
}

View File

@ -39,7 +39,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
break;
}
SubPhrase subPhrase = input.GetSubPhrase(startPos, endPos);
SubPhrase subPhrase = input.GetSubPhrase(startPos, phaseSize);
Range range(startPos, endPos);
InputPath *path = new (pool.Allocate<InputPath>()) InputPath(pool, subPhrase, range, numPt, prefixPath);

View File

@ -53,7 +53,7 @@ void Manager::Decode()
InitActiveChart(startPos);
for (int endPos = startPos + 1; endPos < size + 1; ++endPos) {
SubPhrase sub = m_input->GetSubPhrase(startPos, endPos - 1);
SubPhrase sub = m_input->GetSubPhrase(startPos, endPos - startPos);
cerr << "sub=" << sub << endl;
}

View File

@ -29,9 +29,9 @@ public:
size_t GetSize() const
{ return m_size; }
SubPhrase GetSubPhrase(size_t start, size_t end) const
SubPhrase GetSubPhrase(size_t start, size_t size) const
{
SubPhrase ret(*this, start, end);
SubPhrase ret(*this, start, size);
return ret;
}

View File

@ -45,9 +45,9 @@ public:
size_t GetSize() const
{ return m_size; }
SubPhrase GetSubPhrase(size_t start, size_t end) const
SubPhrase GetSubPhrase(size_t start, size_t size) const
{
SubPhrase ret(*this, start, end);
SubPhrase ret(*this, start, size);
return ret;
}

View File

@ -10,10 +10,10 @@ using namespace std;
namespace Moses2
{
SubPhrase::SubPhrase(const Phrase &origPhrase, size_t start, size_t end)
SubPhrase::SubPhrase(const Phrase &origPhrase, size_t start, size_t size)
:m_origPhrase(&origPhrase)
,m_start(start)
,m_end(end)
,m_size(size)
{
}
@ -32,9 +32,9 @@ std::ostream& operator<<(std::ostream &out, const SubPhrase &obj)
return out;
}
SubPhrase SubPhrase::GetSubPhrase(size_t start, size_t end) const
SubPhrase SubPhrase::GetSubPhrase(size_t start, size_t size) const
{
SubPhrase ret(*m_origPhrase, m_start + start, m_start + end);
SubPhrase ret(*m_origPhrase, m_start + start, m_size);
return ret;
}

View File

@ -8,17 +8,17 @@ class SubPhrase : public Phrase
{
friend std::ostream& operator<<(std::ostream &, const SubPhrase &);
public:
SubPhrase(const Phrase &origPhrase, size_t start, size_t end);
SubPhrase(const Phrase &origPhrase, size_t start, size_t size);
virtual const Word& operator[](size_t pos) const;
virtual size_t GetSize() const
{ return m_end - m_start + 1; }
{ return m_size; }
SubPhrase GetSubPhrase(size_t start, size_t end) const;
SubPhrase GetSubPhrase(size_t start, size_t size) const;
protected:
const Phrase *m_origPhrase;
size_t m_start, m_end;
size_t m_start, m_size;
};
}

View File

@ -78,7 +78,7 @@ GetScore(const Phrase& f, const Phrase& e, const Phrase& c)
key = MakeKey(f, e, c);
else {
for(size_t i = 0; i <= c.GetSize(); ++i) {
SubPhrase sub_c = c.GetSubPhrase(i, c.GetSize()-1);
SubPhrase sub_c = c.GetSubPhrase(i, c.GetSize() - i);
key = MakeKey(f,e,sub_c);
}
}