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);
        }
Exemple #2
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        // Compute the join of facilities based on the list of results.  This is coded to allow for duplicate facility names which are possible
        public void FacilityJoin(MatchResultSet matches, CsvTable csv1, CsvTable csv2)
        {
            if (matches == null || csv1 == null || csv2 == null)
            {
                return;
            }

            foreach (MatchResult match in matches.Results)
            {
                string     path     = match.FullPath;
                string     fac1     = match.Source;
                string     fac2     = match.Best;
                List <int> indices1 = csv1.LookupFacilities(path, fac1);
                List <int> indices2 = csv2.LookupFacilities(path, fac2);
                foreach (int row1 in indices1)
                {
                    foreach (int row2 in indices2)
                    {
                        UpdateColumns(row1, csv1, row2, csv2);
                    }
                }
            }
        }
Exemple #7
0
 private void OnMatchAllFacilities(object sender, EventArgs e)
 {
     this.matchResults = this.facilityManager.MatchAllFacilities(this.csvTable1, this.csvTable2);
 }