コード例 #1
0
        public void AdjectivePhraseConstructorTest()
        {
            IEnumerable <Word> composedWords = new Word[] { new Adjective("soft"), new Adjective("smooth"), new Adjective("silky") };
            var target = new AdjectivePhrase(composedWords);

            Assert.Equal(target.Words, composedWords);
        }
コード例 #2
0
 /// <summary>
 /// Determines if two AdjectivePhrase are similar.
 /// </summary>
 /// <param name="first">The first AdjectivePhrase</param>
 /// <param name="second">The second AdjectivePhrase</param>
 /// <returns><c>true</c> if the given AdjectivePhrase are similar; otherwise, <c>false</c>.</returns>
 public static Similarity IsSimilarTo(this AdjectivePhrase first, AdjectivePhrase second) =>
 Similarity.FromRatio(
     first.Words.OfAdjective()
     .Zip(second.Words.OfAdjective()).With(IsSimilarTo)
     .Select(s => (bool)s)
     .PercentTrue() / 100
     );
コード例 #3
0
        public void ModifyWithTest()
        {
            var        target = new AdjectivePhrase(new Adjective("tall"));
            IAdverbial adv    = new Adverb("overly");

            target.ModifyWith(adv);
            Check.That(target.AdverbialModifiers).Contains(adv).Only();
        }
コード例 #4
0
        public void BindDescriberTest()
        {
            var         target = new NounPhrase(new ProperPluralNoun("Americans"), new Conjunction("and"), new ProperPluralNoun("Canadians"));
            IDescriptor adj    = new AdjectivePhrase(new CommonSingularNoun("peace"), new PresentParticiple("loving"));

            target.BindDescriptor(adj);
            Check.That(target.Descriptors).Contains(adj);
        }
コード例 #5
0
        public void DescribesTest()
        {
            IEnumerable <Word> composedWords = new Word[] { new Adverb("very"), new Adjective("tall") };
            var     target   = new AdjectivePhrase(composedWords);
            IEntity expected = new CommonSingularNoun("tree");
            IEntity actual;

            target.Describes = expected;
            actual           = target.Describes;
            Assert.Equal(expected, actual);
        }
コード例 #6
0
        public void AdverbialModifiersTest()
        {
            IEnumerable <Word> composedWords = new Word[] { new Adjective("soft"), new Conjunction("and"), new Adjective("silky") };
            var target = new AdjectivePhrase(composedWords);
            IEnumerable <IAdverbial> actual;

            actual = target.AdverbialModifiers;
            Assert.False(actual.Any());
            IAdverbial modifier = new Adverb("very");

            target.ModifyWith(modifier);
            Assert.Contains(modifier, target.AdverbialModifiers);
        }
コード例 #7
0
 /// <summary>
 /// Determines if the provided Adjective is similar to the provided AdjectivePhrase.
 /// </summary>
 /// <param name="first">The Adjective.</param>
 /// <param name="second">The AdjectivePhrase.</param>
 /// <returns>
 /// <c>true</c> if the provided Adjective is similar to the provided AdjectivePhrase;
 /// otherwise, <c>false</c>.
 /// </returns>
 public static Similarity IsSimilarTo(this Adjective first, AdjectivePhrase second) => Similarity.FromBoolean(second.Words.OfAdjective().Any(a => a.IsSimilarTo(first)));
コード例 #8
0
 /// <summary>
 /// Determines if the provided AdjectivePhrase is similar to the provided Adjective.
 /// </summary>
 /// <param name="first">The AdjectivePhrase.</param>
 /// <param name="second">The Adjective.</param>
 /// <returns>
 /// <c>true</c> if the provided AdjectivePhrase is similar to the provided Adjective;
 /// otherwise, <c>false</c>.
 /// </returns>
 public static Similarity IsSimilarTo(this AdjectivePhrase first, Adjective second) => second.IsSimilarTo(first);