protected override SimpleContext CombineFeatures(SimpleContext ctxt) { NaturalClassContext result = base.CombineFeatures(ctxt) as NaturalClassContext; if (ctxt.ContextType == SimpleContextType.NATURAL_CLASS) { NaturalClassContext ncCtxt = ctxt as NaturalClassContext; // add variables from the specified pattern's context foreach (KeyValuePair <string, bool> varPolarity in ncCtxt.m_variables) { if (!Owner.IsFeatureReferenced(m_alphaVars.GetFeature(varPolarity.Key))) { result.m_variables[varPolarity.Key] = varPolarity.Value; } } foreach (KeyValuePair <string, bool> varPolarity in ncCtxt.m_antiVariables) { if (!Owner.IsFeatureReferenced(m_alphaVars.GetFeature(varPolarity.Key))) { result.m_antiVariables[varPolarity.Key] = varPolarity.Value; } } } return(result); }
public bool Equals(NaturalClassContext other) { if (other == null) { return(false); } foreach (KeyValuePair <string, bool> varPolarity in m_variables) { Feature feat = m_alphaVars.GetFeature(varPolarity.Key); bool found = false; foreach (KeyValuePair <string, bool> otherVarPolarity in other.m_variables) { Feature otherFeat = other.m_alphaVars.GetFeature(otherVarPolarity.Key); if (feat.Equals(otherFeat)) { if (varPolarity.Value != otherVarPolarity.Value) { return(false); } found = true; break; } } if (!found) { return(false); } } return(m_natClass == other.m_natClass); }
public bool Equals(NaturalClassContext other) { if (other == null) { return(false); } return(m_natClass == other.m_natClass); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="ctxt">The simple context.</param> public NaturalClassContext(NaturalClassContext ctxt) : base(ctxt) { m_natClass = ctxt.m_natClass; if (ctxt.m_variables != null) { m_variables = new Dictionary <string, bool>(ctxt.m_variables); m_antiVariables = new Dictionary <string, bool>(ctxt.m_antiVariables); m_alphaVars = ctxt.m_alphaVars; } }
public bool Equals(NaturalClassContext other) { if (other == null) return false; foreach (KeyValuePair<string, bool> varPolarity in m_variables) { Feature feat = m_alphaVars.GetFeature(varPolarity.Key); bool found = false; foreach (KeyValuePair<string, bool> otherVarPolarity in other.m_variables) { Feature otherFeat = other.m_alphaVars.GetFeature(otherVarPolarity.Key); if (feat.Equals(otherFeat)) { if (varPolarity.Value != otherVarPolarity.Value) return false; found = true; break; } } if (!found) return false; } return m_natClass == other.m_natClass; }
/// <summary> /// Copy constructor. /// </summary> /// <param name="ctxt">The simple context.</param> public NaturalClassContext(NaturalClassContext ctxt) : base(ctxt) { m_natClass = ctxt.m_natClass; if (ctxt.m_variables != null) { m_variables = new Dictionary<string, bool>(ctxt.m_variables); m_antiVariables = new Dictionary<string, bool>(ctxt.m_antiVariables); m_alphaVars = ctxt.m_alphaVars; } }
public bool Equals(NaturalClassContext other) { if (other == null) return false; return m_natClass == other.m_natClass; }