Пример #1
0
int CWord::PutGztArticle(int iH, const TGztArticle& gzt_article, bool bClone)
{
    CHomonym& h = GetRusHomonym(iH);
    bool has_aux_kw = h.HasAuxArticle(KW_DICT);
    if (!has_aux_kw && !h.HasGztArticle()) {
        h.PutGztArticle(gzt_article);
        return iH;
    } else if (bClone || has_aux_kw || h.GetGztArticle().GetType() != gzt_article.GetType()) {
        THomonymPtr pNewHom = h.Clone();
        pNewHom->PutGztArticle(gzt_article);
        return AddRusHomonym(pNewHom);
    } else {
        YASSERT(h.HasGztArticle() && h.GetGztArticle().GetType() == gzt_article.GetType());
        h.m_ExtraGztArticles.insert(gzt_article);
        return iH;
    }
}
Пример #2
0
// return found (or newly made) homonym id
static int FindOrMakeMultiwordHomonym(const CWordSequence& ws, CWord& word, TKeyWordType kwtype, THomonymGrammems grammems, THomonymPtr& res) {
    // use the content of CWordSequence.m_Lemmas as new homonym lemma
    Wtroka str = ws.GetLemma();
    if (!str)
        str = word.GetLowerText();
    TMorph::ToLower(str);

    int homId = -1;
    // search if we already have a multiword homonym with such text
    if (!FindBestHomonym(word, str, kwtype, grammems, homId)) {
        // create new homonym, if there is no ready one
        res = new CHomonym(TMorph::GetMainLanguage(), str);
        if (ws.HasAuxArticle())
            res->PutAuxArticle(ws.GetAuxArticleIndex());
        else
            res->PutGztArticle(ws.GetGztArticle());
        homId = word.AddRusHomonym(res);
    }
    return homId;
}