Пример #1
0
        private string[] QueryDictionary(string word, bool recurse)
        {
            var tags = tagDictionary.GetTags(word) ?? tagDictionary.GetTags(word.ToLowerInvariant());

            if (recurse)
            {
                if (word.StartsWith("-") && word.Length > 1)
                {
                    tags = QueryDictionary(word.Substring(1), false);
                }
            }

            return(GenderUtil.RemoveGender(tags));
        }
Пример #2
0
        /// <summary>
        /// Determines whether a particular continuation of a sequence is valid.
        /// This is used to restrict invalid sequences such as those used in start/continue tag-based chunking or could be used to implement tag dictionary restrictions.
        /// </summary>
        /// <param name="index">The index in the input sequence for which the new outcome is being proposed.</param>
        /// <param name="inputSequence">The input sequence.</param>
        /// <param name="outcomesSequence">The outcomes so far in this sequence.</param>
        /// <param name="outcome">The next proposed outcome for the outcomes sequence.</param>
        /// <returns><c>true</c> if the sequence would still be valid with the new outcome, <c>false</c> otherwise.</returns>
        public bool ValidSequence(int index, string[] inputSequence, string[] outcomesSequence, string outcome)
        {
            if (dictionary == null)
            {
                return(true);
            }

            var tags = dictionary.GetTags(inputSequence[index]);

            if (tags == null)
            {
                return(true);
            }
            return(Array.IndexOf(tags, outcome) != -1);
        }