• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ yvector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: 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


示例5: ConvertRuleIntoIntVector

void ConvertRuleIntoIntVector(const CWorkRule& r_Rule, yvector<int>& v_Rule)
{
    v_Rule.push_back(r_Rule.m_OriginalRuleNo);
    v_Rule.push_back(r_Rule.m_LeftPart);
    v_Rule.push_back(r_Rule.m_RightPart.m_SynMainItemNo);
    for (int i = 0; i < (int)r_Rule.m_RightPart.m_Items.size(); i++)
        v_Rule.push_back(r_Rule.m_RightPart.m_Items[i]);
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:8,代码来源:loader.cpp


示例6: TGramBitSet

void TSurnamePredictor::SaveParadigma(TSurnameLemma& surnameLemma, yvector<TTempForm>& paradigma)
{
    if (surnameLemma.SurnameFlex.empty() ||
        (surnameLemma.Weight == 0))
        return;

    TGramBitSet stemGram;

    SurnameLemmasFlex.push_back(surnameLemma);

    unsigned char c = gBefore + 1;
    for (; c < gMax ; c++)
    {
        int i;
        for (i = 0 ; i < paradigma.ysize() ; i++)
        {
            if (!paradigma[i].Grammars.Test(NTGrammarProcessing::ch2tg(c)))
                break;
        }
        if (i >= paradigma.ysize())
            stemGram.Set(NTGrammarProcessing::ch2tg(c));
    }

    Stroka ss = stemGram.ToString(",");

    for (int i = 0 ; i < paradigma.ysize() ; i++)
    {
        TSurnameFlexMap::iterator it = SurnameFlex2Paradigmas.find(paradigma[i].Flex);

        if (it == SurnameFlex2Paradigmas.end())
        {
            TFormInfo formInfo;
            formInfo.SurnameLemmaFlexNo = SurnameLemmasFlex.ysize() - 1;
            formInfo.StemGrammar = stemGram;
            ss = TGramBitSet(paradigma[i].Grammars & ~stemGram).ToString(",");
            formInfo.FlexGrammars.push_back(paradigma[i].Grammars & ~stemGram);
            SurnameFlex2Paradigmas[paradigma[i].Flex] = yvector<TFormInfo>(1,formInfo);
        } else {
            yvector<TFormInfo>& infos = it->second;
            int j;
            for (j = 0; j < infos.ysize(); j++) {
                if (infos[j].SurnameLemmaFlexNo == (SurnameLemmasFlex.ysize() - 1)) {
                    ss = TGramBitSet(paradigma[i].Grammars & ~stemGram).ToString(",");
                    infos[j].FlexGrammars.push_back(paradigma[i].Grammars & ~stemGram);
                    break;
                }
            }
            if (j >= infos.ysize()) {
                TFormInfo formInfo;
                formInfo.SurnameLemmaFlexNo = SurnameLemmasFlex.ysize() - 1;
                formInfo.StemGrammar = stemGram;
                ss = TGramBitSet(paradigma[i].Grammars & ~stemGram).ToString(",");
                formInfo.FlexGrammars.push_back(paradigma[i].Grammars & ~stemGram);
                infos.push_back(formInfo);
            }
        }
    }
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:58,代码来源:surname_predictor.cpp


示例7: BuildRuleInfo

static void BuildRuleInfo(const yset<CWorkRule>& rules, yvector<CGLRRuleInfo>& res)
{
    res.clear();
    for (yset<CWorkRule>::const_iterator it = rules.begin(); it != rules.end(); ++it) {
        res.push_back();
        res.back().Init(&*it);
    }
    std::sort(res.begin(), res.end());
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:9,代码来源:glrtable.cpp


示例8: CollectFiles

void TMixedDescriptorPool::CollectFiles(yvector<const TFileDescriptor*>& files) {
    files.clear();
    const yset<Stroka>& fileNames = Database.RequestedFiles();
    for (yset<Stroka>::const_iterator it = fileNames.begin(); it != fileNames.end(); ++it) {
        const TFileDescriptor* fd = FindFileByName(*it);
        if (fd)
            files.push_back(fd);
    }
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:9,代码来源:builtin.cpp


示例9: 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


示例10: 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


示例11: YASSERT

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


示例12: 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


示例13: Predict

bool TSurnamePredictor::Predict(const TWtringBuf& w, yvector<TPredictedSurname>& res) const
{
    int MinLemmaSize = 1;
    TGrammarBunch usedFlexGrammars;
    for (int i = Min<int>((int)w.length() - MinLemmaSize, MaxSurnameSuffixLength); i > 0; i--) {
        TWtringBuf Suffix = w.SubStr(w.size() - i);
        TSurnameFlexMap::const_iterator it = SurnameFlex2Paradigmas.find(Suffix);

        //храним те граммемы, которые мы уже приписывали, для того, чтобы когда мы предсказываем
        //по более короткому хвосту, не приписывать граммемы уже приписанного более длинного
        //например, "Балуевского" может предсказаться по АВДУЕВСКИЙ и ТОЛСТОЙ, у АВДУЕВСКИЙ
        //хвост длиннее, и все граммемы хвоста по ТОЛСТОЙ вкладываются в граммемы по АВДУЕВСКИЙ
        //значит вообще не добавляем омонима, предсказанного ТОЛСТОЙ

        yvector<TGramBitSet> grammemsForThisSuffix;
        if (it != SurnameFlex2Paradigmas.end())
        {
            const yvector<TFormInfo>& formInfos = it->second;
            for (int j=0; j < formInfos.ysize(); j++)
            {
                TPredictedSurname predictedSurname;
                for (int k = 0 ; k < formInfos[j].FlexGrammars.ysize() ; k ++)
                {
                    TGramBitSet gramBitSet = formInfos[j].FlexGrammars[k];
                    gramBitSet |= formInfos[j].StemGrammar & AllGenders;
                    if (usedFlexGrammars.find(gramBitSet) == usedFlexGrammars.end())
                        predictedSurname.FlexGrammars.push_back(formInfos[j].FlexGrammars[k]);
                }

                if (predictedSurname.FlexGrammars.size() == 0)
                    continue;
                predictedSurname.StemGrammar = formInfos[j].StemGrammar;
                grammemsForThisSuffix.insert(grammemsForThisSuffix.begin(), predictedSurname.FlexGrammars.begin(),
                                                                            predictedSurname.FlexGrammars.end());

                const TSurnameLemma& L = SurnameLemmasFlex[formInfos[j].SurnameLemmaFlexNo];

                predictedSurname.Lemma = ::ToWtring(w.SubStr(0, w.size() - i)) + L.SurnameFlex;
                predictedSurname.Weight = L.Weight;
                res.push_back(predictedSurname);
            }
        }
        for (int k = 0 ; k < grammemsForThisSuffix.ysize() ; k++)
            usedFlexGrammars.insert(grammemsForThisSuffix[k]);

    }
    return res.size() > 0;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:48,代码来源:surname_predictor.cpp


示例14: 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


示例15: GetIncludedClauses

//все клаузы, которые непосредственно включаются в главную
void CClauseSubTree::GetIncludedClauses(yvector<CClause*>& clauses)
{
    yvector<CWordsPair*> periods;
    GetIncludedPeriodsBase(periods);
    for (size_t i = 0; i < periods.size(); i++)
        clauses.push_back((CClause*)periods[i]);
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:8,代码来源:clausesubtree.cpp


示例16: FindKWWords

void CMultiWordCreator::CreateWordIndexes(const yset<SArtPointer>&  artPointers, yvector<SWordHomonymNum>& WordIndexes, bool bAddEndOfStreamSymbol)
{
    for (yset<SArtPointer>::const_iterator it = artPointers.begin(); it != artPointers.end(); ++it)
        FindKWWords(*it, KW_DICT);

    InitWordIndexes(WordIndexes);
    //использую алгоритм SolveAmbiguity и соответственно структуру COccurrence
    //COccurrence.m_GrammarRuleNo - номер multiWord
    yvector<COccurrence> multiWordsOccurrences;
    for (size_t i = 0; i < m_Words.GetMultiWordsCount(); ++i) {
        const CWord& pW = m_Words.GetMultiWord(i);

        yset<SArtPointer>::const_iterator it;
        for (it = artPointers.begin(); it != artPointers.end(); ++it)
            if (pW.HasArticle(*it))
                break;

        if (it == artPointers.end())
            continue;

        COccurrence o(pW.GetSourcePair().FirstWord(), pW.GetSourcePair().LastWord() + 1, i);
        multiWordsOccurrences.push_back(o);
    }

    SolveAmbiguity(multiWordsOccurrences);
    yvector<SWordHomonymNum> multiWords;
    for (size_t i = 0; i < multiWordsOccurrences.size(); i++) {
        SWordHomonymNum tmp(multiWordsOccurrences[i].m_GrammarRuleNo,-1, false);
        SubstituteByMultiWord(tmp, WordIndexes);
    }
    if (bAddEndOfStreamSymbol)
        WordIndexes.push_back(m_Words.GetEndWordWH());
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:33,代码来源:multiwordcreator.cpp


示例17: 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


示例18: 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


示例19: 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


示例20: GetOccurrences

void CTrieHolder::GetOccurrences (const TerminalString& Text, yvector< COccurrence >& Occurrences) const
{
    int r = 0;
    Occurrences.clear();
    for (size_t i=0; i<Text.size(); i++) {
        r = NextState(r, i, Text[i], Occurrences);
    };
};
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:8,代码来源:ahokorasick.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ zstring类代码示例发布时间:2022-05-31
下一篇:
C++ yvec_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap