Demo entry 6207957

deneme

   

Submitted by anonymous on Oct 12, 2016 at 08:10
Language: C#. Code size: 818 Bytes.

using System;
using Microsoft.SqlServer.Server;

namespace SqlLibrary.Text
{
    public class StringCompare
    {
        [SqlProcedure]
        public static double GetTextSimilarity(
            string inputOne, string inputTwo
        )
        {
            if (inputOne == null)
                throw new ArgumentNullException(nameof(inputOne));

            if (inputTwo == null)
                throw new ArgumentNullException(nameof(inputTwo));

            if (inputOne == string.Empty && inputTwo == string.Empty)
                return 1;

            int distance = LevenshteinDistance
                .GetLevenshteinDistance(inputOne, inputTwo);

            return 1.0 - distance / 
                (double)Math.Max(inputOne.Length, inputTwo.Length);
        }
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).