当前位置: 首页>>代码示例>>C++>>正文


C++ yvector::size方法代码示例

本文整理汇总了C++中yvector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ yvector::size方法的具体用法?C++ yvector::size怎么用?C++ yvector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yvector的用法示例。


在下文中一共展示了yvector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConvertToOriginalWords

void CFilterCheck::ConvertToOriginalWords(ymap< int, yset<int> >& FilterItemToWords,
                                          const yvector<SWordHomonymNum>& ItemWrds, int iID)
{
    if (0 == ItemWrds.size()) return;
    yset<int>& rWrdIds = FilterItemToWords[iID];
    for (size_t i = 0; i < ItemWrds.size(); i++)
        rWrdIds.insert(m_MultiWordCreator.m_Words.GetWord(ItemWrds.at(i)).GetSourcePair().LastWord());
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:8,代码来源:filtercheck.cpp

示例2: ConvertIntVectorIntoRule

void ConvertIntVectorIntoRule(const yvector<int>& v_Rule, CWorkRule& r_Rule)
{
    assert(v_Rule.size() > 3);

    r_Rule.m_OriginalRuleNo = v_Rule[0];
    r_Rule.m_LeftPart = v_Rule[1];
    r_Rule.m_RightPart.m_SynMainItemNo = v_Rule[2];
    for (int i = 3; i < (int)v_Rule.size(); i++)
        r_Rule.m_RightPart.m_Items.push_back(v_Rule[i]);
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:10,代码来源:loader.cpp

示例3: Compact

void CGLRTable::Compact(const yvector< yvector<CSLRCell> >& table)
{
    Mask.clear();
    if (table.empty())
        return;

    Rows = table.size();
    Columns = table[0].size();
    YASSERT(Columns != 0);

    NGzt::TCompactStorageBuilder<ui32> ruleIndexStorageBuilder;
    yvector<ui32> tmp;

    Mask.resize((Rows * Columns - 1)/8 + 1);
    for (size_t row = 0; row < table.size(); ++row) {
        for (size_t column = 0; column < table[row].size(); ++column) {
            const CSLRCell& cell = table[row][column];
            if (cell.IsEmpty())
                continue;

            size_t index = row*Columns + column;
            Mask[index >> 3] |= 1 << (index & 7);
            if (cell.m_ReduceRules.size() == 1 && !cell.m_bShift && cell.m_GotoLine == -1)
                // lowest bit 0 means the rest value is already rule index (without encoding in RuleIndexStorage)
                //SimpleCells.push_back(MakePair(MakePair(row, column), GetRuleIndex(cell.m_ReduceRules[0]) << 1));
                SimpleCells.Add(row, column, GetRuleIndex(cell.m_ReduceRules[0]) << 1);
            else {
                tmp.clear();
                for (size_t i = 0; i < cell.m_ReduceRules.size(); ++i)
                    tmp.push_back(GetRuleIndex(cell.m_ReduceRules[i]));
                ui32 rulesIndex = ruleIndexStorageBuilder.AddRange(tmp.begin(), tmp.end());

                // lowest bit 1 means the rest value is already rule index
                //SimpleCells.push_back(MakePair(MakePair(row, column), (ComplexCells.size() << 1) + 1));    // overflow check will be done later
                SimpleCells.Add(row, column, (ComplexCells.size() << 1) + 1);
                ComplexCells.push_back(TCompactSLRCell(cell.m_bShift, cell.m_GotoLine, rulesIndex));
            }
        }
    }
    TBufferStream tmpbuf;
    ruleIndexStorageBuilder.Save(&tmpbuf);
    RuleIndexStorage.Load(&tmpbuf);

    // make sure we are not out of index space:
    CheckIndexOverflow(ComplexCells.size());

    //assert that reverse conversion produces original data
    YASSERT(Verify(table));
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:49,代码来源:glrtable.cpp

示例4: InitAmbiguousSlot

void InitAmbiguousSlot(yvector< COccurrence >& Occurrences)
{
    /* quite slow implementation. could be done with single iteration through sorted array - i.e. in O(n), not O(n^2) */
    for (size_t i=0; i < Occurrences.size(); i++)
        Occurrences[i].m_bAmbiguous = false;

    for (size_t i=0; i < Occurrences.size(); i++) {
        for (size_t k=i+1; k < Occurrences.size(); k++)
            if (Occurrences[k].first < Occurrences[i].second) {
                Occurrences[k].m_bAmbiguous = true;
                Occurrences[i].m_bAmbiguous = true;
            } else
                break;
    }
}
开发者ID:johny-nsk,项目名称:tomita-parser,代码行数:15,代码来源:solveperiodambiguity.cpp

示例5: SubstituteByMultiWord

void CMultiWordCreator::SubstituteByMultiWord(SWordHomonymNum& WordHomonymNum, yvector<SWordHomonymNum>& WordIndexes)
{
    const CWord& multi_word = m_Words.GetWord(WordHomonymNum);

    int k1 = -1, k2 = -1;
    for (size_t i = 0; i < WordIndexes.size(); i++) {
        const CWord& w = m_Words.GetWord(WordIndexes[i]);
        if ((w.IsOriginalWord()) &&
            (w.GetSourcePair().FirstWord() == multi_word.GetSourcePair().FirstWord()))
            k1 = i;

        if (k1 != -1) {
            if (!w.IsOriginalWord())
                break;

            if (w.GetSourcePair().FirstWord() == multi_word.GetSourcePair().LastWord()) {
                k2 = i;
                break;
            }
        }
    }

    if ((k1 != -1) && (k2 != -1))
        for (int j = k2; j >= k1; j--)
            WordIndexes.erase(WordIndexes.begin() + j);

    if (k1 != -1)
        WordIndexes.insert(WordIndexes.begin() + k1, WordHomonymNum);
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:29,代码来源:multiwordcreator.cpp

示例6: FindAuxKWWords

void CMultiWordCreator::FindAuxKWWords(yvector<SDictIndex>& indexes, EDicType dicType)
{
    if (dicType == DICTYPE_COUNT)
        return;

    bool bHasTextKW = false;
    yvector<SDictIndex> tomitaKWArticles;
    SDictIndex algArticleIndex;//считатеся, что у одного kw_type не больше одного alg
    for (size_t i = 0; i < indexes.size(); ++i) {
        SDictIndex index = indexes[i];
        YASSERT(dicType == index.m_DicType);    //словарь должен быть для всех одинаковый

        const article_t* pArt = GlobalDictsHolder->GetAuxArticle(index);
        if (m_FoundArticles.find(SArtPointer(pArt->get_title())) != m_FoundArticles.end())
            continue;

        if (pArt->has_text_content()) // значит поле СОСТАВ состоит из обычных слов
            bHasTextKW = true;
        else if (pArt->has_gram_file_name())
            tomitaKWArticles.push_back(index);
        else if (pArt->has_alg())
            algArticleIndex = index;
    }

    if (bHasTextKW || dicType == KW_DICT)
        FindKeyWords(dicType);

    for (size_t i = 0; i < tomitaKWArticles.size(); ++i)
        ProcessTomitaAuxArticle(tomitaKWArticles[i]);

    if (algArticleIndex.IsValid())
        ProcessAlgArticle(TArticleRef(algArticleIndex));
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:33,代码来源:multiwordcreator.cpp

示例7: AddClauseVariants

void CTopClauses::AddClauseVariants(yvector<CClauseVariant>& ClauseVars)
{
    m_FirstNode->m_outNodes.clear();
    m_FirstNode->m_inNodes.clear();

    m_LastNode->m_outNodes.clear();
    m_LastNode->m_inNodes.clear();

    yvector<CClause*> deleted_clause;
    for (size_t i = 0; i < ClauseVars.size(); i++) {
        const_clause_it it;
        CClauseNode* pLastNode = m_FirstNode;
        for (it = ClauseVars[i].GetFirstClause(LeftToRight); it != ClauseVars[i].GetEndClause(); it = ClauseVars[i].GetNextClause(LeftToRight, it))
            pLastNode = AddInitialClause(*it, pLastNode, deleted_clause);
        bool bAdd = true;
        for (size_t j = 0; j < pLastNode->m_outNodes.size(); j++)
            if (pLastNode->m_outNodes[j].m_pNode == m_LastNode) {
                bAdd = false;
                break;
            }
        if (bAdd) {
            pLastNode->m_outNodes.push_back(SClauseRelation(m_LastNode));
            m_LastNode->m_inNodes.push_back(SClauseRelation(pLastNode));
        }
    }
    for (size_t j = 0; j < deleted_clause.size(); j++)
        delete deleted_clause[j];/**/
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:28,代码来源:topclauses.cpp

示例8: ConvertFilterIntoIntVector

void ConvertFilterIntoIntVector(const yvector<CFilterPair>& r_Filter, yvector<int>& v_Filter)
{
    for (int i = 0; i < (int)r_Filter.size(); i++) {
        v_Filter.push_back(r_Filter[i].m_iItemID);
        v_Filter.push_back(r_Filter[i].m_iWordDistance);
    }
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:7,代码来源:loader.cpp

示例9: BuildTerminalIndex

static void BuildTerminalIndex(const yvector<CGrammarItem> grammarItems, const ITerminalDictionary& terminals,
                               ymap<int, eTerminals>& index) {
    for (size_t i = 0; i < grammarItems.size(); ++i) {
        const CGrammarItem& item = grammarItems[i];
        if (siString == item.m_Type || siAnyWord == item.m_Type || siFileList == item.m_Type)
            index[i] = terminals.FindTerminal(item.m_ItemStrId);
    }
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:8,代码来源:loader.cpp

示例10: ToHTMLColorString

Stroka CSentence::ToHTMLColorString(const yvector<CWordsPair>& wp, const Stroka& sColor, ECharset encoding) const
{
    Stroka str;
    for (size_t i = 0; i + 1 <= m_words.size(); ++i) {
        CWord* pW = m_words[i].Get();
        for (size_t j = 0; j < wp.size(); ++j)
            if (wp[j].FirstWord() == (int)i)
                str += Substitute("<font color=\"$0\">", sColor);
        if (i > 0 && (!pW->IsPunct() || pW->IsOpenBracket() || pW->IsCloseBracket()))
            str += " ";
        str += NStr::Encode(pW->GetOriginalText(), encoding);
        for (size_t j = 0; j < wp.size(); ++j)
            if (wp[j].LastWord() == (int)i)
                str += "</font>";
    }
    return StripString(str);
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:17,代码来源:sentence.cpp

示例11: BuildClauseVariants

void CTopClauses::BuildClauseVariants(yvector<CClauseVariant>& ClauseVars)
{
    CClauseVariant ClauseVar(m_Words);
    ClauseVars.push_back(ClauseVar);
    BuildClauseVariantsRec(ClauseVars, m_FirstNode);
    for (size_t i = 0; i < ClauseVars.size(); i++)
        ClauseVars[i].CalculateBadWeight();
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:8,代码来源:topclauses.cpp

示例12: GetRelevantAgrWeight

static int GetRelevantAgrWeight(const yvector<CCheckedAgreement>& CheckedAgrs)
{
    int ret = 0;
    for (size_t i = 0; i < CheckedAgrs.size(); i++) {
        ret += GetAgreementWeight(CheckedAgrs[i]);
    }
    return ret;

}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:9,代码来源:factgroup.cpp

示例13: BitsetToString

Stroka BitsetToString(const yvector<TGramBitSet>& bitset, const Stroka& delim /*= ", "*/, const Stroka& groupdelim /*= ", "*/) {
    Stroka s;
    for (size_t i = 0; i < bitset.size(); ++i) {
        if (!s.empty())
            s += groupdelim;
        s += bitset[i].ToString(~delim);
    }
    return s;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:9,代码来源:terminals.cpp

示例14: FillWSFactField

void CSitFactInterpretation::FillWSFactField(const fact_field_reference_t& fact_field, const CWordsPair& newWS, yvector<CFactFields>& newFacts)
{
    bool bAdded = false;
    if (newFacts.size() > 0) {
        for (size_t i = 0; i < newFacts.size(); i++) {
            if (newFacts[i].GetFactName() == fact_field.m_strFactTypeName.c_str()) {
                newFacts[i].AddValue(fact_field.m_strFieldName, newWS, fact_field.m_Field_type, fact_field.m_bConcatenation);
                bAdded = true;
            }
        }
    }

    if (!bAdded) {
        CFactFields fact(fact_field.m_strFactTypeName.c_str());
        fact.AddValue(fact_field.m_strFieldName, newWS, fact_field.m_Field_type, fact_field.m_bConcatenation);
        newFacts.push_back(fact);
    }
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:18,代码来源:sitfactinterpretation.cpp

示例15: SolveAmbiguity

void SolveAmbiguity(yvector<COccurrence>& Occurrences)
{
    yvector<size_t> res;
    SolveAmbiguity(Occurrences, res);
    if (res.size() != Occurrences.size()) {
        yvector<COccurrence> tmp(res.size());
        for (size_t i = 0; i < res.size(); ++i)
            tmp[i] = Occurrences[res[i]];
        Occurrences.swap(tmp);
    }
}
开发者ID:johny-nsk,项目名称:tomita-parser,代码行数:11,代码来源:solveperiodambiguity.cpp


注:本文中的yvector::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。