Beispiel #1
0
//----------------------------------------------------------------------------
bool CMorphwizardView::OpenExistingParadigm( lemma_iterator_t it, bool bRunAccentWizard )
{
	try
	{
		if( it==GetWizard()->m_LemmaToParadigm.end() )
			return false;

		std::string save_common_grammems, save_slf, save_prefixes;
		save_slf = GetWizard()->get_slf_string(it, save_common_grammems, save_prefixes, 50);

		CSLFDocument* pDocument = NewSLFDocument();
		pDocument->m_Paradigm = it->second;
		pDocument->m_ParadigmText = save_slf.c_str();
		pDocument->m_CommonGrammems = save_common_grammems.c_str();
		pDocument->m_Prefixes = save_prefixes.c_str();

		pDocument->OpenParadigm(bRunAccentWizard);
		return true;
	}
	catch(CExpc& e)
	{
		echo(e.m_strCause.c_str());
	}
	catch(...)
	{
		echo("error");
	}
	return false;
}
Beispiel #2
0
//----------------------------------------------------------------------------
void CMorphwizardView::OnToolsSetParaNo()
{
	if (found_paradigms.empty()) 
	{
		ErrorMessage("Cannot set paradigm No to an empty found list");
		return;
	};
	POSITION pos = m_FoundList.GetFirstSelectedItemPosition();		
	WORD ParadigmNo = 0;
	if(pos != 0)
	{
		size_t index = m_FoundList.GetNextSelectedItem(pos);
		assert(index < found_paradigms.size());
		ParadigmNo = found_paradigms[index]->second.m_FlexiaModelNo;
	}
	string s = Format("%i",ParadigmNo);
	if ( !InputBox("Input paradigm No:", s) ) return;
	ParadigmNo = atoi(s.c_str());
	if (ParadigmNo >= GetWizard()->m_FlexiaModels.size())
	{
			ErrorMessage(Format("Paradigm no %i is not found",ParadigmNo));
			return;
	}
	std::string Warn = Format("The program ascribes all found words to paradigm %i . Continue?", ParadigmNo);
	if  (::MessageBox (0, Warn.c_str(),"MorphWizard",MB_OKCANCEL   ) != IDOK )
		return;

	const CFlexiaModel &new_par = GetWizard()->m_FlexiaModels[ParadigmNo];
	size_t ErrorsCount = 0;

	for (size_t i=0; i<found_paradigms.size(); i++)
	{
		const CFlexiaModel &old_par = GetWizard()->m_FlexiaModels[found_paradigms[i]->second.m_FlexiaModelNo];

		if (found_paradigms[i]->second.m_FlexiaModelNo == ParadigmNo) continue;

		
		std::string new_flexia = new_par.get_first_flex();
		std::string lemma = GetWizard()->get_lemm_string(found_paradigms[i]);
		std::string lemma_suffix = lemma.substr(lemma.length() - new_flexia.length());

		if (new_flexia == lemma_suffix)
		{
			GetWizard()->change_prd_info(found_paradigms[i]->second, lemma, ParadigmNo,UnknownAccentModelNo,true);
		}
		else
		{
			ErrorsCount++;
		};
	};
	if (ErrorsCount > 0)
	{
		ErrorMessage (Format("This last operation cannot change lemma in %i cases.", ErrorsCount));
	};
	ShowFoundParadigms();
}
Beispiel #3
0
void CMorphwizardView::OnToolsPackMrd() 
{
	CGriIni cIni("Packing...");;
	cIni.Init(this);
	{
		CWizardProgressMeter meter(*GetWizard());
		GetWizard()->pack();
	}
	AfxMessageBox ("Packing is finished!");
}
Beispiel #4
0
//----------------------------------------------------------------------------
lemma_iterator_t CMorphwizardView::FindNonAccentedPara( bool partialAccentedPara )
{
	lemma_iterator_t it=GetWizard()->m_LemmaToParadigm.begin();
	for( ; 
		it!=GetWizard()->m_LemmaToParadigm.end(); it++ )
	{
		if( GetWizard()->HasUnknownAccents(it) ) 
		{
			if( GetWizard()->IsPartialAccented(it) || !partialAccentedPara ) 
				return it;
		}
	}
	return it;		
}
BOOL COutputWizardFinish::OnWizardFinish()
{
	UpdateData();
	LRESULT result = OutputWizardPage::OnWizardFinish();
	GetWizard()->GenerateOutputProfiles();
	return result;
}
Beispiel #6
0
void CMorphwizardView::OnAdd() 
{
	POSITION pos = m_PredictedList.GetFirstSelectedItemPosition();		

	try{
		CSLFDocument* pDocument = NewSLFDocument();
				
		CString predict_what;
		m_PredictWhat.GetWindowText(predict_what);
		if (pos == NULL)
		{
			predict_what += " ";
			pDocument->m_ParadigmText = predict_what;
			pDocument->m_CommonGrammems = "";
		}else 
		{
			size_t ind = m_PredictedList.GetNextSelectedItem(pos);
			CString S = m_PredictedList.GetItemText(ind, PredictIndexColumnNo);
			std::string common_grammems;
			pDocument->m_ParadigmText = GetWizard()->create_slf_from_predicted(atoi(S), common_grammems, 50).c_str();
			pDocument->m_CommonGrammems = common_grammems.c_str();
			int i = predict_what.Find("|");
			if (i != -1)
				pDocument->m_Prefixes =  predict_what.Mid(0, i);
		}


		pDocument->OpenParadigm();

	}catch(CExpc& e){
		echo(e.m_strCause.c_str());
	}catch(...){
		echo("error");
	}
}
Beispiel #7
0
void CParadigmDifferences::OnBnClickedAnalyse()
{
	UpdateData(TRUE);
	if (m_Paradigm1 >= GetWizard()->m_FlexiaModels.size())
	{
			ErrorMessage(Format("Paradigm no %i is not found",m_Paradigm1));
			return;
	}
	if (m_Paradigm2 >= GetWizard()->m_FlexiaModels.size())
	{
			ErrorMessage(Format("Paradigm no %i is not found",m_Paradigm2));
			return;
	}
	std::string s = GetWizard()->show_differences_in_two_paradigms(m_Paradigm1,m_Paradigm2);
	m_Results = s.c_str();
	UpdateData(FALSE);
}
Beispiel #8
0
void CMorphwizardView::ShowFoundParadigms() 
{
	m_FoundList.clear();
	
	for( int i=0; i<found_paradigms.size(); i++ )
	{
		int FlexiaModelNo = found_paradigms[i]->second.m_FlexiaModelNo;
		std::string s = Format("%i (%i)", FlexiaModelNo,
			found_paradigms[i]->second.m_AccentModelNo);

		m_FoundList.InsertItem(i, s.c_str() );

		std::string Lemma = GetWizard()->get_lemm_string_with_accents(found_paradigms[i]);
		std::string PrefixSet = GetWizard()->get_prefix_set( found_paradigms[i] );
		if (!PrefixSet.empty())
			Lemma = PrefixSet+'|'+Lemma;
		RmlMakeLower(Lemma, GetWizard()->m_Language);
		m_FoundList.SetItemText(i, FindLemmaColumn, Lemma.c_str());

		s = GetWizard()->get_pos_string(found_paradigms[i]) + " " + GetWizard()->get_grammem_string(found_paradigms[i]);
		m_FoundList.SetItemText(i, FindGrammemsColumn, s.c_str());
			
		s = GetWizard()->get_common_grammems_string(found_paradigms[i]);
		m_FoundList.SetItemText(i, FindTypeGrammemsColumn, s.c_str());

		m_FoundList.m_ToolTips.push_back(GetWizard()->m_FlexiaModels[FlexiaModelNo].m_Comments);

	}

	char ch[1024];
	sprintf(ch, "Found %d paradigms", found_paradigms.size());
	echo(ch);
};
Beispiel #9
0
//----------------------------------------------------------------------------
BOOL CMorphwizardDoc::SaveModified()
{
	CSLFDocument* doc, *doc1;
	CString s;
	if( HasModifiedSlf() ) 
	{
		POSITION pos = m_slfDocs.GetStartPosition();
		while( !!pos ) 
		{
			m_slfDocs.GetNextAssoc(pos,doc,doc1);
			if( doc->IsModified() )
				s += doc->GetLemma() + ",\n";
		}
	}

	bool hasModifedSlf = !s.IsEmpty();
	int rn=IDCANCEL;

	if( hasModifedSlf || IsModified() ) 
	{
		CString msg; 
		if( hasModifedSlf )
		{
			s.Delete(s.GetLength()-2,2);
			msg = GetTitle() + "\n\nSave all ";
			if( GetWizard()->is_changed() ) 
				msg += "changes\nincluding ";

			msg += "revised paradigms:\n\n" + s + "?";
		}
		else	// if( IsModified() )
		{
			msg = GetTitle() + "\n\nSave all changes?";
		}

		rn = ::AfxMessageBox(msg, MB_YESNOCANCEL);

		if( rn==IDCANCEL ) 
			return FALSE;
	}

	if( hasModifedSlf && rn==IDYES ) 
	{
		POSITION pos = m_slfDocs.GetStartPosition();
		while( !!pos ) 
		{
			m_slfDocs.GetNextAssoc(pos,doc,doc1);
			doc->DoFileSave();
		}
	}

	if( rn==IDYES ) 
		DoFileSave();

	return TRUE;
}
Beispiel #10
0
BOOL CMorphwizardDoc::DoFileSave()
{
	if (GetWizard()->m_ReadOnly)
	{
		AfxMessageBox ("Wizard is readonly, cannot be saved");
		return TRUE;
	};
	
	CWaitCursor wait;
	try
	{
		CWizardProgressMeter meter(m_Wizard);
		GetWizard()->save_mrd();
	}
	catch(CExpc e)
	{
		AfxMessageBox(e.m_strCause.c_str());
		return FALSE;
	}
	return TRUE;
}
Beispiel #11
0
//----------------------------------------------------------------------------
void CMorphwizardView::OnToolsSaveListFile() 
{
   	CFileDialog D(FALSE, "txt", "wordlist.txt");
	if (D.DoModal() != IDOK) return;
	FILE * fp = fopen (D.GetPathName(),"wb");

	for( int i=0; i<found_paradigms.size(); i++ )
	{
		std::string lemma = GetWizard()->get_lemm_string_with_accents(found_paradigms[i]);
		std::string PrefixSet = GetWizard()->get_prefix_set( found_paradigms[i] );
		if (!PrefixSet.empty())
			lemma = PrefixSet+'|'+lemma;
		RmlMakeLower(lemma, GetWizard()->m_Language);
        std::string common_grams = "* "+GetWizard()->get_grammem_string(found_paradigms[i]->second.GetCommonAncodeIfCan());

		std::string s = lemma 
			+ ";"
			+ common_grams
			+ ";"
			+ GetWizard()->get_pos_string(found_paradigms[i]) 
			+ " " 
			+ GetWizard()->get_grammem_string(found_paradigms[i]);
		fprintf (fp, "%s\n", s.c_str());
			
	}
    fclose (fp);
}
Beispiel #12
0
void CMorphwizardDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
	}
	else
	{
	   	// ask username
		CDlgLogin dlgLogin;
		if( dlgLogin.DoModal() != IDOK )
			throw CExpc("No login information");

		CGriIni cIni;
		cIni.Init();
		CWizardProgressMeter meter(m_Wizard);
		bool ret = GetWizard()->load_wizard(ar.GetFile()->GetFilePath(), dlgLogin.m_name);
		
		SetInputLanguage(GetWizard()->m_Language);

		cIni.Exit();
	}
}
Beispiel #13
0
void CMorphwizardView::OnBnClickedSetPrdComments()
{
	POSITION pos = m_FoundList.GetFirstSelectedItemPosition();		

	if(pos == 0)
	{
		ErrorMessage ("No item selected");
		echo("No item selected");
		return;
	};
	size_t index = m_FoundList.GetNextSelectedItem(pos);
	int ModelNo = found_paradigms[index]->second.m_FlexiaModelNo;
	string Caption = Format("Input comments to paradigm No:%i", ModelNo);
	InputBox(Caption.c_str(), GetWizard()->m_FlexiaModels[ModelNo].m_Comments);
}
Beispiel #14
0
//----------------------------------------------------------------------------
void CMorphwizardView::OnReadonlyImage() 
{
	// TODO: Add your control notification handler code here
    CString FileName = GetWizard()->get_lock_file_name().c_str();
	if (access((const char*)FileName, 0) != -1)
	{
	    char s [1000];
		CString Mess;
        FILE* fp =  fopen (FileName, "r");
		if (!fp) return;
		while (fgets(s, 1000, fp))
			Mess += s;
		fclose(fp);
		::MessageBox (0, Mess, "Lock Information", MB_OK);
	}
}
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName )
{
    int max = GetSize();
    
    for( int i=0; i<max; i++ )
    {
        FOOTPRINT_WIZARD *wizard =  GetWizard( i );
        
        wxString name = wizard->GetName();
        
        if ( name.Cmp( aName ) )
                return wizard;     
    }
   
    return NULL;
}
BOOL COutputWizardFinish::OnSetActive()
{
	if (RunTimeHelper::IsVista())
	{
		PropSheet_EnableWizButtons(m_hWnd,
		                           PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_FINISH,
		                           PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_FINISH);
		PropSheet_ShowWizButtons(m_hWnd,
		                         PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_CANCEL | PSWIZB_FINISH,
		                         PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_FINISH | PSWIZB_FINISH);
	}
	else
		GetWizard()->SetWizardButtons(PSWIZB_BACK|PSWIZB_FINISH);

	return OutputWizardPage::OnSetActive();
}
bool FOOTPRINT_WIZARDS::deregister_object( void* aObject )
{
    int max = GetWizardsCount();

    for( int i = 0; i<max; i++ )
    {
        FOOTPRINT_WIZARD* wizard = GetWizard( i );

        if( wizard->GetObject() == aObject )
        {
            m_FootprintWizards.erase( m_FootprintWizards.begin() + i );
            delete wizard;
            return true;
        }
    }

    return false;
}
Beispiel #18
0
void CMorphwizardView::OnToolsExport() 
{
	try {
   		CFileDialog D(FALSE, "slf", "paradigms.slf");
		if (D.DoModal() != IDOK) return;
		FILE * fp = fopen (D.GetPathName(),"wb");
		if (!fp) 
		{
			AfxMessageBox ("Cannot open file");
			return;
		};
		
		CProgressMeterRML meter;
		meter.SetMaxPos(found_paradigms.size(),100);
		CString info = "Exporting " + D.GetPathName() + "..."; 
		meter.SetInfo(info);

		GetWizard()->set_to_delete_false();
		for  (long i=0;  i <found_paradigms.size(); i++) 
		{
			CDumpParadigm P;
			P.m_SlfStr = GetWizard()->get_slf_string(found_paradigms[i], P.m_TypeGrammemsStr, P.m_PrefixesStr, 50);
			
			if (found_paradigms[i]->second.m_PrefixSetNo != UnknownPrefixSetNo)
				P.m_PrefixesStr = GetWizard()->get_prefix_set(found_paradigms[i]);

			if ( !found_paradigms[i]->second.GetCommonAncodeIfCan().empty() )
				P.m_TypeGrammemsStr =  GetWizard()->get_grammem_string(found_paradigms[i]->second.GetCommonAncodeIfCan());

			if (found_paradigms[i]->second.m_SessionNo != UnknownSessionNo)
				P.m_Session =  GetWizard()->get_session(found_paradigms[i]->second.m_SessionNo);

			P.SaveToFile(fp);

			found_paradigms[i]->second.m_bToDelete = true;

			meter.AddPos();
		}
		fclose (fp);

		if (::MessageBox (0,"Delete all exported paradigms?","MorphWizard",MB_YESNO   ) == IDYES)
		  GetWizard()->delete_checked_lemms();
	}
   catch (...)
   {
	   			AfxMessageBox ("some error has occured");
   };

    
}
Beispiel #19
0
void CMorphwizardView::OnRemove() 
{
	try 
	{
		POSITION pos = m_FoundList.GetFirstSelectedItemPosition();		
		if(pos == 0)
		{
			echo("No item selected");
		}
		else
		{
			size_t index = m_FoundList.GetNextSelectedItem(pos);
			GetWizard()->remove_lemm(found_paradigms.at(index));	
			echo("Word removed");
		}
		m_FoundList.DeleteAllItems();
		OnFind();
	}
	catch (...)
	{
		ErrorMessage ("An exception occurred!");
	};
}
Beispiel #20
0
//----------------------------------------------------------------------------
//	Ищет слова по заданному в файле перечню. 
//  В файле на каждой строке сначала стоит часть речи, а потом лемма.
//----------------------------------------------------------------------------
void CMorphwizardView::OnToolsSelectByFile() 
{
	// TODO: Add your command handler code here
   	CFileDialog D(TRUE, "slf", "paradigms.txt");
	if (D.DoModal() != IDOK) return;
	FILE * fp = fopen (D.GetPathName(),"rb");
	if (!fp) 
	{
		AfxMessageBox ("Cannot open file");
		return;
	};
	char buf[1000];
	std::string strNotFound;
	int ParadigmCount = 0;
	found_paradigms.clear();
	while  (fgets(buf, 1000, fp)) 
	{
		std::string Line = buf;
		Trim(Line);
		if (Line.empty()) continue;
		StringTokenizer tok (Line.c_str(), ";");
		if (!tok())
		{
			std::string mess = std::string("cannot get lemma from ") + buf + std::string("; The format should be <Lemma>;<TypeGrammems>;<MorphPattern>");
			AfxMessageBox (mess.c_str());
			break;
		};
		std::string Lemma = tok.val();
		Trim(Lemma);


		if (!tok())
		{
			std::string mess = std::string("cannot get type grammem ") + buf + std::string("; The format should be <Lemma> <PartofSpeech> <Grammems>");
			AfxMessageBox (mess.c_str());
			break;
		};
		std::string TypeAncode;
		{
			std::string grams = tok.val();
			Trim(grams);
			if (grams != "*")
				if (!GetWizard()->slf2ancode(grams, TypeAncode )) 
				{
					std::string mess = std::string("cannot process type grammems ") + grams;
					AfxMessageBox (mess.c_str());
					break;
				};
		};


		if (!tok())
		{
			std::string mess = std::string("cannot get morphological pattern ") + buf + std::string("; The format should be <Lemma>;<TypeGrammems>;<MorphPattern>");
			AfxMessageBox (mess.c_str());
			break;
		};
		std::string FirstCode;
		{
			std::string PosStr = tok.val();
			Trim(PosStr);
			if (!GetWizard()->slf2ancode(PosStr,FirstCode )) 
			{
				std::string mess = std::string("cannot process morph. pattern ") + PosStr;
				AfxMessageBox (mess.c_str());
				break;
			};
		};

		std::vector<lemma_iterator_t> curr_found_paradigms;
		RmlMakeUpper(Lemma, GetWizard()->m_Language);
		bool bFound = false;
		GetWizard()->find_lemm(Lemma.c_str(), true, curr_found_paradigms);
		for(size_t i=0; i<curr_found_paradigms.size(); i++ )
		{
			std::string str_pos = GetWizard()->m_FlexiaModels[curr_found_paradigms[i]->second.m_FlexiaModelNo].get_first_code();;

			if (curr_found_paradigms[i]->second.GetCommonAncodeIfCan() == TypeAncode)
				if( FirstCode == str_pos )
					if (std::find(found_paradigms.begin(), found_paradigms.end(), curr_found_paradigms[i]) == found_paradigms.end())
					{
						found_paradigms.push_back(curr_found_paradigms[i]);
						bFound = true;
					};
		}
		if (!bFound)
			strNotFound +=  Format("Not found: %s\r\n", Line.c_str());


	};
	fclose(fp);

	FilterFoundParadigms();
	ShowFoundParadigms();	
	if (!strNotFound.empty())
		echo(strNotFound.c_str());
}
Beispiel #21
0
//----------------------------------------------------------------------------
void CMorphwizardView::OnToolsImport() 
{
	int line_no = 0;
	CString PathName;

try {
   	CFileDialog D(TRUE, "slf", "paradigms.slf",OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT);
	char file_buffer[10000];
	file_buffer[0] = 0;
	D.m_ofn.lpstrFile = file_buffer;
	D.m_ofn.nMaxFile = 10000;
	if (D.DoModal() != IDOK) return;
	POSITION pos = D.GetStartPosition();
	if (pos == 0) return;
	bool bTestMode = ::MessageBox (0,"Test it or import?","MorphWizard",MB_YESNO   ) == IDYES;
	
	GetWizard()->m_bFullTrace = false;
	PathName = D.GetNextPathName(pos);
	while  (true) // all selected files 
	{

		FILE * fp = fopen (PathName,"r");
		if (!fp) 
		{
			AfxMessageBox ("Cannot open file");
			return;
		};
				
		GetWizard()->log (std::string("import file ") + (const char*)PathName);
				
		CProgressMeterRML meter;
		meter.SetFileMaxPos(fp);
		CString info = (bTestMode?"Test":"Import");
		info+= "ing file " + PathName + "...";
		meter.SetInfo(info);
				
		int ParadigmCount = 0;
		string Errors;
		line_no = 0;
		bool bError;
		CDumpParadigm P;
		while  (GetWizard()->ReadNextParadigmFromFile(fp, P, line_no, bError, Errors)) 
		{
			if (!bError)
			{
				int line_no_err = 0;
				ParadigmCount++;
				try 
				{
					if (bTestMode)
					{
						std::string lemm;
						CFlexiaModel Dummy1;
						CAccentModel AccentModel;
						BYTE Dummy;
						GetWizard()->slf_to_mrd (P.m_SlfStr, lemm, Dummy1, AccentModel, Dummy, line_no_err);
					}
					else
					{
						WORD SessionNo = GetWizard()->RegisterSession(P.m_Session);
						GetWizard()->add_lemma(P.m_SlfStr, P.m_TypeGrammemsStr, P.m_PrefixesStr, line_no_err, SessionNo);
					};

					meter.SetFilePos();		  
				}
				catch (CExpc C)
				{
					Errors += Format("%s (%s:%i) \n", C.m_strCause.c_str(), (const char*)PathName, P.m_FirstSlfLineNo+line_no_err);
				}
				catch  (...) 
				{
					Errors += Format("error at %s:%i \n", (const char*)PathName, P.m_FirstSlfLineNo+line_no_err);
				};
					
			}
		}
		fclose (fp);
		if (!Errors.empty())
		{
			try {
				string ErrorFile = MakeFName((const char*)PathName, "err");
				FILE * fp = fopen (ErrorFile.c_str(), "w");
				fprintf (fp, "%s",Errors.c_str());
				fclose(fp);
				ErrorMessage(Format("Errors were written to file %s",  ErrorFile.c_str()));
			} 
			catch (...){
				AfxMessageBox ("Cannot write errors to paradigms.err ");
			}
		}
		else
		{
			ErrorMessage(Format("Successfully %s %i paradigms from \"%s\"" , bTestMode? "tested":"imported", ParadigmCount, PathName), "Confirmation");
		};
		if (pos == 0) break;
		PathName = D.GetNextPathName(pos);
	} // all selected files

}
catch (...)
{
	ErrorMessage (Format("some error has occurred (file=%s, line=%i", PathName, line_no));
};
	GetWizard()->m_bFullTrace = true;
}
Beispiel #22
0
//----------------------------------------------------------------------------
BOOL CMorphwizardDoc::IsModified()
{
	//if(	GetWizard()->m_ReadOnly ) return FALSE; 
	if( GetWizard()->is_changed() || HasModifiedSlf() ) return TRUE;
	return FALSE;
}
Beispiel #23
0
//----------------------------------------------------------------------------
void CMorphwizardView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
	SetInputLanguage(GetWizard()->m_Language);
	CSizeFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
Beispiel #24
0
void CMorphwizardView::OnPredict() 
{
	try
	{
		UpdateData(TRUE);
		m_FoundList.DeleteAllItems();
		std::vector<lemma_iterator_t> curr_found_paradigms;

		m_PredictedList.clear();

		CString predict_what;
		CString prefix;

		m_PredictWhat.GetWindowText(predict_what);
		std::string Lemma = predict_what;
		int i = predict_what.Find("#");
		
		if (i != -1)
		{
			prefix = predict_what.Mid(0, i);
			predict_what = predict_what.Mid(i+1);
			Lemma = prefix+predict_what;
		};

		GetWizard()->find_lemm(Lemma.c_str(), false, curr_found_paradigms);
		if (!curr_found_paradigms.empty())
			AfxMessageBox ("The dictionary contains already this word!");


		GetWizard()->predict_lemm((const char*)predict_what, m_PredictSuffLength, m_MinimalFrequence, m_bOnlyMainPartOfSpeeches==TRUE);
		if (GetWizard()->m_CurrentPredictedParadigms.empty())
		{
			ErrorMessage("No variants found");
			return;
		};
		vector<size_t> Index;
		for(size_t i=0; i < GetWizard()->m_CurrentPredictedParadigms.size(); i++)
			Index.push_back(i);
		std::sort (Index.begin(), Index.end(), IsLessForPredict(this));
		for(size_t i = 0; i < Index.size(); i++)
		{
			size_t  ind = Index[i];
			const CPredictSuffix& S = *GetWizard()->m_CurrentPredictedParadigms[ind];
			const CFlexiaModel& P = GetWizard()->m_FlexiaModels[S.m_FlexiaModelNo];

			m_PredictedList.InsertItem(i, GetWizard()->get_pos_string_and_grammems(S.m_SourceLemmaAncode).c_str() );
			m_PredictedList.SetItemText(i, PredictTypeDictColumn, GetWizard()->get_grammem_string(S.m_SourceCommonAncode).c_str());
			m_PredictedList.SetItemText(i, PredictLemmaColumn, S.m_SourceLemma.c_str());
			m_PredictedList.SetItemText(i, PredictFreqColumnNo, Format("%i", S.m_Frequence).c_str());
			m_PredictedList.SetItemText(i, PredictIndexColumnNo,  Format("%i", ind).c_str() );
			m_PredictedList.SetItemText(i, PredictParadigmColumnNo,  Format("%i", S.m_FlexiaModelNo).c_str() );
			m_PredictedList.SetItemText(i, PredictLemmaPrefixColumnNo,  S.m_PrefixSetStr.c_str() );
			m_PredictedList.m_ToolTips.push_back(P.m_Comments);
		}
		OnFind();
		m_PredictWhat.SetFocus();
	}
	catch (...)
	{
	ErrorMessage("wizard", "an exception occurred!");

	};
	
}
Beispiel #25
0
void CMorphwizardView::OnFind() 
{
	try 
	{
		m_FoundList.DeleteAllItems();
		found_paradigms.clear();
		m_FindWhat.SetFocus();

		CString find_what;
		m_FindWhat.GetWindowText(find_what);
		if (find_what == "") return;
		ChangeHistory((const char*)find_what);

		CWizardProgressMeter meter(*GetWizard());

		if(GetCheckedRadioButton(IDC_RFIND_LEM,IDC_WORD_FORM)==IDC_RFIND_LEM)
		{
			std::string s = find_what;
			RmlMakeUpper(s, GetWizard()->m_Language);
			Trim(s);
			char ch = s[0];
			if( '0'<=ch && ch<='9' )
			{
				int prdno = atoi(s.c_str());
				GetWizard()->find_lemm_by_prdno(prdno,found_paradigms);
			}
			else
			{
				if (s.substr(0,7) == "ACCENT=")
				{
					int accent_model_no = atoi(s.c_str()+7);
					GetWizard()->find_lemm_by_accent_model(accent_model_no, found_paradigms);
				}
				else
					GetWizard()->find_lemm(s.c_str(), false, found_paradigms);
			};
		}
	//
		if(GetCheckedRadioButton(IDC_RFIND_LEM,IDC_WORD_FORM)==IDC_RFIND_GRM)
			GetWizard()->find_lemm_by_grammem((const char *)find_what, found_paradigms);

		if(GetCheckedRadioButton(IDC_RFIND_LEM,IDC_WORD_FORM)==IDC_WORD_FORM)
		{
			std::string s = find_what;
			// нельзя применять  RmlMakeUpper из-за "*"
			if (GetWizard()->IsGerman())
				GerMakeUpper(s);
			else
				EngRusMakeUpper(s);
			GetWizard()->find_wordforms(s.c_str(), found_paradigms);
		};

		//  findinsg by gramcode
		if(GetCheckedRadioButton(IDC_RFIND_LEM,IDC_FIND_BY_GRAMCODE)==IDC_FIND_BY_GRAMCODE)
		{
			std::string s = find_what;
			GetWizard()->find_ancodes(s.c_str(), found_paradigms);
		};
		if(GetCheckedRadioButton(IDC_RFIND_LEM,IDC_FIND_BY_USERNAME)==IDC_FIND_BY_USERNAME)
		{
			std::string s = find_what;
			GetWizard()->find_lemm_by_user(s.c_str(), found_paradigms);
		};
		

	// proceed filter string
		FilterFoundParadigms();
		ShowFoundParadigms();
	}
	catch (CExpc C)
	{
		ErrorMessage(C.m_strCause);
	}
}
Beispiel #26
0
void CMorphwizardView::FilterFoundParadigms() 
{
	CString tmp;
	GetDlgItem(IDC_FILTER)->GetWindowText(tmp);
	std::string flt_str = (LPCTSTR)tmp;
	Trim(flt_str);
	if( flt_str.empty() ) return;
	std::string common_ancode;
	if (isdigit ((BYTE)flt_str[0]) )
	{
		if (strspn(flt_str.c_str(), "0123456789") != flt_str.length())
		{
			ErrorMessage ("Bad format for paradigm No in filter");
			return;
		};
		size_t FlexiaModel = atoi(flt_str.c_str() );
		if( FlexiaModel >= GetWizard()->m_FlexiaModels.size() )
		{
			ErrorMessage ("Paradigm No in filter is too high ");
			return;
		};
		std::vector<lemma_iterator_t> filter_paradigms;
		for( int i=0; i<found_paradigms.size(); i++ )
		{
			if (found_paradigms[i]->second.m_FlexiaModelNo != FlexiaModel) continue;
			filter_paradigms.push_back(found_paradigms[i]);
		}
		found_paradigms = filter_paradigms;

	}
	else
	{
		BYTE pos;
		QWORD grm;
		if	(		!GetWizard()->m_pGramTab->ProcessPOSAndGrammemsIfCan(flt_str.c_str(),&pos,&grm) 
				&&	!GetWizard()->m_pGramTab->ProcessPOSAndGrammemsIfCan(string("* "+flt_str).c_str(),&pos,&grm)
		)
		{
				AfxMessageBox(IDS_BADFSTR,MB_ICONERROR|MB_OK);
		}
		else
		{
			std::string flt_pos;
			if (pos != UnknownPartOfSpeech)
				flt_pos = GetWizard()->m_pGramTab->GetPartOfSpeechStr(pos);
			std::vector<lemma_iterator_t> filter_paradigms;
			for( int i=0; i<found_paradigms.size(); i++ )
			{
				std::string str_pos = GetWizard()->get_pos_string(found_paradigms[i]);

				if (!flt_pos.empty())
					if( flt_pos != str_pos )
						continue;

				if( (GetWizard()->get_all_lemma_grammems(found_paradigms[i]) & grm)  != grm) 
					continue;

				filter_paradigms.push_back(found_paradigms[i]);
			}
			found_paradigms = filter_paradigms;
		}
	};

};
Beispiel #27
0
void CParadigmDifferences::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
	CSizeFormView::OnActivate(nState, pWndOther, bMinimized);
	SetInputLanguage(GetWizard()->m_Language);
}
Beispiel #28
0
void CMorphwizardView::OnInitialUpdate() 
{
	CSizeFormView::OnInitialUpdate(); 

	// sizing 
	int GlobalX = ::GetSystemMetrics(SM_CXSCREEN);
	int GlobalY = ::GetSystemMetrics(SM_CYSCREEN);
	const  int DlgWidth = 830;
	const  int DlgHeight = 600;
	GetParent()->SetWindowPos(NULL, (GlobalX-DlgWidth)/2, (GlobalY-DlgHeight)/2-60, DlgWidth, DlgHeight, SWP_SHOWWINDOW|SWP_NOZORDER);
	GetParent()->ShowWindow(SW_MAXIMIZE); // Nick [12/Dec/2003]
	
	m_PredictedList.InsertColumn(PredictGrammemsColumn,"Grammems",LVCFMT_LEFT, 90);
	m_PredictedList.InsertColumn(PredictTypeDictColumn,"Type",LVCFMT_LEFT, 35);
	m_PredictedList.InsertColumn(PredictLemmaColumn,"Source lemma",LVCFMT_LEFT, 90);
	m_PredictedList.InsertColumn(PredictFreqColumnNo,"Freq",LVCFMT_LEFT, 50);
	m_PredictedList.InsertColumn(PredictIndexColumnNo,"Innernumber", LVCFMT_LEFT, 0);
	m_PredictedList.InsertColumn(PredictParadigmColumnNo,"ParadigmNo", LVCFMT_LEFT, 50);
	m_PredictedList.InsertColumn(PredictLemmaPrefixColumnNo,"Prefix", LVCFMT_LEFT, 50);
	m_PredictedList.SetExtendedStyle(LVS_EX_FULLROWSELECT);  

	m_FoundList.InsertColumn(FindParadigmColumnNo,"ParadigmNo",LVCFMT_LEFT, 50);
	m_FoundList.InsertColumn(FindLemmaColumn,"Lemma",LVCFMT_LEFT, 130);
	m_FoundList.InsertColumn(FindGrammemsColumn,"Grammems",LVCFMT_LEFT, 210);
	m_FoundList.InsertColumn(FindTypeGrammemsColumn,"Type",LVCFMT_LEFT, 210);
	m_FoundList.SetExtendedStyle(LVS_EX_FULLROWSELECT);  
	//m_FoundList.AddTip(0, "Tip1");
	//m_FoundList.AddTip(1, "Tip2");

	
	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
		}
	}

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	CheckRadioButton(IDC_RFIND_LEM,IDC_WORD_FORM,IDC_RFIND_LEM);
	m_inFind = true;
	m_inPredict = false;
	m_inFilter = false;

	if (!GetWizard()->m_ReadOnly)
	{
		GetDescendantWindow(IDC_READONLY_IMAGE)->ShowWindow(SW_HIDE);
	}
	else
	{
		//GetDlgItem(IDC_REMOVE)->ShowWindow(SW_HIDE);
		//GetDlgItem(IDC_ADD)->ShowWindow(SW_HIDE);
		//GetDlgItem(IDC_EDIT)->SetWindowText("VIEW");
	}

	m_MinimalFrequence = 2;
	m_bOnlyMainPartOfSpeeches = TRUE;


	UpdateData(FALSE);
	
//	CMorphwizardApp* App = (CMorphwizardApp*)AfxGetApp();
//	App->m_PointerCount[this] = 0;
}