public MatchingPair Map(LostAndFoundIndexedItem loss, LostAndFoundIndexedItem finding)
        {
            var pair = new MatchingPair
            {
                LossDateOfIncident    = MapDate(loss.DateOfIncident),
                FindingDateOfIncident = MapDate(finding.DateOfIncident),

                /*LossEasyFindNo = MapIdentifier(loss.EasyFindNo),
                 * FindingEasyFindNo = MapIdentifier(finding.EasyFindNo),
                 * LossBagTag = MapIdentifier(loss.BagTag),
                 * FindingBagTag = MapIdentifier(loss.BagTag),*/



                // TODO:
//        Description
//        LossLocation
            };

            pair.LossCategory    = MapCategory(loss.CategoryID, loss.SubCategoryID);
            pair.FindingCategory = MapCategory(finding.CategoryID, finding.SubCategoryID);

            pair.LossColors    = MapColors(loss.Attributes.OfType <ColorValueAttribute>());
            pair.FindingColors = MapColors(finding.Attributes.OfType <ColorValueAttribute>());

            //*
            MapBool(pair.LossAttributes, loss.Attributes.OfType <BoolAttribute>());
            MapBool(pair.FindingAttributes, finding.Attributes.OfType <BoolAttribute>());
            //*/

            MapDouble(pair.LossAttributes, loss.Attributes.OfType <DoubleAttribute>());
            MapDouble(pair.FindingAttributes, finding.Attributes.OfType <DoubleAttribute>());

            pair.LossMoney    = MapMoney(loss.Attributes.OfType <MoneyValueAttribute>());
            pair.FindingMoney = MapMoney(finding.Attributes.OfType <MoneyValueAttribute>());

            MapInteger(pair.LossAttributes, loss.Attributes.OfType <IntegerAttribute>());
            MapInteger(pair.FindingAttributes, finding.Attributes.OfType <IntegerAttribute>());

            return(pair);
        }
        public virtual IList <MatchingPair> GetMatchingPairs(ActivationNetwork net)
        {
            var pairs = new List <MatchingPair>();

            Parallel.ForEach(Findings, finding =>
            {
                MatchingPair bestPair = null;
                foreach (var loss in Losses)
                {
                    var pair          = Mapper.MapMatch(loss, finding);
                    pair.PercentMatch = net.Compute(pair.ToVectorArray(ActualMetadata)).Single();
                    if (bestPair == null || bestPair.PercentMatch < pair.PercentMatch)
                    {
                        bestPair = pair;
                    }
                }
                lock (pairs)
                {
                    pairs.Add(bestPair);
                }
            });
            return(pairs);
        }
Ejemplo n.º 3
0
        public void WritePair(TextWriter writer, MatchingPair pair)
        {
            var vector = pair.ToVectorArray(_metadataAttributes);

            writer.WriteLine(string.Join(",", vector.Select(number => number.ToString(CultureInfo.InvariantCulture))));
        }