public static bool AnalyzeNominalPhrase(EvaluationContext <Word> evaluationContext, Evaluator <Word, SentenceContext> evaluator) { Word noun = null; var adjectives = new List <Word>(); Word determinant = null; foreach (var word in evaluationContext.Words.Select((value, index) => new { value, index })) { if (word.index == 0 && word.value.KnownMatchingCategories.Any(category => category.Type == WordCategoryType.Determinant)) { determinant = word.value; } else if (word.value.MayBe(WordCategoryType.Noun, WordCategoryType.ProperNoun) && noun == null) { noun = word.value; } else if (word.value.MayBe(WordCategoryType.Adjective)) { adjectives.Add(word.value); } else { throw new UnrecognizedPhraseException(); } } evaluationContext.AppendPartList(new NominalPhrase(determinant, noun, adjectives)); return(true); }