Esempio n. 1
0
bool
CIMIContext::_buildLattice(IPySegmentor::TSegmentVec &segments,
                           unsigned rebuildFrom,
                           bool doSearch)
{
    _clearFrom(rebuildFrom);

    IPySegmentor::TSegmentVec::const_iterator it = segments.begin();
    IPySegmentor::TSegmentVec::const_iterator ite = segments.end();

    unsigned i, j = 0;
    for (; it != ite; ++it) {
        i = it->m_start;
        j = i + it->m_len;

        if (i < rebuildFrom - 1)
            continue;

        if (j >= m_lattice.capacity() - 1)
            break;

        if (it->m_type == IPySegmentor::SYLLABLE)
            _forwardSyllables(i, j, *it);
        else if (it->m_type == IPySegmentor::SYLLABLE_SEP)
            _forwardSyllableSep(i, j);
        else
            _forwardString(i, j, it->m_syllables);
        m_bOmitPunct = false;
    }

    _forwardTail(j, j + 1);
    m_tailIdx = j + 1;

    return doSearch && searchFrom(rebuildFrom);
}
Esempio n. 2
0
void CIMIContext::clear ()
{
    _clearFrom (1);
    _clearBestPaths ();
    m_tailIdx = 1;
    m_candiStarts = m_candiEnds = 0;
}