Пример #1
0
        private string SelectPostfix(Noun word, InflectionCase aCase, DecliantionNumber amount,
                                     string root, params string[] postfixes)
        {
            foreach (NounPostfixToken token in this.endings)
            {
                if (token.Declination == word.DeclinationType &&
                    token.Genre == word.Genre && token.DecliantionNumber == amount &&
                    token.InflectionCase == aCase)
                {
                    if (token.Postfixes.Length > 1)
                    {
                        int indx = NounGrammar.GetPostFixIndex(word, amount, aCase);

                        if (indx < token.Postfixes.Length)
                        {
                            return(token.Postfixes[indx]);
                        }
                        else
                        {
                            return("");
                        }
                    }
                    else
                    {
                        return(token.Postfixes[0]);
                    }
                }
            }

            return("");           //postfixes[0];
        }
Пример #2
0
        void edit_PostfixButtonPressed(object sender, EventArgs e)
        {
            ControlNounCaseEdit edit = (ControlNounCaseEdit)sender;

            NounGrammar.SetPostIndex(this.edited, edit.InflectionCase, edit.DecliantionNumber, edit.PostFixIndex);
            this.RefreshFields();
        }
Пример #3
0
        private void SetEdited(Panel targetPanel, Noun noun)
        {
            foreach (Control ctrl in targetPanel.Controls)
            {
                if (!(ctrl is ControlNounCaseEdit))
                {
                    continue;
                }

                ControlNounCaseEdit edit = ctrl as ControlNounCaseEdit;
                if (noun == null)
                {
                    edit.Value = "";
                }
                else
                {
                    string form = NounDecliner.Decliner.MakeWord(
                        noun, edit.InflectionCase, edit.DecliantionNumber);
                    edit.Value     = form;
                    edit.PostFixes = NounDecliner.Decliner.GetPostFix(noun.Genre, noun.DeclinationType,
                                                                      edit.InflectionCase, DecliantionNumber.Singular).Split(' ');
                    edit.PostFixIndex = NounGrammar.GetPostFixIndex(noun, DecliantionNumber.Singular, edit.InflectionCase);
                }
            }
        }
Пример #4
0
        void edit_IrregularSet(object sender, EventArgs e)
        {
            ControlNounCaseEdit edit  = (ControlNounCaseEdit)sender;
            WordToken           token = new WordToken(edit.Value, edit.InflectionCase, edit.DecliantionNumber);

            NounGrammar.UpdateIrregular(this.edited, token);
            this.RefreshFields();
        }
Пример #5
0
        public string MakeWord(Noun word, InflectionCase aCase, DecliantionNumber amount)
        {
            if (aCase == InflectionCase._Unknown || amount == DecliantionNumber._Unknown)
            {
                return(null);
            }

            if ((amount == DecliantionNumber.Singular && !word.CanBeSingular) ||
                (amount == DecliantionNumber.Plural && !word.CanBePlural))
            {
                return(null);
            }

            if (word.IsConstant)
            {
                return(word.Root);
            }

            if (word.IsException)
            {
                string except = NounGrammar.GetForm(word, aCase, amount);
                if (except != null)
                {
                    return(except); // else - calculate own...
                }
            }

            string prefix  = "";
            string postfix = "";
            string root    = ((aCase != InflectionCase.Nominative || amount != DecliantionNumber.Singular) &&
                              !string.IsNullOrEmpty(word.RootOther))
                ? word.RootOther : word.Root;

            #region Switching

            postfix = this.SelectPostfix(word, aCase, amount, root);
            if (postfix == "*")
            {
                postfix = "";
            }

#if SW
            switch (word.Genre)
            {
                #region MasculineLife

            case GrammaticalGender.MasculineLife:
            {
                switch (aCase)
                {
                case InflectionCase.Nominative:             // Mianownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Genitive:             //Dopełniacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Dative:             // Celownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Accusative:             // Biernik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Ablative:             // Narzędnik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Locative:             // Miejscownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Vocative:             //Wołacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }
                }

                break;
            }

                #endregion

                #region MasculinePerson

            case GrammaticalGender.MasculinePerson:
            {
                switch (aCase)
                {
                case InflectionCase.Nominative:             // Mianownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Genitive:             //Dopełniacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Dative:             // Celownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Accusative:             // Biernik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Ablative:             // Narzędnik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Locative:             // Miejscownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Vocative:             //Wołacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

                #endregion

                #region MasculineThing

            case GrammaticalGender.MasculineThing:
            {
                switch (aCase)
                {
                case InflectionCase.Nominative:             // Mianownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;                         // Nothing
                    }

                    case DecliantionNumber.Plural:
                    {
                        root    = Soften(word, root);
                        postfix = "y";
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Genitive:             //Dopełniacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        root = Soften(word, root);
                        //postfix = SelectPostfix(word, root, "a", "u");
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        root = Soften(word, root);
                        //postfix = SelectPostfix(word, root, "y", "ów");
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Dative:             // Celownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Accusative:             // Biernik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Ablative:             // Narzędnik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Locative:             // Miejscownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Vocative:             //Wołacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

                #endregion

                #region Feminine

            case GrammaticalGender.Feminine:
            {
                switch (aCase)
                {
                case InflectionCase.Nominative:             // Mianownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Genitive:             //Dopełniacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Dative:             // Celownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Accusative:             // Biernik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Ablative:             // Narzędnik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Locative:             // Miejscownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Vocative:             //Wołacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

                #endregion

                #region Neuter

            case GrammaticalGender.Neuter:
            {
                switch (aCase)
                {
                case InflectionCase.Nominative:             // Mianownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Genitive:             //Dopełniacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Dative:             // Celownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Accusative:             // Biernik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Ablative:             // Narzędnik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Locative:             // Miejscownik
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }

                case InflectionCase.Vocative:             //Wołacz
                {
                    switch (amount)
                    {
                    case DecliantionNumber.Singular:
                    {
                        break;
                    }

                    case DecliantionNumber.Plural:
                    {
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

                #endregion
            }
#endif

            #endregion

            return(string.Format("{0}{1}{2}", prefix, root, postfix));
        }