I have a question about the function :
MiraWeightVector.ToSparse(SparseVector* sparse) .

It's defined as this:

void MiraWeightVector::ToSparse(SparseVector* sparse) const
{
  for (size_t i = 0; i < m_weights.size(); ++i) {
    if(abs(m_weights[i])>1e-8) {
      sparse->set(i,m_weights[i]);
    }
  }
}

This means the same index i is used for both SparseVector and
MiraWeightVector.
However, according to the code in kbmira.cpp, there's a gap between the
indexes.

for dense feature:      size_t id = SparseVector::encode(names[i]);
then, for sparse feature:      size_t id = SparseVector::encode(name) +
initDenseSize;


​Why isn't  the ToSparse function looks like this:

void MiraWeightVector::ToSparse(SparseVector* sparse, size_t denseSize)
const
{
  for (size_t i = 0; i < m_weights.size(); ++i) {
    if (i < denseSize) {
      sparse->set(i,m_weights[i]);
    } else {
      if(abs(m_weights[i])>1e-8) {
        sparse->set(i-denseSize,m_weights[i]);
      }
    }
  }
}

I'm kind of confused,  did I miss something ?
Many thanks.

Liangyou

-- 

Liangyou Li
CNGL
School of Computing
Dublin City University
_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to