RTDealsScanerEngine.Similarity.sim C# (CSharp) Method

sim() public method

public sim ( String str1, String str2 ) : double
str1 String
str2 String
return double
        public double sim(String str1, String str2)
        {
            int ld = LD(str1, str2);
            return 1 - (double)ld / Math.Max(str1.Length, str2.Length);
        }

Usage Example

        public static void DuplicateResult(int SimiPecentage)
        {
            DateTime starttime = DateTime.Now;
            DataSet ds = GetRtDealsDataSet();
            Similarity s = new Similarity();
            int Total = 0;
            if (ds != null)
            {
                string Title = "";
                string SourceID = "";
                string DealsID = "";
                int Percentage = 0;

                foreach (DataRow dr in ds.Tables["rssdeals"].Rows)
                {
                    Title = dr["Title"].ToString();
                    SourceID = dr["SourceID"].ToString();
                    DealsID = dr["dealsID"].ToString();

                    foreach (DataRow drr in ds.Tables["rssdeals"].Rows)
                    {
                        string Title1 = "";
                        string SourceID1 = "";
                        string DealsID1 = "";
                        Title1 = drr["Title"].ToString();
                        SourceID1 = drr["SourceID"].ToString();
                        DealsID1 = drr["dealsID"].ToString();
                        if ((DealsID != DealsID1) && (Convert.ToInt32(DealsID) < Convert.ToInt32(DealsID1)))
                        {
                            Percentage = Convert.ToInt16(s.sim(Title, Title1) * 100);
                            if (Percentage > SimiPecentage)
                            {
                                Total++;
                                Console.WriteLine(string.Format("{0}-{1} found duplicate at {2}-{3} Similarity:{4}%", SourceID, DealsID, SourceID1, DealsID1, Percentage));
                            }
                        }

                    }
                }
                Console.WriteLine("Total Duplicate Found: " + Total.ToString());
            }
        }
All Usage Examples Of RTDealsScanerEngine.Similarity::sim