Beispiel #1
0
        /// <inheritdoc/>
        protected override void setMapping(FeatureInstance featureInstance, NodeMapping mapping)
        {
            var instanceNodeData = featureInstance.Origin.Words.Skip(Index).First();
            var generalNodeData  = IndexPrefix + Index;

            mapping.SetMapping(instanceNodeData, generalNodeData);
        }
Beispiel #2
0
 private void indexPositions(FeatureInstance feature)
 {
     //set index of all indexed positions
     foreach (var coveredPosition in feature.CoveredPositions)
     {
         _coveredPositions[coveredPosition] = true;
     }
 }
Beispiel #3
0
        internal FeatureCover(FeatureInstance feature, ParsedUtterance utterance)
        {
            OriginalUtterance = utterance;
            _coveredPositions = new bool[feature.MaxOriginPosition + 1];
            FeatureInstances  = new[] { feature };
            indexPositions(feature);

            FeatureKey = createFeatureKey();
        }
Beispiel #4
0
        private FeatureCover(FeatureCover previousCover, FeatureInstance extendingFeature)
        {
            OriginalUtterance = previousCover.OriginalUtterance;
            _coveredPositions = previousCover._coveredPositions.ToArray();
            FeatureInstances  = previousCover.FeatureInstances.Concat(new[] { extendingFeature }).OrderBy(f => f.CoveredPositions.First()).ToArray();

            indexPositions(extendingFeature);

            FeatureKey = createFeatureKey();
        }
Beispiel #5
0
        internal IEnumerable <FeatureCover> Extend(FeatureInstance feature)
        {
            var hasOverlap = feature.CoveredPositions.Where(p => _coveredPositions[p]).Any();

            if (hasOverlap)
            {
                return(new FeatureCover[0]);
            }

            return(new[] {
                new FeatureCover(this, feature)
            });
        }
        protected override IEnumerable <FeatureInstance> generateFeatures(ParsedUtterance expression, ComposedGraph graph)
        {
            var featureInstances = new List <FeatureInstance>();
            var wordIndex        = 0;

            foreach (var word in expression.Words)
            {
                var feature         = new UnigramFeature(word);
                var featureInstance = new FeatureInstance(expression, feature, wordIndex);
                featureInstances.Add(featureInstance);
                ++wordIndex;
            }

            return(featureInstances);
        }
Beispiel #7
0
        /// <inheritdoc/>
        protected override IEnumerable <FeatureInstance> generateFeatures(ParsedUtterance expression, ComposedGraph graph)
        {
            var featureInstances = new List <FeatureInstance>();
            var wordIndex        = 0;

            foreach (var word in expression.Words)
            {
                if (graph.HasEvidence(word))
                {
                    var nodeFeature = new NodeFeature(wordIndex);
                    var instance    = new FeatureInstance(expression, nodeFeature, wordIndex);
                    featureInstances.Add(instance);
                }
                ++wordIndex;
            }

            return(featureInstances);
        }
Beispiel #8
0
 /// <inheritdoc/>
 protected override void setMapping(FeatureInstance featureInstance, NodeMapping mapping)
 {
     //nothing to do
 }
Beispiel #9
0
 internal void SetMapping(FeatureInstance featureInstance, NodeMapping mapping)
 {
     setMapping(featureInstance, mapping);
 }
Beispiel #10
0
 abstract protected void setMapping(FeatureInstance featureInstance, NodeMapping mapping);