Exemple #1
0
        private void LinkResultsWithUniqueIdenticalWhat()
        {
            WhatMap beforeMap = new WhatMap(Before, MatchingIndexFromBefore);
            WhatMap afterMap  = new WhatMap(After, MatchingIndexFromAfter);

            foreach (Tuple <int, int> link in beforeMap.UniqueLinks(afterMap))
            {
                LinkIfSimilar(link.Item1, link.Item2);
            }
        }
Exemple #2
0
 /// <summary>
 ///  Return the indices of results in this set and the other set
 ///  which have a common trait which is unique in each set.
 /// </summary>
 /// <param name="other">WhatMap for other Result set</param>
 /// <returns>Index of this and Index of other Result where the two have a unique trait in common.</returns>
 public IEnumerable <Tuple <int, int> > UniqueLinks(WhatMap other)
 {
     foreach (KeyValuePair <WhatComponent, int> entry in _map.Where(entry => entry.Value != -1))
     {
         if (other._map.TryGetValue(entry.Key, out int otherIndex) && otherIndex != -1)
         {
             yield return(new Tuple <int, int>(entry.Value, otherIndex));
         }
     }
 }
Exemple #3
0
        private static void BuildMap(List <ExtractedResult> results, WhatMap whatMap, TrustMap trustMap, HashSet <string> otherRunLocations)
        {
            // Populate the WhatMap and TrustMap
            for (int i = 0; i < results.Count; ++i)
            {
                ExtractedResult result = results[i];

                // Find the LocationSpecifier for the Result (the first Uri or FQN also in the other Run)
                string locationSpecifier = WhereComparer.LocationSpecifier(result, otherRunLocations);

                foreach (WhatComponent component in WhatComparer.WhatProperties(result, locationSpecifier))
                {
                    // Add Result attributes used as matching hints in a "bucket" for the Rule x LocationSpecifier x AttributeName
                    whatMap.Add(component, i);

                    // Track attribute usage to determine per-attribute trust
                    trustMap.Add(component);
                }
            }
        }
Exemple #4
0
        public StatefulResultMatcher(IList <ExtractedResult> before, IList <ExtractedResult> after)
        {
            // Sort results by 'Where', then 'RuleId' for matching
            _before = new List <ExtractedResult>(before);
            _before.Sort(ResultMatchingComparer.Instance);

            _beforeTrustMap = new TrustMap();
            _beforeWhatMap  = new WhatMap();

            _matchingIndexFromBefore = new int[_before.Count];
            Fill(_matchingIndexFromBefore, -1);

            _after = new List <ExtractedResult>(after);
            _after.Sort(ResultMatchingComparer.Instance);

            _afterTrustMap = new TrustMap();
            _afterWhatMap  = new WhatMap();

            _matchingIndexFromAfter = new int[_after.Count];
            Fill(_matchingIndexFromAfter, -1);
        }