Ejemplo n.º 1
0
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);
	}
}
Ejemplo n.º 2
0
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");
		}
	}


}