コード例 #1
0
ファイル: SimpleContext.cs プロジェクト: bbriggs/FieldWorks
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="ctxt">The simple context.</param>
		public SimpleContext(SimpleContext ctxt)
			: base(ctxt)
		{
			m_featSys = ctxt.m_featSys;
			m_featureValues = new FeatureBundle(ctxt.m_featureValues);
			m_antiFeatureValues = new FeatureBundle(ctxt.m_antiFeatureValues);
		}
コード例 #2
0
			/// <summary>
			/// Checks for overlap of features between the specified simple context and the specified
			/// environment.
			/// </summary>
			/// <param name="ctxt">The simple context.</param>
			/// <param name="envSeq">The environment.</param>
			/// <returns>
			/// 	<c>true</c> if there is no overlap, otherwise <c>false</c>.
			/// </returns>
			bool IsNonSelfOpaquing(SimpleContext ctxt, PhoneticPattern env)
			{
				foreach (PhoneticPatternNode node in env)
				{
					switch (node.Type)
					{
						case PhoneticPatternNode.NodeType.SIMP_CTXT:
							SimpleContext envCtxt = node as SimpleContext;
							if (!envCtxt.FeatureValues.IsDisjoint(ctxt.AntiFeatureValues))
								return false;
							break;

						case PhoneticPatternNode.NodeType.BDRY_CTXT:
							break;

						case PhoneticPatternNode.NodeType.PATTERN:
							NestedPhoneticPattern optSeq = node as NestedPhoneticPattern;
							if (!IsNonSelfOpaquing(ctxt, optSeq.Pattern))
								return false;
							break;
					}
				}

				return true;
			}
コード例 #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ModifyFromInput"/> class.
		/// </summary>
		/// <param name="partition">The partition to modify.</param>
		/// <param name="ctxt">The simple context.</param>
		/// <param name="morpher">The morpher.</param>
		public ModifyFromInput(int partition, SimpleContext ctxt, Morpher morpher)
		{
			m_partition = partition;
			m_ctxt = ctxt;
			m_morpher = morpher;
		}
コード例 #4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="InsertSimpleContext"/> class.
		/// </summary>
		/// <param name="ctxt">The simple context.</param>
		public InsertSimpleContext(SimpleContext ctxt)
		{
			m_ctxt = ctxt;
		}
コード例 #5
0
ファイル: NaturalClass.cs プロジェクト: bbriggs/FieldWorks
		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;
		}
コード例 #6
0
ファイル: SimpleContext.cs プロジェクト: bbriggs/FieldWorks
		protected virtual SimpleContext CombineFeatures(SimpleContext ctxt)
		{
			SimpleContext result = Clone() as SimpleContext;

			// collect all of the possible values of the features
			List<FeatureValue> featVals = new List<FeatureValue>();
			foreach (Feature feature in Owner.Features)
				featVals.AddRange(feature.PossibleValues);
			// create a mask feature bundle from all possible values
			FeatureBundle mask = new FeatureBundle(featVals, m_featSys);

			FeatureBundle temp = ctxt.FeatureValues.Clone();
			// remove features referenced in the this pattern's context
			temp.RemoveValues(mask);
			// add remaining features from the specified pattern's context to this pattern's context
			result.FeatureValues.AddValues(temp);
			// remove anti features referenced in the specified pattern's context from this pattern's context
			result.AntiFeatureValues.RemoveValues(ctxt.AntiFeatureValues);
			return result;
		}
コード例 #7
0
ファイル: SimpleContext.cs プロジェクト: bbriggs/FieldWorks
		public SimpleContext Combine(SimpleContext ctxt)
		{
			if (m_featSys.HasFeatures)
				return CombineFeatures(ctxt);
			else
				return Clone() as SimpleContext;
		}