public NameSet GetFacilities(string pathString) { NameSet names = new NameSet(pathString); List <string> pathList = Utilities.PathStringToList(pathString); AdminTreeNode node = this; for (int i = 1; i < pathList.Count; i++) { int index = node.Children.IndexOfKey(pathList[i]); if (index == -1) { return(names); } node = node.Children[index]; } foreach (AdminTreeNode child in node.Children) { if (child.IsFacility) { names.AddName(child.Name); } } return(names); }
MatchResultSet LongestCommonSubsequence(NameSet target) { MatchResultSet result = new MatchResultSet(); foreach (string str1 in this.names) { int index = target.Names.IndexOf(str1); if (index > -1) { result.Add(str1, str1, 100); } else { string best = ""; int score = 0; foreach (string str2 in target.Names) { int lcs = Utilities.LcsLength(str1, str2); if (lcs > score) { score = lcs; best = str2; } } result.Add(str1, best, score); } } return(result); }
private void InitializeApplication() { this.csvTable1 = new CsvTable(country); this.csvTable2 = new CsvTable(country); this.nameSet1 = new NameSet(); this.nameSet2 = new NameSet(); this.appOptions = new ApplicationOptions(); this.displayManager = new DisplayManager(this.textBox1, this.textBox2, this.textBox3, this.listBox1, this.treeView1, this.treeView2); this.dataCleaner = new DataCleaner(this.displayManager); this.facilityManager = new FacilityManager(this.displayManager, this.appOptions); }
public void ApplyNameSubstitutions(NameSet ns, CsvTable csv, ListBox lb) { List <string> path = ns.ExtractPath; string columnName = "Admin " + path.Count; foreach (int i in lb.SelectedIndices) { string str = lb.Items[i].ToString(); char[] separator = new char[] { '\\' }; string[] values = str.Split(separator); string oldValue = values[0]; string newValue = values[1]; csv.Substitute(path, columnName, oldValue, newValue); } }
public void MatchNames(NameSet ns1, NameSet ns2) { if (ns1.FullPath != ns2.FullPath) { MessageBox.Show("Paths do not match for OnMatchNames"); return; } MatchResultSet result1 = ns1.CompareNames(ns2, applicationOptions.MatchingAlgorithm); displayManager.Text1 = result1.ToString(); MatchResultSet result2 = ns2.CompareNames(ns1, applicationOptions.MatchingAlgorithm); displayManager.Text2 = result2.ToString(); result2.AddToListBox(displayManager.ListBox); }
MatchResultSet Basic(NameSet target) { MatchResultSet result = new MatchResultSet(); foreach (string str1 in this.names) { int index = target.Names.IndexOf(str1); if (index > -1) { result.Add(str1, str1, 1); } else { result.Add(str1, "", 0); } } return(result); }
public MatchResultSet CompareNames(NameSet target, Algorithm alg = Algorithm.Basic) { MatchResultSet result = null; switch (alg) { case Algorithm.Basic: result = Basic(target); break; case Algorithm.LCS: result = LongestCommonSubsequence(target); break; default: break; } return(result); }
public MatchResultSet MatchAllFacilities(CsvTable csv1, CsvTable csv2) { List <string> results = new List <string>(); if (csv1 == null || csv2 == null) { return(null); } AdminTree admin1 = new AdminTree(csv1, applicationOptions.Country); admin1.AddFacilityNodes(csv1); AdminTree admin2 = new AdminTree(csv2, applicationOptions.Country); admin2.AddFacilityNodes(csv2); AdminIterator adminNodes = new AdminIterator(admin1); MatchResultSet resultsToReturn = new MatchResultSet(); foreach (AdminTreeNode node in adminNodes) { Console.WriteLine(node.Name); if (node.IsFacility) { string path = node.Path; NameSet facilitiesToMatch = admin2.GetFacilities(path); MatchResult result = facilitiesToMatch.FindBestMatch(node.Name); if (GoodMatch(node.Name, result)) { string resultString = path + "\\" + result.ToString(); results.Add(resultString); result.FullPath = path; resultsToReturn.Add(result); } } } displayManager.DisplayTextFile(results, 10000); return(resultsToReturn); }
private void OnTreeTwoSelect(object sender, TreeViewEventArgs e) { this.nameSet2 = new NameSet(this.treeView2.SelectedNode); this.textBox2.Text = this.nameSet2.ToString(); }
private void OnTreeOneSelect(object sender, TreeViewEventArgs e) { this.nameSet1 = new NameSet(this.treeView1.SelectedNode); this.treeView1.SelectedNode.BackColor = Color.PowderBlue; this.textBox1.Text = this.nameSet1.ToString(); }