Exemplo n.º 1
0
 private static string CoNameToPadej(EPadej _padej, CoName _coName, bool _isCreature, ESex _sex)
 {
     if (_coName == null)
     {
         return("");
     }
     return("-" + NounToPadej(_padej, _coName.Text, _isCreature, _sex));
 }
Exemplo n.º 2
0
 public static string To(this Noun _noun, EPadej _padej, bool _withRandom = true)
 {
     if (_withRandom && _noun.AlsoKnownAs != null && YesNo())
     {
         return(_noun.AlsoKnownAs.To(_padej));
     }
     if (_noun.CoName != null)
     {
     }
     return(_noun.Adjective.To(_padej, _noun.Sex, _noun.IsCreature)
            + NounToPadej(_padej, _noun.Text, _noun.IsCreature, _noun.Sex)
            + CoNameToPadej(_padej, _noun.CoName, _noun.IsCreature, _noun.Sex)
            + OfSomethingToPadej(_noun.OfSomething)
            + _noun.Immutable.ToText());
 }
Exemplo n.º 3
0
        private static string PluralNounToPadej(EPadej _padej, string _noun, bool _isCreature, ESex _sex)
        {
            bool мягкий;
            var  last = _noun[_noun.Length - 1];

            string text;

            switch (last)
            {
            case 'ы':
                мягкий = false;
                text   = _noun.Substring(0, _noun.Length - 1);
                break;

            case 'и':
                мягкий = true;
                text   = _noun.Substring(0, _noun.Length - 1);
                break;

            default:
                throw new ArgumentOutOfRangeException("last");
            }
            switch (_sex)
            {
            case ESex.PLURAL:
                if (мягкий)
                {
                    text += new[] { "и", "ей", "ям", "ей", "ами", "ях" }[(int)_padej];
                }
                else
                {
                    text += new[] { "ы", "ов", "ам", "ов", "ами", "ах" }[(int)_padej];
                }

                break;

            default:
                throw new ArgumentOutOfRangeException("_sex");
            }
            return(text);
        }
Exemplo n.º 4
0
		public static string NounToPadej(EPadej _target, string _noun, bool _isCreature, ESex _sex)
		{
			if(_target==EPadej.IMEN) return _noun;

			Dictionary<EPadej, string> dictionary;
			if(m_iskluchenia.TryGetValue(_noun, out dictionary))
			{
				return dictionary[_target];
			}

			if (_sex == ESex.PLURAL || _sex == ESex.PLURAL_FEMALE)
			{
				return PluralNounToPadej(_target, _noun, _isCreature, _sex);
			}

			bool мягкий;
			var noun = _noun;
			var sklon = GetSklon(ref noun, _isCreature, _sex, out мягкий);

			if(sklon<0)
			{
				return _noun;
			}

			if (sklon == 1 && _sex == ESex.FEMALE && _noun.EndsWith("ка"))
			{
				мягкий = true;
			}
			var твердый = !мягкий;
			string value;
			if (m_padejDict[sklon][_sex][_target].TryGetValue(твердый, out value))
			{
				noun += value;
			}
			else
			{

				switch (sklon)
				{
					case 1:
						throw new ApplicationException("не должно сюда попасть");
					case 2:
						switch (_target)
						{
							case EPadej.ROD:
								noun += твердый ? "а" : "я";
								break;
							case EPadej.DAT:
								noun += твердый ? "у" : "ю";
								break;
							case EPadej.VIN:
								if (_sex == ESex.MALE)
								{
									if (_isCreature)
									{
										noun += твердый ? "а" : "я";
									}
									else
									{
										noun = _noun;
									}
								}
								else
								{
									noun += _isCreature ? (твердый ? "а" : "я") : (твердый ? "о" : "е");
								}
								break;
							case EPadej.TVOR:
								noun += твердый ? "ом" : "ем";
								break;
							case EPadej.PREDL:
								noun += "е";
								break;
							default:
								throw new ArgumentOutOfRangeException("_target");
						}
						break;
					case 3:
						switch (_target)
						{
							case EPadej.ROD:
								noun += "и";
								break;
							case EPadej.DAT:
								noun += "и";
								break;
							case EPadej.VIN:
								noun += "ь";
								break;
							case EPadej.TVOR:
								noun += "ью";
								break;
							case EPadej.PREDL:
								noun += "и";
								break;
							default:
								throw new ArgumentOutOfRangeException("_target");
						}
						break;
				}
			}
			
			return noun;
		}
Exemplo n.º 5
0
		public static string To(this Essence _essence, EPadej _padej, bool _withRandom = true)
		{
			return _essence.Name.To(_padej, _withRandom);
		}
Exemplo n.º 6
0
		private static string PluralNounToPadej(EPadej _padej, string _noun, bool _isCreature, ESex _sex)
		{
			bool мягкий;
			var last = _noun[_noun.Length - 1];

			string text;
			switch (last)
			{
				case 'ы':
					мягкий = false;
					text = _noun.Substring(0, _noun.Length - 1);
					break;
				case 'и':
					мягкий = true;
					text = _noun.Substring(0, _noun.Length - 1);
					break;
				default:
					throw new ArgumentOutOfRangeException("last");
			}
			switch (_sex)
			{
				case ESex.PLURAL:
					if(мягкий)
					{
						text += new[] { "и", "ей", "ям", "ей", "ами", "ях" }[(int)_padej];	
					}
					else
					{
						text += new[] { "ы", "ов", "ам", "ов", "ами", "ах" }[(int)_padej];	
					}
					
					break;
				default:
					throw new ArgumentOutOfRangeException("_sex");
			}
			return text;
		}
Exemplo n.º 7
0
		public static string To(this Adjective _adj, EPadej _padej, ESex _sex, bool _isCreature)
		{
			if (_adj == null) return "";
			var text = _adj.Text;

			if (text == null)
			{
				return "";
			}

			if (_padej == EPadej.VIN && !_isCreature)
			{
				_padej = EPadej.IMEN;
			}
			var padej = (int)_padej;

			if (text.EndsWith("ый"))
			{
				text = text.Substring(0, text.Length - 2);
				switch (_sex)
				{
					case ESex.MALE:
						text += new[] { "ый", "ого", "ому", "ого", "ым", "ом" }[padej];
						break;
					case ESex.FEMALE:
						text += new[] { "ая", "ой", "ой", "ую", "ой", "ой" }[padej];
						break;
					case ESex.IT:
						text += new[] { "ое", "ого", "ому", "ого", "ым", "ом" }[padej];
						break;
					case ESex.PLURAL:
						text += new[] { "ые", "ых", "ым", "ых", "ыми", "ых" }[padej];
						break;
					default:
						throw new ArgumentOutOfRangeException("_sex");
				}
			}
			else if (text.EndsWith("ий"))
			{
				text = text.Substring(0, text.Length - 2);
				switch (_sex)
				{
					case ESex.MALE:
						text += new[] { "ий", "ого", "ому", "ого", "им", "ом" }[padej];
						break;
					case ESex.FEMALE:
						text += new[] { "ая", "ой", "ой", "юю", "ой", "ой" }[padej];
						break;
					case ESex.IT:
						text += new[] { "ое", "ого", "ому", "ого", "им", "ом" }[padej];
						break;
					case ESex.PLURAL:
						text += new[] { "ие", "их", "им", "их", "ими", "их" }[padej];
						break;
					default:
						throw new ArgumentOutOfRangeException("_sex");
				}
			}
			else if (text.EndsWith("ой"))
			{
				text = text.Substring(0, text.Length - 2);
				switch (_sex)
				{
					case ESex.MALE:
						text += new[] { "ой", "ого", "ому", "ого", "ым", "ом" }[padej];
						break;
					case ESex.FEMALE:
						text += new[] { "ая", "ой", "ой", "ую", "ой", "ой" }[padej];
						break;
					case ESex.IT:
						text += new[] { "ое", "ого", "ому", "ого", "ым", "ом" }[padej];
						break;
					case ESex.PLURAL:
						text += new[] { "ые", "ых", "ым", "ых", "ыми", "ых" }[padej];
						break;
					default:
						throw new ArgumentOutOfRangeException("_sex");
				}
			}
			else
			{
				throw new NotImplementedException();
			}

			return text + " ";
		}
Exemplo n.º 8
0
		private static string CoNameToPadej(EPadej _padej, CoName _coName, bool _isCreature, ESex _sex)
		{
			if (_coName==null)
			{
				return "";
			}
			return "-" + NounToPadej(_padej, _coName.Text, _isCreature, _sex);
		}
Exemplo n.º 9
0
		public static string To(this Noun _noun, EPadej _padej, bool _withRandom = true)
		{
			if(_withRandom && _noun.AlsoKnownAs!=null && YesNo())
			{
				return _noun.AlsoKnownAs.To(_padej);
			}
			if (_noun.CoName!=null)
			{
				
			}
			return _noun.Adjective.To(_padej, _noun.Sex, _noun.IsCreature) 
				+ NounToPadej(_padej, _noun.Text, _noun.IsCreature, _noun.Sex)
				+ CoNameToPadej(_padej, _noun.CoName, _noun.IsCreature, _noun.Sex)
				+ OfSomethingToPadej(_noun.OfSomething)
				+ _noun.Immutable.ToText();
		}
Exemplo n.º 10
0
        public static string NounToPadej(EPadej _target, string _noun, bool _isCreature, ESex _sex)
        {
            if (_target == EPadej.IMEN)
            {
                return(_noun);
            }

            Dictionary <EPadej, string> dictionary;

            if (m_iskluchenia.TryGetValue(_noun, out dictionary))
            {
                return(dictionary[_target]);
            }

            if (_sex == ESex.PLURAL || _sex == ESex.PLURAL_FEMALE)
            {
                return(PluralNounToPadej(_target, _noun, _isCreature, _sex));
            }

            bool мягкий;
            var  noun  = _noun;
            var  sklon = GetSklon(ref noun, _isCreature, _sex, out мягкий);

            if (sklon < 0)
            {
                return(_noun);
            }

            if (sklon == 1 && _sex == ESex.FEMALE && _noun.EndsWith("ка"))
            {
                мягкий = true;
            }
            var    твердый = !мягкий;
            string value;

            if (m_padejDict[sklon][_sex][_target].TryGetValue(твердый, out value))
            {
                noun += value;
            }
            else
            {
                switch (sklon)
                {
                case 1:
                    throw new ApplicationException("не должно сюда попасть");

                case 2:
                    switch (_target)
                    {
                    case EPadej.ROD:
                        noun += твердый ? "а" : "я";
                        break;

                    case EPadej.DAT:
                        noun += твердый ? "у" : "ю";
                        break;

                    case EPadej.VIN:
                        if (_sex == ESex.MALE)
                        {
                            if (_isCreature)
                            {
                                noun += твердый ? "а" : "я";
                            }
                            else
                            {
                                noun = _noun;
                            }
                        }
                        else
                        {
                            noun += _isCreature ? (твердый ? "а" : "я") : (твердый ? "о" : "е");
                        }
                        break;

                    case EPadej.TVOR:
                        noun += твердый ? "ом" : "ем";
                        break;

                    case EPadej.PREDL:
                        noun += "е";
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("_target");
                    }
                    break;

                case 3:
                    switch (_target)
                    {
                    case EPadej.ROD:
                        noun += "и";
                        break;

                    case EPadej.DAT:
                        noun += "и";
                        break;

                    case EPadej.VIN:
                        noun += "ь";
                        break;

                    case EPadej.TVOR:
                        noun += "ью";
                        break;

                    case EPadej.PREDL:
                        noun += "и";
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("_target");
                    }
                    break;
                }
            }

            return(noun);
        }
Exemplo n.º 11
0
 public static string To(this Essence _essence, EPadej _padej, bool _withRandom = true)
 {
     return(_essence.Name.To(_padej, _withRandom));
 }
Exemplo n.º 12
0
        public static string To(this Adjective _adj, EPadej _padej, ESex _sex, bool _isCreature)
        {
            if (_adj == null)
            {
                return("");
            }
            var text = _adj.Text;

            if (text == null)
            {
                return("");
            }

            if (_padej == EPadej.VIN && !_isCreature)
            {
                _padej = EPadej.IMEN;
            }
            var padej = (int)_padej;

            if (text.EndsWith("ый"))
            {
                text = text.Substring(0, text.Length - 2);
                switch (_sex)
                {
                case ESex.MALE:
                    text += new[] { "ый", "ого", "ому", "ого", "ым", "ом" }[padej];
                    break;

                case ESex.FEMALE:
                    text += new[] { "ая", "ой", "ой", "ую", "ой", "ой" }[padej];
                    break;

                case ESex.IT:
                    text += new[] { "ое", "ого", "ому", "ого", "ым", "ом" }[padej];
                    break;

                case ESex.PLURAL:
                    text += new[] { "ые", "ых", "ым", "ых", "ыми", "ых" }[padej];
                    break;

                default:
                    throw new ArgumentOutOfRangeException("_sex");
                }
            }
            else if (text.EndsWith("ий"))
            {
                text = text.Substring(0, text.Length - 2);
                switch (_sex)
                {
                case ESex.MALE:
                    text += new[] { "ий", "ого", "ому", "ого", "им", "ом" }[padej];
                    break;

                case ESex.FEMALE:
                    text += new[] { "ая", "ой", "ой", "юю", "ой", "ой" }[padej];
                    break;

                case ESex.IT:
                    text += new[] { "ое", "ого", "ому", "ого", "им", "ом" }[padej];
                    break;

                case ESex.PLURAL:
                    text += new[] { "ие", "их", "им", "их", "ими", "их" }[padej];
                    break;

                default:
                    throw new ArgumentOutOfRangeException("_sex");
                }
            }
            else if (text.EndsWith("ой"))
            {
                text = text.Substring(0, text.Length - 2);
                switch (_sex)
                {
                case ESex.MALE:
                    text += new[] { "ой", "ого", "ому", "ого", "ым", "ом" }[padej];
                    break;

                case ESex.FEMALE:
                    text += new[] { "ая", "ой", "ой", "ую", "ой", "ой" }[padej];
                    break;

                case ESex.IT:
                    text += new[] { "ое", "ого", "ому", "ого", "ым", "ом" }[padej];
                    break;

                case ESex.PLURAL:
                    text += new[] { "ые", "ых", "ым", "ых", "ыми", "ых" }[padej];
                    break;

                default:
                    throw new ArgumentOutOfRangeException("_sex");
                }
            }
            else
            {
                throw new NotImplementedException();
            }

            return(text + " ");
        }
Exemplo n.º 13
0
 public string GetString(EPadej _padej, params Noun[] _nouns)
 {
     return(string.Join(", ", _nouns.Select(e => e.To(_padej))));
 }
Exemplo n.º 14
0
		public string GetString(EPadej _padej, params Noun[] _nouns)
		{
			return string.Join(", ", _nouns.Select(e => e.To(_padej)));
		}