예제 #1
0
        /// <summary>
        /// Evaluates a <c>pron</c> wildcard, replacing the string with the adequate pronoun
        /// regarding the last token found.
        /// </summary>
        /// <param name="w">The wilcard to find a replacement for</param>
        /// <returns>An appropiate replacement for the wildcard.</returns>
        private void EvaluatePronoun(Wildcard w)
        {
            Wildcard prev = null;
            string   keycode;
            string   keyword;

            for (int i = currentWildcardIx - 1; i >= 0; --i)
            {
                keycode = textWildcards [i].Keycode;
                keyword = wildcards [keycode].Keyword;
                if ((keyword != null) && keyword.IsAnyOf("name", "male", "female"))
                {
                    // prev = textWildcards [i];
                    prev = wildcards [keycode];
                    break;
                }
            }
            for (int i = currentWildcardIx - 1; (prev == null) && (i >= 0); --i)
            {
                keycode = textWildcards [i].Keycode;
                keyword = wildcards [keycode].Keyword;
                if ((keyword != null) && keyword.IsAnyOf("void", "pron"))
                {
                    continue;
                }
                // prev = textWildcards [i];
                prev = wildcards [keycode];
                break;
            }

            w.Replacement = new NamedTaskElement(Pronoun.FromWildcard(w, prev));
        }