/// <summary> /// Determines whether this subrule is applicable to the specified word analysis. /// </summary> /// <param name="input">The word analysis.</param> /// <returns> /// <c>true</c> if this subrule is applicable, otherwise <c>false</c>. /// </returns> public bool IsApplicable(WordSynthesis input) { // check part of speech and MPR features return((m_requiredPOSs == null || m_requiredPOSs.Count == 0 || m_requiredPOSs.Contains(input.POS)) && (m_requiredMPRFeatures == null || m_requiredMPRFeatures.Count == 0 || m_requiredMPRFeatures.IsMatch(input.MPRFeatures)) && (m_excludedMPRFeatures == null || m_excludedMPRFeatures.Count == 0 || !m_excludedMPRFeatures.IsMatch(input.MPRFeatures))); }
/// <summary> /// Determines whether this rule is applicable to the specified word synthesis. /// </summary> /// <param name="input">The input word synthesis.</param> /// <returns> /// <c>true</c> if the rule is applicable, otherwise <c>false</c>. /// </returns> public override bool IsApplicable(WordSynthesis input) { // TODO: check subcats. // check required parts of speech return(input.NextRule == this && input.GetNumAppliesForMorphologicalRule(this) < m_maxNumApps && (m_requiredPOSs == null || m_requiredPOSs.Count == 0 || m_requiredPOSs.Contains(input.POS))); }
/// <summary> /// Adds the feature value. /// </summary> /// <param name="value">The feature value.</param> /// <exception cref="System.InvalidOperationException">Thrown when the current number of feature values is equal to the maximum /// and this feature system does not contain the specified value.</exception> public void AddValue(FeatureValue value) { if (!m_values.Contains(value) && m_values.Count == FeatureBundle.MAX_NUM_VALUES) { throw new InvalidOperationException(HCStrings.kstidTooManyFeatValues); } value.FeatureBundleIndex = m_values.Count; m_values.Add(value); }
public bool Equals(HCObjectSet <T> other) { if (other == null) { return(false); } if (Count != other.Count) { return(false); } foreach (T item in this) { if (!other.Contains(item)) { return(false); } } return(true); }
/// <summary> /// Checks if the specified part of speech matches the set of instantiated parts of speech. /// </summary> /// <param name="pos">The part of speech.</param> /// <returns><c>true</c> if the specified part of speech matches, otherwise <c>false</c>.</returns> public bool MatchPOS(PartOfSpeech pos) { return(m_pos.Count == 0 || m_pos.Contains(pos)); }
public bool IsApplicable(WordSynthesis input) { return(m_requiredPOSs.Contains(input.POS)); }
/// <summary> /// Determines whether this group contains the specified MPR feature. /// </summary> /// <param name="mprFeature">The MPR feature.</param> /// <returns> /// <c>true</c> if this group contains the feature, otherwise <c>false</c>. /// </returns> public bool Contains(MPRFeature mprFeature) { return(m_mprFeatures.Contains(mprFeature)); }
/// <summary> /// Determines whether this subrule is applicable to the specified word analysis. /// </summary> /// <param name="input">The word analysis.</param> /// <param name="trace"> </param> /// <returns> /// <c>true</c> if this subrule is applicable, otherwise <c>false</c>. /// </returns> public bool IsApplicable(WordSynthesis input, Trace trace) { // check part of speech and MPR features bool fRequiredPOSMet = m_requiredPOSs == null || m_requiredPOSs.Count == 0 || m_requiredPOSs.Contains(input.POS); bool fRequiredMPRFeaturesMet = m_requiredMPRFeatures == null || m_requiredMPRFeatures.Count == 0 || m_requiredMPRFeatures.IsMatch(input.MPRFeatures); bool fExcludedMPRFeaturesMet = m_excludedMPRFeatures == null || m_excludedMPRFeatures.Count == 0 || !m_excludedMPRFeatures.IsMatch(input.MPRFeatures); if (trace != null) { if (!fRequiredPOSMet) { var badPosTrace = new PhonologicalRuleSynthesisRequiredPOSTrace(input.POS, m_requiredPOSs); trace.AddChild(badPosTrace); } if (!fRequiredMPRFeaturesMet) { var badRequiredMPRFeaturesTrace = new PhonologicalRuleSynthesisMPRFeaturesTrace( PhonologicalRuleSynthesisMPRFeaturesTrace.PhonologicalRuleSynthesisMPRFeaturesTraceType.REQUIRED, input.MPRFeatures, m_requiredMPRFeatures); trace.AddChild(badRequiredMPRFeaturesTrace); } if (!fExcludedMPRFeaturesMet) { var badExcludedMPRFeaturesTrace = new PhonologicalRuleSynthesisMPRFeaturesTrace( PhonologicalRuleSynthesisMPRFeaturesTrace.PhonologicalRuleSynthesisMPRFeaturesTraceType.EXCLUDED, input.MPRFeatures, m_excludedMPRFeatures); trace.AddChild(badExcludedMPRFeaturesTrace); } } return(fRequiredPOSMet && fRequiredMPRFeaturesMet && fExcludedMPRFeaturesMet); }