Beispiel #1
0
        public static SqlDouble sorensenDistance(SqlString string1, SqlString string2)
        {
            var compString = new CompStrings(string1, string2);
            var sdist      = new StringDist(compString.from, compString.to);

            return(new SqlDouble(sdist.sorensenDistance()));
        }
        public static IEnumerable GetStringDistances(String query) {

            ArrayList returnValues = new ArrayList();

            using (SqlConnection connection = new SqlConnection("context connection=true")) {

                connection.Open();

                using (SqlCommand dataTable = new SqlCommand(query, connection)) {

                    using (SqlDataReader row = dataTable.ExecuteReader()) {
                        while (row.Read()) {

                            CompStrings comparisonStrings = new CompStrings(row.GetSqlString(0), row.GetSqlString(1));
                            StringDist dists = new StringDist(comparisonStrings.from, comparisonStrings.to);
                            returnValues.Add(new AllDistanceMetrics(comparisonStrings.from, comparisonStrings.to, 
                                dists.hamming(), dists.jaccard(), dists.jaro(), dists.jaroWinkler(), 
                                dists.levenshtein(), dists.levenshteinLower(), dists.levenshteinUpper(),
                                dists.levenshteinNormalized(), dists.overlap(), dists.ratcliff(), dists.sorensenIndex(),
                                dists.sorensenDistance(), dists.tanimotoCoefficient()));
                        }
                    }
                }
            }
            return returnValues;
        }
Beispiel #3
0
        public static IEnumerable GetStringDistances(String query)
        {
            ArrayList returnValues = new ArrayList();

            using (SqlConnection connection = new SqlConnection("context connection=true")) {
                connection.Open();

                using (SqlCommand dataTable = new SqlCommand(query, connection)) {
                    using (SqlDataReader row = dataTable.ExecuteReader()) {
                        while (row.Read())
                        {
                            CompStrings comparisonStrings = new CompStrings(row.GetSqlString(0), row.GetSqlString(1));
                            StringDist  dists             = new StringDist(comparisonStrings.from, comparisonStrings.to);
                            returnValues.Add(new AllDistanceMetrics(comparisonStrings.from, comparisonStrings.to,
                                                                    dists.hamming(), dists.jaccard(), dists.jaro(), dists.jaroWinkler(),
                                                                    dists.levenshtein(), dists.levenshteinLower(), dists.levenshteinUpper(),
                                                                    dists.levenshteinNormalized(), dists.overlap(), dists.ratcliff(), dists.sorensenIndex(),
                                                                    dists.sorensenDistance(), dists.tanimotoCoefficient()));
                        }
                    }
                }
            }
            return(returnValues);
        }
 public static SqlDouble sorensenDistance(SqlString string1, SqlString string2)
 {
     var compString = new CompStrings(string1, string2);
     var sdist = new StringDist(compString.from, compString.to);
     return new SqlDouble(sdist.sorensenDistance());
 }