IPhFeatureConstraint RemoveFeatureConstraint(FdoReferenceSequence <IPhFeatureConstraint> featConstrs, int hvoClosedFeature) { IPhFeatureConstraint constrToRemove = GetFeatureConstraint(featConstrs.HvoArray, hvoClosedFeature); if (constrToRemove != null) { featConstrs.Remove(constrToRemove); } return(constrToRemove); }
/// <summary> /// Updates the feature constraints in the context. /// </summary> void UpdateFeatureConstraints() { CheckDisposed(); List <int> featureHvos = m_bvList.AllItems; foreach (int hvoClosedFeature in featureHvos) { var feat = m_cache.ServiceLocator.GetInstance <IFsFeatDefnRepository>().GetObject(hvoClosedFeature); string str = m_sda.get_UnicodeProp(feat.Hvo, FeatureConstraintPublisher.PolarityFlid); if (String.IsNullOrEmpty(str)) { IPhFeatureConstraint removedConstr = RemoveFeatureConstraint(m_ctxt.PlusConstrRS, feat); if (removedConstr == null) { removedConstr = RemoveFeatureConstraint(m_ctxt.MinusConstrRS, feat); } if (removedConstr != null) { if (!m_rule.FeatureConstraints.Contains(removedConstr)) { m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Remove(removedConstr); } } } else { IPhFeatureConstraint var = GetFeatureConstraint(m_rule.FeatureConstraints, feat); if (var == null) { var = m_cache.ServiceLocator.GetInstance <IPhFeatureConstraintFactory>().Create(); m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Add(var); var.FeatureRA = feat; } if (str == MEStrings.ksFeatConstrAgree) { if (!m_ctxt.PlusConstrRS.Contains(var)) { m_ctxt.PlusConstrRS.Add(var); RemoveFeatureConstraint(m_ctxt.MinusConstrRS, feat); } } else if (str == MEStrings.ksFeatConstrDisagree) { if (!m_ctxt.MinusConstrRS.Contains(var)) { m_ctxt.MinusConstrRS.Add(var); RemoveFeatureConstraint(m_ctxt.PlusConstrRS, feat); } } } } }
protected override int GetVarIndex(IPhFeatureConstraint var) { int i = 0; foreach (var curVar in m_rhs.OwningRule.FeatureConstraints) { if (var == curVar) return i; i++; } return -1; }
protected override int GetVarIndex(IPhFeatureConstraint var) { int i = 0; foreach (var curVar in m_rhs.OwningRule.FeatureConstraints) { if (var == curVar) { return(i); } i++; } return(-1); }
protected override int GetVarIndex(IPhFeatureConstraint var) { IPhRegularRule rule = new PhRegularRule(m_cache, m_rhs.OwnerHVO); List <int> featConstrs = rule.FeatureConstraints; for (int i = 0; i < featConstrs.Count; i++) { if (var.Hvo == featConstrs[i]) { return(i); } } return(-1); }
IPhFeatureConstraint GetFeatureConstraint(IEnumerable <int> featConstrs, int hvoClosedFeature) { IPhFeatureConstraint result = null; foreach (int hvo in featConstrs) { IPhFeatureConstraint curConstr = new PhFeatureConstraint(m_cache, hvo); if (curConstr.FeatureRAHvo == hvoClosedFeature) { result = curConstr; break; } } return(result); }
ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity) { int varIndex = GetVarIndex(var); if (varIndex == -1) { return(m_questions); } ITsIncStrBldr varLine = TsIncStrBldrClass.Create(); if (!polarity) { varLine.Append("-"); } varLine.AppendTsString(m_cache.MakeUserTss(VARIABLE_NAMES[varIndex])); varLine.Append(" "); varLine.AppendTsString(var.FeatureRAHvo == 0 ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative); return(varLine.GetString()); }
ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity) { int varIndex = GetVarIndex(var); if (varIndex == -1) { return(m_questions); } ITsIncStrBldr varLine = TsStringUtils.MakeIncStrBldr(); if (!polarity) { varLine.AppendTsString(TsStringUtils.MakeString("-", m_cache.DefaultUserWs)); } varLine.AppendTsString(TsStringUtils.MakeString(VariableNames[varIndex], m_cache.DefaultUserWs)); varLine.Append(" "); varLine.AppendTsString(var.FeatureRA == null ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative); return(varLine.GetString()); }
private static XElement ExportFeatureConstraint(IPhFeatureConstraint featureConstraint) { return new XElement("PhFeatureConstraint", new XAttribute("Id", featureConstraint.Hvo), ExportItemAsReference(featureConstraint.FeatureRA, "Feature")); }
protected override int GetVarIndex(IPhFeatureConstraint var) { return(-1); }
/// <summary> /// Gets the index of the specified feature constraint. This is used to ensure that the same /// variable is used for a feature constraint across the entire rule. /// </summary> /// <param name="var">The variable.</param> /// <returns></returns> protected abstract int GetVarIndex(IPhFeatureConstraint var);
ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity) { int varIndex = GetVarIndex(var); if (varIndex == -1) return m_questions; ITsIncStrBldr varLine = TsIncStrBldrClass.Create(); if (!polarity) varLine.AppendTsString(m_cache.TsStrFactory.MakeString("-", m_cache.DefaultUserWs)); varLine.AppendTsString(m_cache.TsStrFactory.MakeString(VARIABLE_NAMES[varIndex], m_cache.DefaultUserWs)); varLine.Append(" "); varLine.AppendTsString(var.FeatureRA == null ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative); return varLine.GetString(); }
/// <summary> /// Gets the index of the specified feature constraint. This is used to ensure that the same /// variable is used for a feature constraint across the entire rule. /// </summary> /// <param name="var">The variable.</param> /// <returns></returns> protected abstract int GetVarIndex(IPhFeatureConstraint var);
protected override int GetVarIndex(IPhFeatureConstraint var) { return -1; }
/// <summary> /// Updates the feature constraints in the context. /// </summary> void UpdateFeatureConstraints() { CheckDisposed(); List <int> featureHvos = m_bvList.AllItems; foreach (int hvoClosedFeature in featureHvos) { string str = m_cache.GetUnicodeProperty(hvoClosedFeature, m_dummyPolarityFlid); if (str == null) { IPhFeatureConstraint removedConstr = RemoveFeatureConstraint(m_ctxt.PlusConstrRS, hvoClosedFeature); if (removedConstr == null) { removedConstr = RemoveFeatureConstraint(m_ctxt.MinusConstrRS, hvoClosedFeature); } if (removedConstr != null) { bool found = false; foreach (int hvo in m_rule.FeatureConstraints) { if (removedConstr.Hvo == hvo) { found = true; break; } } if (!found) { m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Remove(removedConstr); } } } else { IPhFeatureConstraint var = GetFeatureConstraint(m_rule.FeatureConstraints, hvoClosedFeature); if (var == null) { var = new PhFeatureConstraint(); m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Append(var); var.FeatureRAHvo = hvoClosedFeature; var.NotifyNew(); } if (str == MEStrings.ksFeatConstrAgree) { if (!m_ctxt.PlusConstrRS.Contains(var)) { m_ctxt.PlusConstrRS.Append(var); RemoveFeatureConstraint(m_ctxt.MinusConstrRS, hvoClosedFeature); } } else if (str == MEStrings.ksFeatConstrDisagree) { if (!m_ctxt.MinusConstrRS.Contains(var)) { m_ctxt.MinusConstrRS.Append(var); RemoveFeatureConstraint(m_ctxt.PlusConstrRS, hvoClosedFeature); } } } } }
protected override int GetVarIndex(IPhFeatureConstraint var) { IPhRegularRule rule = new PhRegularRule(m_cache, m_rhs.OwnerHVO); List<int> featConstrs = rule.FeatureConstraints; for (int i = 0; i < featConstrs.Count; i++) { if (var.Hvo == featConstrs[i]) return i; } return -1; }