Beispiel #1
0
        internal void Add(InterpretationsFactory interpretationsFactory, IEnumerable <FeatureCover> covers)
        {
            //create simple mapping which doesn't need expensive computation
            var entry = new OptimizedEntry(this, interpretationsFactory, covers);

            registerEntry(entry);
        }
Beispiel #2
0
        private void registerEntry(OptimizedEntry entry)
        {
            var initialInstance = entry.GetSimpleFeatureInstance();
            var initialRule     = new FeaturedRule(initialInstance.Feature, new ContextRule(new CompositionPoolRule(entry.CurrentInterpretation.Rules)));


            RulesDistribution distribution;

            if (!_featureToDistributions.TryGetValue(initialRule.Feature, out distribution))
            {
                _featureToDistributions[initialRule.Feature] = distribution = new RulesDistribution();
            }

            distribution.Add(initialRule.Rule);
            _optimizedEntries.Add(entry);
        }
Beispiel #3
0
        private Ranked <Interpretation> getNextRankedInterpretation(OptimizedEntry entry)
        {
            if (!entry.Next())
            {
                //there are no more patterns available
                return(null);
            }

            //get next interpretation
            var interpretation = entry.CurrentInterpretation;

            //rank according to generalization point of view
            var similarAnswerNodes     = getSimilarNodes(entry.CorrectAnswerNode);
            var substitutedAnswerNodes = getSubstitutedAnswers(interpretation);
            var similarSubstitutions   = similarAnswerNodes.Intersect(substitutedAnswerNodes).ToArray();
            var generalizationAbility  = 1.0 * similarSubstitutions.Length / similarAnswerNodes.Count;

            return(new Ranked <Interpretation>(interpretation, generalizationAbility));
        }
Beispiel #4
0
 public void LinkTo(OptimizedEntry entry, int offset)
 {
     LinkId              = entry.Id;
     LinkOffset          = offset;
     entry.HasbeenLinked = true;
 }