void CHomonym::ResetGenderFromHomonym(const CHomonym& h) { if (h.HasGrammem(gFeminine)) Grammems.Replace(gMasculine, gFeminine); if (h.HasGrammem(gMasculine)) Grammems.Replace(gFeminine, gMasculine); }
bool CWord::CanAddHomonym(const CHomonym& h) const { //make sure that abbreviations (e.g. PO, OAO, etc.) are uppercased if (h.HasGrammem(gAbbreviation) && !m_bIgnoreUpperCase) { if (!m_bUp) return false; for (size_t i = 0; i < m_txt.size(); ++i) if (!::IsUpper(m_txt[i])) return false; } if ((h.IsGeo() || h.IsName()) && h.IsMorphNoun() && !m_bUp && !m_bIgnoreUpperCase) return false; return true; }
void CAnalyticFormBuilder::ChangeGrammemsAsAnalyticForm(CHomonym& H, const CHomonym& VerbHomonym) { THomonymGrammems old_grammems; H.Grammems.Swap(old_grammems); for (THomonymGrammems::TFormIter old = old_grammems.IterForms(); old.Ok(); ++old) for (THomonymGrammems::TFormIter verb = VerbHomonym.Grammems.IterForms(); verb.Ok(); ++verb) { Stroka strPos; // auxiliary verb grammems const TGramBitSet& VerbGrammems = *verb; // meaningful part grammems TGramBitSet MainGrammems = *old; // final grammems to set TGramBitSet ResultedGrammems; if (MainGrammems.Has(gInfinitive)) { ResultedGrammems = MainGrammems & ~TMorph::AllPOS(); if (VerbGrammems.Has(gImperative)) { // analytical form for imperatives in singular number does not exist if (VerbGrammems.Has(gSingular)) continue; ResultedGrammems.Set(gImperative); // "будем же жить!" } else ResultedGrammems |= VerbGrammems & NSpike::AllTimes; // "я стал пилить" или "стану писать" ResultedGrammems |= VerbGrammems & NSpike::AllPersons; ResultedGrammems |= VerbGrammems & NSpike::AllNumbers; ResultedGrammems |= VerbGrammems & NSpike::AllGenders; //copy all POS grammems from verb to main ResultedGrammems |= VerbGrammems & TMorph::AllPOS(); H.PutAuxArticle(SDictIndex(TEMPLATE_DICT, VerbHomonym.GetAuxArticleIndex(TEMPLATE_DICT))); strPos = "Г"; } else if (TMorph::IsShortParticiple(MainGrammems)) { // "*будем же взяты!" if (VerbGrammems.Has(gImperative)) continue; ResultedGrammems = MainGrammems & ~TMorph::AllPOS(); // remove any time grammems from participle ResultedGrammems &= ~NSpike::AllTimes; ResultedGrammems |= VerbGrammems & NSpike::AllPersons; ResultedGrammems |= VerbGrammems & NSpike::AllTimes; if (VerbGrammems.Has(gImperative)) // ??? the same check second time, always false? ResultedGrammems.Set(gImperative); strPos = "ПРИЧАСТИЕ"; ResultedGrammems |= TGramBitSet(gParticiple, gShort); } else if (TMorph::IsShortAdjective(MainGrammems)) { if (VerbGrammems.Has(gImperative)) continue; // будем cчитать, что "будем же красивы!" - это плохо! // на самом деле, просто не хочется вводить ее кучу кодов. ResultedGrammems = VerbGrammems; ResultedGrammems |= MainGrammems & (NSpike::AllNumbers | NSpike::AllGenders | TGramBitSet(gAnimated, gInanimated)); ResultedGrammems &= ~TMorph::AllPOS(); if (ResultedGrammems.Has(gActive)) ResultedGrammems &= ~TGramBitSet(gActive); ResultedGrammems |= TGramBitSet(gAdjective, gShort); strPos = "П"; } else if (MainGrammems.Has(gPraedic)) // "мне было больно" { ResultedGrammems = VerbGrammems; ResultedGrammems |= NSpike::AllCases & MainGrammems; //copied from PronounPredk code (commented below) - preserve cases if any ResultedGrammems &= ~TMorph::AllPOS(); if (ResultedGrammems.Has(gActive)) ResultedGrammems.Reset(gActive); strPos = "ПРЕДК"; ResultedGrammems |= MainGrammems & TMorph::AllPOS(); } else if (MainGrammems.Has(gComparative)) // он был больше тебя { ResultedGrammems = (VerbGrammems & ~TMorph::AllPOS()) | TGramBitSet(gComparative); if (ResultedGrammems.Has(gActive)) ResultedGrammems.Reset(gActive); strPos = "П"; ResultedGrammems |= MainGrammems & TMorph::AllPOS(); } else if (TMorph::IsFullAdjective(MainGrammems)) // resolve disambiguity of homonyms, because analytical forms with full adjectives do not exist. continue; // "стал писать" "стану писать" "стать писать" - совершенный вид if (VerbHomonym.Lemma == kStat) ResultedGrammems.Reset(gImperfect).Set(gPerfect); // if the auxiliary verb was an infinitive then it is all an infinitive // "быть лучше" или "должно быть принесено" if (VerbHomonym.HasGrammem(gInfinitive)) { ResultedGrammems &= ~TMorph::AllPOS(); ResultedGrammems.Set(gInfinitive); strPos = "ИНФИНИТИВ"; } else if (VerbHomonym.HasGrammem(gGerund)) // "будучи лишней" { ResultedGrammems &= ~TMorph::AllPOS(); ResultedGrammems.Set(gGerund); strPos = "ДЕЕПРИЧАСТИЕ"; } if (strPos.empty()) continue; /* do some corrections (code taken from RusGramTab.ProcessPOSAndGrammems) */ if (ResultedGrammems.HasAll(NSpike::AllCases | TGramBitSet(gAdjPronoun))) ResultedGrammems |= NSpike::AllGenders | NSpike::AllNumbers; if (ResultedGrammems.Has(gMasFem)) ResultedGrammems |= TGramBitSet(gMasculine, gFeminine); if (!ResultedGrammems.Has(gPraedic) && ResultedGrammems.HasAll(NSpike::AllCases) && !ResultedGrammems.Has(gSingular)) ResultedGrammems |= TGramBitSet(gSingular, gPlural); H.Grammems.AddForm(ResultedGrammems); } }