Exemplo n.º 1
0
 /// <summary>
 /// Applies the specified variables that occur in the instantiated variables to the specified feature bundle.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <param name="variables">The variables.</param>
 /// <param name="instantiatedVars">The instantiated variables.</param>
 public void ApplyCurrent(FeatureBundle fb, IDictionary <string, bool> variables, VariableValues instantiatedVars)
 {
     foreach (KeyValuePair <string, bool> varPolarity in variables)
     {
         Feature feature = m_varFeatures[varPolarity.Key];
         ICollection <FeatureValue> varValues = instantiatedVars.GetValues(varPolarity.Key);
         if (varValues.Count > 0)
         {
             foreach (FeatureValue value in GetCurVarFeatValue(feature, varValues, varPolarity.Value))
             {
                 fb.Set(value, true);
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Enumerates thru all of the possible values for the specified variable.
        /// </summary>
        /// <param name="variableName">The variable.</param>
        /// <param name="polarity">The variable polarity.</param>
        /// <param name="instantiatedVars">The instantiated variables.</param>
        /// <returns>An enumerable of feature values.</returns>
        IEnumerable <FeatureValue> GetVarFeatValue(string variableName, bool polarity, VariableValues instantiatedVars)
        {
            Feature feature = m_varFeatures[variableName];

            ICollection <FeatureValue> varValues = instantiatedVars.GetValues(variableName);

            if (varValues.Count > 0)
            {
                // variable is instantiated, so only check already instantiated values
                foreach (FeatureValue value in GetCurVarFeatValue(feature, varValues, polarity))
                {
                    yield return(value);
                }
            }
            else
            {
                foreach (FeatureValue value in feature.PossibleValues)
                {
                    // if polarity is true, then values must be the same, otherwise they must be different
                    if (polarity)
                    {
                        yield return(value);
                    }
                    else
                    {
                        foreach (FeatureValue value2 in feature.PossibleValues)
                        {
                            if (value2 != value)
                            {
                                yield return(value2);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
		/// <summary>
		/// Enumerates thru all of the possible values for the specified variable.
		/// </summary>
		/// <param name="variableName">The variable.</param>
		/// <param name="polarity">The variable polarity.</param>
		/// <param name="instantiatedVars">The instantiated variables.</param>
		/// <returns>An enumerable of feature values.</returns>
		IEnumerable<FeatureValue> GetVarFeatValue(string variableName, bool polarity, VariableValues instantiatedVars)
		{
			Feature feature = m_varFeatures[variableName];

			ICollection<FeatureValue> varValues = instantiatedVars.GetValues(variableName);
			if (varValues.Count > 0)
			{
				// variable is instantiated, so only check already instantiated values
				foreach (FeatureValue value in GetCurVarFeatValue(feature, varValues, polarity))
					yield return value;
			}
			else
			{
				foreach (FeatureValue value in feature.PossibleValues)
				{
					// if polarity is true, then values must be the same, otherwise they must be different
					if (polarity)
					{
						yield return value;
					}
					else
					{
						foreach (FeatureValue value2 in feature.PossibleValues)
						{
							if (value2 != value)
								yield return value2;
						}
					}
				}
			}
		}
Exemplo n.º 4
0
		/// <summary>
		/// Applies the specified variables that occur in the instantiated variables to the specified feature bundle.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <param name="variables">The variables.</param>
		/// <param name="instantiatedVars">The instantiated variables.</param>
		public void ApplyCurrent(FeatureBundle fb, IDictionary<string, bool> variables, VariableValues instantiatedVars)
		{
			foreach (KeyValuePair<string, bool> varPolarity in variables)
			{
				Feature feature = m_varFeatures[varPolarity.Key];
				ICollection<FeatureValue> varValues = instantiatedVars.GetValues(varPolarity.Key);
				if (varValues.Count > 0)
				{
					foreach (FeatureValue value in GetCurVarFeatValue(feature, varValues, varPolarity.Value))
						fb.Set(value, true);
				}
			}
		}