/// <summary>
        /// Define the term with which to compare string properties to
        /// </summary>
        /// <param name="term">The term to perform the Levenshtein distance against</param>
        /// <returns></returns>
        public IEnumerable <ILevenshteinDistance <T> > ComparedTo(string term)
        {
            var stringProperty = this.Properties[0];
            var levenshteinDistanceExpression = EnumerableExpressionHelper.CalculateLevenshteinDistance(stringProperty, term);
            var buildExpression  = EnumerableExpressionHelper.ConstructLevenshteinResult <T>(levenshteinDistanceExpression, this.FirstParameter);
            var selectExpression = Expression.Lambda <Func <T, LevenshteinDistance <T> > >(buildExpression, this.FirstParameter).Compile();
            var convertedSource  = this.Source.Select(selectExpression.Invoke);

            return(new EnumerableLevenshteinCompare <ILevenshteinDistance <T> >(convertedSource));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Define the term with which to compare string properties to
        /// </summary>
        /// <param name="stringProperties">The properties to perform the Levenshtein distance against</param>
        /// <returns></returns>
        public IEnumerable <ILevenshteinDistance <T> > ComparedTo(params Expression <Func <T, string> >[] stringProperties)
        {
            var targetProperties = stringProperties.Select(AlignParameter).ToArray();

            var levenshteinDistanceExpression = EnumerableExpressionHelper.CalculateLevenshteinDistance(Properties, targetProperties);
            var buildExpression  = EnumerableExpressionHelper.ConstructLevenshteinResult <T>(levenshteinDistanceExpression, FirstParameter);
            var selectExpression = Expression.Lambda <Func <T, LevenshteinDistance <T> > >(buildExpression, FirstParameter).Compile();
            var convertedSource  = Source.Select(selectExpression.Invoke);

            return(new EnumerableLevenshteinCompare <ILevenshteinDistance <T> >(convertedSource));
        }