bool CWord::RightPartIsSurname(int& iH, THomonymGrammems& grammems, Wtroka& strLemma) { iH = HasMorphNounWithGrammems_i(TGramBitSet(gSurname)); if (iH != -1) { CHomonym& h = GetRusHomonym(iH); grammems = h.Grammems; strLemma = h.GetLemma(); size_t ii = strLemma.find('-'); YASSERT(ii != Wtroka::npos); strLemma = strLemma.substr(ii + 1); return true; } //if this word is in morphology - do not try to predict if (IsDictionary()) return false; size_t ii = m_txt.find('-'); if (ii == Wtroka::npos) return false; Wtroka strRightPart = m_txt.substr(ii + 1); TMorph::ToLower(strRightPart); yvector<TSurnamePredictor::TPredictedSurname> out; if (!TMorph::PredictSurname(strRightPart, out)) return false; TGrammarBunch newForms; NSpike::ToGrammarBunch(out[0].StemGrammar, out[0].FlexGrammars, newForms); grammems.Reset(newForms); strLemma = out[0].Lemma; return true; }
//if we already tried to predict then return what we predicted bool CWord::PredictAsSurname() { int iH = HasMorphNounWithGrammems_i(TGramBitSet(gSurname)); if (iH != -1) return !GetRusHomonym(iH).IsDictionary(); yvector<TSurnamePredictor::TPredictedSurname> out; if (!TMorph::PredictSurname(GetLowerText(), out)) return false; THomonymPtr pFirstHomonym = m_Homonyms[IterHomonyms().GetID()]; bool bFound = IsDictionary(); for (size_t i = 0; i < out.size(); i++) { TGrammarBunch forms; ToGrammarBunch(out[i].StemGrammar, out[i].FlexGrammars, forms); Wtroka lemma = out[i].Lemma; if (i == 0 && !bFound) pFirstHomonym->Init(lemma, forms, pFirstHomonym->IsDictionary()); else { THomonymPtr pClonedHomonym = pFirstHomonym->Clone(); pClonedHomonym->Init(lemma, forms, false); AddHomonym(pClonedHomonym, false); } } return true; }
bool CWord::HasCommonHomonyms(const CWord& w) const { if (!IsDictionary() || !w.IsDictionary()) { SHomIt it1 = IterHomonyms(); SHomIt it2 = w.IterHomonyms(); if (it1.Ok() && it2.Ok() && TMorph::IdentifSimilar(it1->Lemma, it2->Lemma)) return true; } for (SHomIt it1 = IterHomonyms(); it1.Ok(); ++it1) for (SHomIt it2 = w.IterHomonyms(); it2.Ok(); ++it2) if (it1->Lemma == it2->Lemma) return true; return false; }
void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) { ASSERT(IsDictionary()); // Avoid 2 constructions of CFX_ByteString. CFX_ByteString key_bytestring = key; auto it = m_Map.find(key_bytestring); if (it == m_Map.end()) { if (pObj) { m_Map.insert(std::make_pair(key_bytestring, pObj)); } return; } if (it->second == pObj) return; it->second->Release(); if (pObj) it->second = pObj; else m_Map.erase(it); }
const CPDF_Dictionary* CPDF_Object::AsDictionary() const { return IsDictionary() ? static_cast<const CPDF_Dictionary*>(this) : nullptr; }