Beispiel #1
0
        internal void AddInterpretation(FeatureCover cover, RuledInterpretation interpretation, double rank)
        {
            double score;
            var    key = Tuple.Create(cover, interpretation);

            _interpretationScores.TryGetValue(key, out score);
            score += rank;
            _interpretationScores[key] = score;
        }
        internal void ReportInterpretation(RuledInterpretation interpretation)
        {
            var key = interpretation.FeatureKey;

            InterpretationCounter counter;

            if (!_coverIndex.TryGetValue(key, out counter))
            {
                //create new counter
                _coverIndex[key] = counter = new InterpretationCounter();
            }

            counter.Add(interpretation);
            ++RegisteredInterpretations;
        }
        private void reportToCompatibleGenerators(FeatureCover reportingCover, Interpretation generalInterpretation)
        {
            if (_completedGeneralInterpretations.Contains(generalInterpretation))
            {
                //we are searchnig only for new general interpretations
                return;
            }

            //remember that we have proceed this interpretation so we don't need to repeatedly increment it
            _completedGeneralInterpretations.Add(generalInterpretation);

            //feature key has always been present in the index
            var generatorCovers = _keyToGeneratorCovers[reportingCover.FeatureKey];

            var compatibleCovers = new List <FeatureCover>();

            foreach (var generatorCover in generatorCovers)
            {
                var generator = generatorCover.Item1;
                var cover     = generatorCover.Item2;

                var instantiatedInterpretation = generalInterpretation.InstantiateBy(cover, Graph);
                if (isCompatibleInterpretation(instantiatedInterpretation, generator))
                {
                    compatibleCovers.Add(cover);
                    var ruledInterpretation = new RuledInterpretation(generalInterpretation, reportingCover.FeatureKey);
                    _mapping.ReportInterpretation(ruledInterpretation);
                }
            }

            if (compatibleCovers.Count > 1)
            {
                Console.WriteLine(generalInterpretation);
                Console.WriteLine("\tCOMPATIBLE WITH:");
                foreach (var cover in compatibleCovers)
                {
                    var origin = cover.FeatureInstances.First().Origin;
                    Console.WriteLine("\t\t" + origin);
                }

                Console.WriteLine();
            }
        }
Beispiel #4
0
        internal void Add(RuledInterpretation interpretation)
        {
            ++_totalInterpretationCount;

            int count;

            _ruleCounts.TryGetValue(interpretation, out count);
            ++count;

            //set new value
            _ruleCounts[interpretation] = count;

            if (count > _maxCount)
            {
                //better interpretation has been found
                _maxCount          = count;
                BestInterpretation = interpretation;
            }

            BestInterpretationRank = 1.0 * _maxCount / _totalInterpretationCount;
        }