Exemplo n.º 1
0
    public static SqlString GetString(string str, int numRemoveLetters)
    {
        string stringValue = UserDefinedFunctions.CleanUpProductName(str);
        //string stringValue = str.Replace("  ", " ").Trim(); // dbo.Split

        string stringSortValue = UserDefinedFunctions.CleanUpProductName(UserDefinedFunctions.SortString(stringValue, " ", numRemoveLetters));

        if (stringSortValue == null)
        {
            stringSortValue = "0";
        }

        StringBuilder res = new StringBuilder();

        // Words
        var matches = Regex.Matches(stringSortValue, @"[\D']*");

        foreach (Match match in matches)
        {
            res.Append(match.Value.TrimStart().TrimEnd() + " ").ToString();
        }

        // Result
        if (res == null || res.ToString().Trim() == "")
        {
            return("");
        }
        else
        {
            return(res.ToString().Trim());
        }
    }
Exemplo n.º 2
0
    public static int SortLevenshteinDistance(string firstString, string secondString, Boolean ignoreCase, int numRemoveLetters)
    {
        int defaultMatch = 0;

        if ((firstString != null) || (secondString != null))
        {
            //Use SortString Function to sort String and remove letters
            string sortFirstString  = UserDefinedFunctions.SortString(firstString, " ", numRemoveLetters);
            string sortSecondString = UserDefinedFunctions.SortString(secondString, " ", numRemoveLetters);

            int cSortLevenshteinDistance = UserDefinedFunctions.LevenshteinDistance(sortFirstString, sortSecondString, ignoreCase);

            return(cSortLevenshteinDistance);
        }
        return(defaultMatch);
    }
Exemplo n.º 3
0
    public static Double SortJaroWinklerDistance(String firstWord, String secondWord, int numRemoveLetters)
    {
        double defaultMismatchScore = 0.0;

        if ((firstWord != null) && (secondWord != null))
        {
            //Use SortString Function to sort String
            String sortedFirstString  = UserDefinedFunctions.SortString(firstWord, " ", numRemoveLetters);
            String sortedSecondString = UserDefinedFunctions.SortString(secondWord, " ", numRemoveLetters);

            double cSortJaroWinklerDistance = UserDefinedFunctions.JaroWinklerDistance(sortedFirstString, sortedSecondString);

            // Return value Sorted JaroWinklerDistance
            return(cSortJaroWinklerDistance);
        }
        return(defaultMismatchScore);
    }