/// <summary> /// Unifies this set of feature values with the specified set of feature values. If the specified /// set of feature values does not contain a feature specified in this set of feature values, then the /// default value will be used for that feature. /// </summary> /// <param name="fv">The feature values.</param> /// <param name="output">The unification.</param> /// <returns><c>true</c> if the feature values could be unified, otherwise <c>false</c>.</returns> public bool UnifyDefaults(FeatureValues fv, out FeatureValues output) { output = fv.Clone(); foreach (KeyValuePair <Feature, ValueInstance> kvp in m_values) { ValueInstance value; if (fv.m_values.TryGetValue(kvp.Key, out value)) { ValueInstance vi = null; if (kvp.Value != null && !kvp.Value.UnifyDefaults(value, out vi)) { output = null; return(false); } output.m_values[kvp.Key] = vi; } else if (kvp.Key.DefaultValue != null) { ValueInstance vi = null; if (kvp.Value != null && !kvp.Value.UnifyDefaults(kvp.Key.DefaultValue, out vi)) { output = null; return(false); } output.m_values[kvp.Key] = vi; } else { output.m_values[kvp.Key] = kvp.Value; } } return(true); }
public override bool IsMatch(ValueInstance other) { ClosedValueInstance vi = other as ClosedValueInstance; HCObjectSet <FeatureValue> intersection = m_values.Intersection(vi.m_values); return(intersection.Count > 0); }
public override bool UnifyDefaults(ValueInstance other, out ValueInstance output) { FeatureValues fvs; if (UnifyDefaults(other as FeatureValues, out fvs)) { output = fvs; return(true); } else { output = null; return(false); } }
public override bool Unify(ValueInstance other, out ValueInstance output) { ClosedValueInstance vi = other as ClosedValueInstance; HCObjectSet <FeatureValue> intersection = m_values.Intersection(vi.m_values); if (intersection.Count > 0) { output = new ClosedValueInstance(intersection); return(true); } else { output = null; return(false); } }
public override bool UnifyDefaults(ValueInstance other, out ValueInstance output) { FeatureValues fvs; if (UnifyDefaults(other as FeatureValues, out fvs)) { output = fvs; return true; } else { output = null; return false; } }
public override bool UnifyDefaults(ValueInstance other, out ValueInstance output) { return(Unify(other, out output)); }
public abstract bool IsMatch(ValueInstance other);
public abstract bool IsCompatible(ValueInstance other);
public override bool IsMatch(ValueInstance other) { return(IsMatch(other as FeatureValues)); }
public override bool IsCompatible(ValueInstance other) { return(IsMatch(other)); }
/// <summary> /// Adds the specified feature-value pair. /// </summary> /// <param name="feature">The feature.</param> /// <param name="value">The value.</param> public void Add(Feature feature, ValueInstance value) { m_values[feature] = value; }
public override bool IsCompatible(ValueInstance other) { return IsMatch(other); }
public override bool IsMatch(ValueInstance other) { ClosedValueInstance vi = other as ClosedValueInstance; HCObjectSet<FeatureValue> intersection = m_values.Intersection(vi.m_values); return intersection.Count > 0; }
public override bool UnifyDefaults(ValueInstance other, out ValueInstance output) { return Unify(other, out output); }
public override bool Unify(ValueInstance other, out ValueInstance output) { ClosedValueInstance vi = other as ClosedValueInstance; HCObjectSet<FeatureValue> intersection = m_values.Intersection(vi.m_values); if (intersection.Count > 0) { output = new ClosedValueInstance(intersection); return true; } else { output = null; return false; } }
public override bool IsMatch(ValueInstance other) { return IsMatch(other as FeatureValues); }
public override bool IsCompatible(ValueInstance other) { return IsCompatible(other as FeatureValues); }
public abstract bool UnifyDefaults(ValueInstance other, out ValueInstance output);
public override bool IsCompatible(ValueInstance other) { return(IsCompatible(other as FeatureValues)); }