Exemplo n.º 1
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
     );
Exemplo n.º 2
0
        /// <summary>Determines if two IAggregateEntity instances are similar.</summary>
        /// <param name="first">The first IAggregateEntity</param>
        /// <param name="second">The second IAggregateEntity</param>
        /// <returns>
        /// <c>true</c> if the given IAggregateEntity instances are similar; otherwise, <c>false</c>.
        /// </returns>
        private static Similarity IsSimilarTo(this IAggregateEntity first, IAggregateEntity second)
        {
            var simResults = from e1 in first
                             from e2 in second
                             select e1.IsSimilarTo(e2);

            return(Similarity.FromRatio(simResults.Select(x => x.Boolean).PercentTrue() / 100));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determines if two <see cref="VerbPhrase"/>s are similar.
        /// </summary>
        /// <param name="first">The first VerbPhrase</param>
        /// <param name="second">The second VerbPhrase</param>
        /// <returns> <c>true</c> if the given VerbPhrases are similar; otherwise, <c>false</c>.</returns>
        public static Similarity IsSimilarTo(this VerbPhrase first, VerbPhrase second)
        {
            //Look into refining this

            var results = from v1 in first.Words.OfVerb()
                          from v2 in second.Words.OfVerb()
                          select(bool) v1.IsSimilarTo(v2);

            var ratio = results.PercentTrue() / 100;

            return(Similarity.FromRatio(ratio));

            // TODO: make this fuzzier.

            //return new Similarity(leftHandVerbs.Count == rightHandVerbs.Count &&
            //    leftHandVerbs.Zip(rightHandVerbs, (x, y) => x.IsSynonymFor(y)).All(areSyonyms => areSyonyms)
            //);
        }
Exemplo n.º 4
0
 /// <summary>Determines if two NounPhrases are similar.</summary>
 /// <param name="first">The first NounPhrase</param>
 /// <param name="second">The second NounPhrase</param>
 /// <returns><c>true</c> if the given NounPhrases are similar; otherwise, <c>false</c>.</returns>
 public static Similarity IsSimilarTo(this NounPhrase first, NounPhrase second) => Similarity.FromRatio(GetSimilarityRatio(first, second));