コード例 #1
0
ファイル: RTENoun.cs プロジェクト: YourChance/elundi.diplom
		public Slovo Translate(Predlozhenie pr,int place)
		{
			Slovo analyzed = pr[place];
			
			TranslateOsnova(ref pr,ref analyzed);
			Chislo(ref analyzed);
			Rod(ref analyzed);
			Padezh(ref pr,place,ref analyzed);
			
			pr.SetSlovo(analyzed,place);
			
			return analyzed;
		}
コード例 #2
0
		public Predlozhenie MorfAnalyze(Predlozhenie pr)
		{
			Open();
			Predlozhenie pred = pr;
			
			for(int j=0;j<pred.Count;j++)
			{
				Slovo s = (Slovo)pred[j];
				string slovo = s.rSlovo;
				string flextype = "";
				string grtype = "";
				slovo = slovo.ToUpper();
				
				bool cifra = false;
				
				try
				{
					int i = int.Parse(slovo);
					cifra = true;					
				}
				catch
				{
					cifra = false;
				}
				
				if(!cifra)
				{
				
					for(int i=slovo.Length;i>0;i--)
					{
						string osnova = slovo.Substring(0,i);
						ArrayList ar = GetDict(osnova);
						bool br = false;
						if(ar.Count>0)
						{
							//System.Windows.Forms.MessageBox.Show(osnova);
							foreach(string flexid in ar)
							{
							
							//	Console.WriteLine(osnova);
							string flex = GetFlex(flexid.Split(';')[0]);
						//System.Windows.Forms.MessageBox.Show(flexid.ToString());
								foreach(string f in flex.Split('%'))
								{
									if(f!="")
									{
										if(osnova+f.Split('*')[0]==slovo)
										{
										//	System.Windows.Forms.MessageBox.Show(osnova+flex.Split('%')[1].Split('*')[0],"Начальная форма: ");
											s.eSlovo = (osnova+flex.Split('%')[1].Split('*')[0]).ToLower();
										//	System.Windows.Forms.MessageBox.Show(f.Split('*')[1],"Тип флексии: ");
											flextype = f.Split('*')[1];
											grtype = flexid.Split(';')[1];
											br = true;
											break;
										}
									}
									if(br)
										break;
								}
							}						
						}
						if(br)
							break;
					}
					AnalyzeGramTab(ref s,flextype,grtype);
					pr.SetSlovo(s,j);
					if(s.chastRechi == ChastRechi.Suschestvitelnoe)
						pr.SetSlovo(PostAnalyzePadezh(pr,j),j);
				}
				else 
				{
					s.eSlovo = s.rSlovo;
					s.chastRechi = ChastRechi.Znak;
					pr.SetSlovo(s,j);
				}
				if(this.Tick != null)
					Tick(this,null);
			}
			
			Close();
			
			return pr;
		}
コード例 #3
0
ファイル: RTENoun.cs プロジェクト: YourChance/elundi.diplom
		public void Padezh(ref Predlozhenie pr,int place, ref Slovo slovo)
		{
			string ppred = "";
			
			switch(slovo.ruSlovo.ruPadezh)
			{
				case RuPadezh.Imenitelniy:
					break;
				case RuPadezh.Roditelniy:
					ppred = "FQV";
					break;
				case RuPadezh.Vinitelniy:
					ppred = "FF";
					break;
				case RuPadezh.Datelniy:
					ppred = "FZP";
					break;
				case RuPadezh.Tvoritelniy:
					ppred = "FT";
					break;
				case RuPadezh.Predlozhniy:
					ppred = "FZJ";
					break;
			}
			
			int i = place-1;
			
			while(i>0 && (pr[i].chastRechi == ChastRechi.Prichastie || pr[i].chastRechi == ChastRechi.Prilagatelnoe || pr[i].chastRechi == ChastRechi.Mestoimenie))
			{
				i= i-1;
			}
			
			if(i>=0 && pr[i].chastRechi != ChastRechi.Predlog)
			{
				Slovo ts = pr[i];
				ts.eSlovo = ts.eSlovo + " "+ppred;
				pr.SetSlovo(ts,i);
			}
			else
			{
				if(i>=0 && pr[i].eSlovo != ppred)
				{
					Slovo ts = pr[i];
					ts.eSlovo = ts.eSlovo + " "+ppred;
					pr.SetSlovo(ts,i);
				}
			}
		}