static int GetConjProperties(const CSentence& S, int WordNo, ConjFromWhatList& FromWhere,int& iConjIndex, int UpperBorder) { if( (WordNo == -1) || (WordNo >= UpperBorder) ) return -1; int OborotNo = S.m_Words[WordNo].GetOborotNo(); if ( OborotNo != -1 && S.GetOpt()->m_pOborDic->m_Entries[OborotNo].HasPartOfSpeech(S.GetOpt()->m_Conjunction) ) { for(size_t i = WordNo ; i < UpperBorder; i++ ) if( S.m_Words[i].HasOborot2()) { FromWhere = FROM_OBOR_DIC; iConjIndex = OborotNo; return WordNo + 1; } } iConjIndex = S.m_Words[WordNo].m_SubordinateConjNo; int HomonymNo; if ( (iConjIndex != -1 ) && !S.IsRelativSentencePronoun(0, WordNo, HomonymNo) ) { FromWhere = FROM_SUB_CONJ; return WordNo+1; } return -1; }
void GetRelations(const CSentence& Sentence, string& Result) { CRelationsIterator RelIt; RelIt.SetSentence(&Sentence); for (int i = 0; i<Sentence.m_vectorPrClauseNo.size(); i++) RelIt.AddClauseNoAndVariantNo(Sentence.m_vectorPrClauseNo[i], 0); RelIt.BuildRelations(); for (long RelNo = 0; RelNo < RelIt.GetRelations().size(); RelNo++) { const CSynOutputRelation& piRel = RelIt.GetRelations()[RelNo]; string RelName = Sentence.GetOpt()->GetGroupNameByIndex(piRel.m_Relation.type); string Src = GetNodeStr(Sentence, RelIt, piRel.m_iSourceGroup, piRel.m_Relation.m_iFirstWord); string Trg = GetNodeStr(Sentence, RelIt, piRel.m_iTargetGroup, piRel.m_Relation.m_iLastWord); string SrcLemma, TrgLemma; string SrcGrm = GetNodeGrmStr(Sentence, RelIt, piRel.m_iSourceGroup, piRel.m_Relation.m_iFirstWord, SrcLemma); string TrgGrm = GetNodeGrmStr(Sentence, RelIt, piRel.m_iTargetGroup, piRel.m_Relation.m_iLastWord, TrgLemma); string GramRel = Sentence.GetOpt()->GetGramTab()->GrammemsToStr(piRel.m_Relation.m_iGrammems); Result += Format("\t<rel name=\"%s\" gramrel=\"%s\" lemmprnt=\"%s\" grmprnt=\"%s\" lemmchld=\"%s\" grmchld=\"%s\" > %s -> %s </rel>\n", RelName.c_str(), GramRel.c_str(), SrcLemma.c_str(), SrcGrm.c_str(), TrgLemma.c_str(), TrgGrm.c_str(), Src.c_str(), Trg.c_str()); } }
string GetNodeGrmStr(const CSentence& Sentence, const CRelationsIterator& RelIt, int GroupNo, int WordNo, string& Lemma) { Lemma = ""; if (GroupNo != -1) return ""; else { size_t ClauseNo = Sentence.GetMinClauseByWordNo(WordNo); const CClause& Clause = Sentence.GetClause(ClauseNo); const CMorphVariant* pSynVar = &*Clause.GetSynVariantByNo(0); int UnitNo = pSynVar->UnitNoByWordNo(WordNo); const CSynUnit& U = pSynVar->m_SynUnits[UnitNo]; Lemma = Sentence.GetWords()[WordNo].GetHomonym(U.m_iHomonymNum)->m_strLemma; return Sentence.GetOpt()->GetGramTab()->GrammemsToStr(U.m_iGrammems | U.m_TypeGrammems); } }
void GetGroups(const CSentence& Sentence, const CAgramtab& A, string& Res) { int nClausesCount = Sentence.GetClausesCount(); for (int ClauseNo = 0; ClauseNo<nClausesCount; ClauseNo++) { const CClause& Clause = Sentence.GetClause(ClauseNo); int nCvar = Clause.m_SynVariants.size(); if (Clause.m_SynVariants.empty()) continue; int nVmax = Clause.m_SynVariants.begin()->m_iWeight; for (CSVI pSynVar = Clause.m_SynVariants.begin(); pSynVar != Clause.m_SynVariants.end(); pSynVar++) { if (pSynVar->m_iWeight < nVmax) break; const CMorphVariant& V = *pSynVar; Res += Format("\t<synvar>\n"); // print the clause { int ClauseType = (V.m_ClauseTypeNo == -1) ? UnknownSyntaxElement : Clause.m_vectorTypes[V.m_ClauseTypeNo].m_Type;; string Type; if (ClauseType != UnknownSyntaxElement) Type = (const char*)A.GetClauseNameByType(ClauseType); else Type = "EMPTY"; Res += Format("\t\t<clause type=\"%s\">%s</clause>\n", Type.c_str(), GetWords(Sentence, Clause).c_str()); } for (int GroupNo = 0; GroupNo < V.m_vectorGroups.GetGroups().size(); GroupNo++) { const CGroup& G = V.m_vectorGroups.GetGroups()[GroupNo]; Res += Format("\t\t<group type=\"%s\">%s</group>\n", Sentence.GetOpt()->GetGroupNameByIndex(G.m_GroupType), GetWords(Sentence, G).c_str()); }; Res += Format("\t</synvar>\n"); } } }