예제 #1
0
/*
Выдает по парадигме прилагательного наречие, которое совпадает с краткой формой среднего рода
этого прилагательного, например: 
	"красивый" (ПРИЛ) -> "красиво" (НАР)
	"лучше" (ПРИЛ) -> "хорошо" (НАР)
*/
UINT CSemanticsHolder::GetAdverbWith_O_ByAdjective (UINT AdjParadigmId, string AdjWordForm)
{
	string AdvLemma;	

	CFormInfo Paradigm;
	try {
		if (!GetRusLemmatizer()->CreateParadigmFromID(AdjParadigmId, Paradigm))
			return -1;
	}
	catch (...) {
		return -1;
	};


	// ищем краткое прилагательное среднего рода
	long k=0;
	for (; k < Paradigm.GetCount(); k++)
	{
		string Form = Paradigm.GetWordForm(k);
		string AnCode = Paradigm.GetAncode(k);
		QWORD Grammems;
        BYTE POS;
        GetRusGramTab()->ProcessPOSAndGrammems(AnCode.c_str(), POS, Grammems );

        if (( Grammems & _QM(rNeutrum)) && POS==ADJ_SHORT)
					break;
	};
	if (k == Paradigm.GetCount()) return -1;

	AdvLemma = Paradigm.GetWordForm(k);

	return GetFirstParadigmId(morphRussian, AdvLemma,  (1<<ADV));
};
예제 #2
0
파일: RusWord.cpp 프로젝트: eamosov/lspl
bool CRusSentence::IsAdjDeclination (const CSynHomonym& H) const
{
	if (!H.IsMorphNoun()) return false;
	if (H.m_strLemma.length() < 3)  return false;
	if (H.m_lPradigmID == -1) return false;
	string suffix = H.m_strLemma.substr(H.m_strLemma.length()-2);
	bool bMasc = (suffix == "»…") ||  (suffix == "џ…");
	bool bFem = (suffix == "јя") ||  (suffix == "яя");
	if (!bMasc && !bFem) return false;

	CFormInfo Info;
	GetOpt()->GetLemmatizer()->CreateParadigmFromID(H.m_lPradigmID, Info);
	for (long k=0; k < Info.GetCount(); k++)
	{
		string Ancode = Info.GetAncode(k);
		QWORD  g = GetRusGramTab()->GetAllGrammems(Ancode.c_str());
		if (  g & _QM(rSingular) )
			if ( g & _QM(rGenitiv) )
			{
				string Form = Info.GetWordForm(k);
				int l = Form.length();
				if (l < 3) return false;
				if (bMasc)
					return		(Form.substr(l-3) == "≈√ќ")
							||	(Form.substr(l-3) == "ќ√ќ");
				else
					return		(Form.substr(l-2) == "ќ…")
							||	(Form.substr(l-2) == "≈…");
			};
	};
	return false;		
};
예제 #3
0
// loading simple list of words from a file, lemmatizing it, and storing
void CMorphDictionary::LoadFrequentRoots(string path)
{
	string load_path = path+"predictroots.txt";
	FILE*fp =  fopen (load_path.c_str(), "r");
	if (!fp) return;
	char buffer[1000];
	while (fgets (buffer, 1000, fp))
	{
		string WordStr = buffer;
		Trim(WordStr);
		if (WordStr.empty()) continue;
		RmlMakeUpper (WordStr, m_Language);
		vector<CFindWordNode> FindResults;
		bool retval = FindWord(WordStr, true, false, false, FindResults);
		if (!retval) continue;
		set<size_t> UsedFlexia;
		for (size_t i=0; i<FindResults.size(); i++)
		{
				CFormInfo P;
				P.Create(	this, 
							FindResults[i].m_nBase,
							FindResults[i].m_LemmaInfo,
							FindResults[i].m_nFlex
						);
				for (size_t j=0; j < P.GetCount(); j++)
				{
					size_t FlexNo = P.GetFlexNoOfForm(j);
					if (UsedFlexia.find(FlexNo) == UsedFlexia.end())
					{
						CPredictEndRoot R;
						R.m_BaseNo = FindResults[i].m_nBase;
						R.m_LemmaInfo = FindResults[i].m_LemmaInfo;
						R.m_EndRoot = P.GetWordForm(j);
						reverse(R.m_EndRoot.begin(),R.m_EndRoot.end());
						
						R.m_FlexNo = FlexNo;
						UsedFlexia.insert(FlexNo);
						m_PredictEndRoots.push_back(R);
					};
				};
			

		};

	};
	fclose(fp);
	sort(m_PredictEndRoots.begin(), m_PredictEndRoots.end());
};
예제 #4
0
BOOL CNewRefArticles::OnSetActive() 
{
	// TODO: Add your specialized code here and/or call the base class
	SetWindowText (m_Caption);
	CRossDevApp* App = (CRossDevApp*)AfxGetApp();
	CNewArticleWizard* P  = (CNewArticleWizard*)GetParent();

    m_List.ResetContent();
	P->SetWizardButtons( PSWIZB_BACK|PSWIZB_NEXT|PSWIZB_FINISH);

	for (size_t k = 0;  k < m_RefsId.size(); k++)
	{
		CFormInfo Prd;
		if (GetSemBuilder().m_RusStr.m_pData->GetRusLemmatizer()->CreateParadigmFromID(m_RefsId[k], Prd))
			m_List.AddString(Prd.GetWordForm(0).c_str());
	};
	return CPropertyPage::OnSetActive();
}