private StructuredInterpretation getInterpretation(ConstraintSelector selector) { var constraints = selector.Rules; var interpretation = new StructuredInterpretation(FeatureKey, _topicGenerator.TopicConstraints, constraints); return(interpretation); }
/// <summary> /// Adds new interpretation based on given generator. /// </summary> /// <param name="selector">The generator.</param> private void addNewInterpretation(ConstraintSelector selector) { var interpretation = getInterpretation(selector); var rankedInterpretation = rank(interpretation); if (rankedInterpretation.Rank == 0) { throw new NotSupportedException("This should not happen"); } //insertion sort var isInserted = false; for (var i = 0; i < _availableInterpretations.Count; ++i) { if (_availableInterpretations[i].Rank < rankedInterpretation.Rank) { _availableInterpretations.Insert(i, rankedInterpretation); isInserted = true; break; } } if (!isInserted) { _availableInterpretations.Add(rankedInterpretation); } //remove exceeding interpretations if needed if (_availableInterpretations.Count > InterpretationCountLimit) { _availableInterpretations.RemoveRange(InterpretationCountLimit, _availableInterpretations.Count - InterpretationCountLimit); } }
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ConstraintSelector CS = value[0] as ConstraintSelector; if (CS != null) { return(CS.FullConstraintDefinition); } else { return(""); } }
internal Interpretation GetNextInterpretation() { while (_currentConstraintSelector == null || !_currentConstraintSelector.MoveNext()) { if (!_topicSelector.MoveNext()) { //there are no other interpretations return(null); } _currentConstraintSelector = _interpretations.GetConstraintSelector(_owner.Graph, _topicSelector.SelectedNodes); } var interpretation = new Interpretation(_topicSelector.Rules.Concat(_currentConstraintSelector.Rules)); return(interpretation); }
/// <summary> /// Sets new constraint and selector pattern. /// </summary> /// <returns></returns> internal bool Next() { CurrentInterpretation = null; while (!_currentConstraintSelector.MoveNext()) { if (!_topicSelector.MoveNext()) { //there are no other interpretations return(false); } _currentConstraintSelector = _interpretations.GetConstraintSelector(_originMapping.Graph, _topicSelector.SelectedNodes); } CurrentInterpretation = new Interpretation(_topicSelector.Rules.Concat(_currentConstraintSelector.Rules)); return(true); }
internal OptimizedEntry(FeatureMapping originMapping, InterpretationsFactory interpretations, IEnumerable <FeatureCover> covers) { _covers = covers.ToArray(); if (_covers.Length == 0) { throw new NotSupportedException("Cannot create optimized entry without feature covers"); } _interpretations = interpretations; _originMapping = originMapping; _topicSelector = interpretations.GetTopicSelector(originMapping.Graph); if (_topicSelector.MoveNext()) { _currentConstraintSelector = interpretations.GetConstraintSelector(originMapping.Graph, _topicSelector.SelectedNodes); Next(); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ConstraintSelector CS = value as ConstraintSelector; if (CS != null) { if (CS.ReferenceType == ReferenceTypes.Lower) { return(new SolidColorBrush(Colors.IndianRed)); } else { return(new SolidColorBrush(Colors.SteelBlue)); } } else { return(new SolidColorBrush(Colors.SteelBlue)); } }
internal InterpretationGenerator(IEnumerable <FeatureCover> covers, InterpretationsFactory interpretations, ContextPool context, ProbabilisticQAModule owner) { var coversCopy = covers.ToArray(); if (coversCopy.Length == 0) { throw new NotSupportedException("Cannot create InterpretationGenerator without feature covers"); } Covers = coversCopy; _interpretations = interpretations; _context = context.Clone(); _owner = owner; _topicSelector = interpretations.GetTopicSelector(owner.Graph); if (_topicSelector.MoveNext()) { //initialize constraint selector _currentConstraintSelector = interpretations.GetConstraintSelector(owner.Graph, _topicSelector.SelectedNodes); } }