当前位置: 首页>>代码示例>>C#>>正文


C# Distance.LD方法代码示例

本文整理汇总了C#中Distance.LD方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.LD方法的具体用法?C# Distance.LD怎么用?C# Distance.LD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Distance的用法示例。


在下文中一共展示了Distance.LD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MatchMedia_Click

        private void MatchMedia_Click(object sender, RoutedEventArgs e)
        {
            string bestMatch;
            //var f = item as FileInfo;

            #region Wheels
            if (MediaType == "Wheels")
            {
                foreach (Table table in DataGridMedia.Items)
                {
                    if (!table.HaveWheels)
                    {
                        foreach (var item in listWheels)
                        {
                            bestMatch = string.Empty;
                            int i = 0;
                            int ii = Convert.ToInt32(_wheels_matchValue.Text);
                            string pattern = System.IO.Path.GetFileNameWithoutExtension(item.File.Name).ToUpper();
                            string input = table.Description.ToUpper();

                            Distance d = new Distance();
                            i = d.LD(input, pattern);
                            if (i <= ii)
                            {
                                ii = i;
                                bestMatch = table.Description;
                                item.TagRename = true;
                                item.MatchedName = bestMatch;
                            }
                        }
                    }

                }
            }
            #endregion
            else if (MediaType == "Table Image")
            {
                foreach (Table table in DataGridMedia.Items)
                {
                    if (!table.HaveTableImage)
                    {
                        foreach (var item in listTImgs)
                        {
                            bestMatch = string.Empty;
                            int i = 0;
                            int ii = Convert.ToInt32(_wheels_matchValue.Text);
                            string pattern = System.IO.Path.GetFileNameWithoutExtension(item.File.Name).ToUpper();
                            string input = table.Description.ToUpper();

                            Distance d = new Distance();
                            i = d.LD(input, pattern);
                            if (i <= ii)
                            {
                                ii = i;
                                bestMatch = table.Description;
                                item.TagRename = true;
                                item.MatchedName = bestMatch;
                            }
                        }
                    }

                }
            }
            else if (MediaType == "Table Vids")
            {
                foreach (Table table in DataGridMedia.Items)
                {
                    if (!table.HaveTableVideo)
                    {
                        foreach (var item in listTVids)
                        {
                            bestMatch = string.Empty;
                            int i = 0;
                            int ii = Convert.ToInt32(_wheels_matchValue.Text);
                            string pattern = System.IO.Path.GetFileNameWithoutExtension(item.File.Name).ToUpper();
                            string input = table.Description.ToUpper();

                            Distance d = new Distance();
                            i = d.LD(input, pattern);
                            if (i <= ii)
                            {
                                ii = i;
                                bestMatch = table.Description;
                                item.TagRename = true;
                                item.MatchedName = bestMatch;
                            }
                        }
                    }

                }
            }
        }
开发者ID:horseyhorsey,项目名称:PinXCheck,代码行数:92,代码来源:MainWindow.xaml.cs

示例2: Button_Click_9

        private void Button_Click_9(object sender, RoutedEventArgs e)
        {
            List<string> li = new List<string>();
            var p = Pinxsystem.ElementAt(comboBox_syslist.SelectedIndex);
            DirectoryInfo di = new DirectoryInfo(p.TablePath + "\\");
            FileInfo[] fi = di.GetFiles("*.directb2s");

            foreach (var table in tables)
            {
                int i = 0;
                int ii = 15;
                string bestMatch = string.Empty;

                if (!table.HaveDirectB2S)
                {
                    foreach (var item in fi)
                    {
                        string pattern = item.Name;
                        string input;
                        input = table.Description;

                        Distance d = new Distance();
                        i = d.LD(input, pattern);

                        if (i <= ii)
                        {
                            ii = i;
                            table.FlagRenameB2S = true;
                            table.MatchedPercent = i;
                            bestMatch = item.Name;
                        }

                    }

                    li.Add(bestMatch);
                    bestMatch = string.Empty;

                }

            }

            int iii = 0;
            foreach (var item in (li))
            {
                tables.ElementAt(iii).MatchedB2SName = item;
                iii++;

            }
        }
开发者ID:horseyhorsey,项目名称:PinXCheck,代码行数:49,代码来源:MainWindow.xaml.cs

示例3: bw_DoWork

        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            List<Table> li = new List<Table>();
            int count = 0;
            int i = 0;
            string inputTableName, inputTableDescription, TableNameEdit="", TableDescriptionEdit="",masterTableName="",masterTableDesc="";
            string replacement = "";
            string patterns = @"\(.*\)";
            Regex rgx = new Regex(patterns);
            Table bestTableMatch = new Table();

            foreach (var table in tables)
            {
                // Remove everything in the Parenthesys from Table or description
                inputTableName = table.Name;
                inputTableDescription = table.Description;
                if (RegExBracketsTable)
                {
                    TableNameEdit = rgx.Replace(inputTableName, replacement);
                    TableDescriptionEdit = rgx.Replace(inputTableDescription, replacement);
                }

                table.FlagRename = false;
                table.MatchedName = "";
                if (yearGreater)
                {
                    if (table.Year > yearMatchFilter || table.Year == 0)
                        flagMatchEnabled = true;
                    else flagMatchEnabled = false;
                }
                else
                {
                    if (table.Year < yearMatchFilter || table.Year == 0)
                        flagMatchEnabled = true;
                    else flagMatchEnabled = false;
                }

                if (flagMatchEnabled)
                {
                   if (!table.MatchedDescription)
                        {
                            foreach (var item in master_tables)
                            {
                                if (RegExBracketsMaster)
                                {
                                    masterTableName = rgx.Replace(item.Name, replacement);
                                    masterTableDesc = rgx.Replace(item.Description, replacement);
                                }

                                if (yearGreater)
                                {
                                    if (item.Year > yearMatchFilter )
                                        flagMatchEnabled = true;
                                    else flagMatchEnabled = false;
                                }
                                else
                                {
                                    if (item.Year < yearMatchFilter)
                                        flagMatchEnabled = true;
                                    else flagMatchEnabled = false;
                                }

                                if (flagMatchEnabled)
                                {
                                    if (bw.CancellationPending)
                                    {
                                        e.Cancel = true;
                                        return;
                                    }
                                    else
                                    {
                                        string pattern;
                                        string input;

                                        if (matchToTable)
                                        {
                                            if (RegExBracketsTable)
                                                pattern = TableNameEdit.ToUpper();
                                            else
                                                pattern = table.Name.ToUpper();
                                        }
                                        else
                                        {
                                            if (RegExBracketsTable)
                                                pattern = TableDescriptionEdit.ToUpper();
                                            else
                                                pattern = table.Description.ToUpper();
                                        }

                                        if (matchToMasterTable)
                                        {
                                            input = item.Name.ToUpper();
                                        }
                                        else
                                        {
                                            input = item.Description.ToUpper();
                                        }

                                        Distance d = new Distance();
                                        i = d.LD(input, pattern);
//.........这里部分代码省略.........
开发者ID:horseyhorsey,项目名称:PinXCheck,代码行数:101,代码来源:MainWindow.xaml.cs


注:本文中的Distance.LD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。