当前位置: 首页>>代码示例>>C#>>正文


C# Match.GetPartition方法代码示例

本文整理汇总了C#中Match.GetPartition方法的典型用法代码示例。如果您正苦于以下问题:C# Match.GetPartition方法的具体用法?C# Match.GetPartition怎么用?C# Match.GetPartition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Match的用法示例。


在下文中一共展示了Match.GetPartition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Reorder

		void Reorder(Direction dir, Match match)
		{
			if (match.EntireMatch.Count == 0)
				return;

			PhoneticShapeNode first = null;
			PhoneticShapeNode last = null;
			switch (dir)
			{
				case Direction.RIGHT:
					first = match.EntireMatch[0];
					last = match.EntireMatch[match.EntireMatch.Count - 1];
					break;

				case Direction.LEFT:
					first = match.EntireMatch[match.EntireMatch.Count - 1];
					last = match.EntireMatch[0];
					break;
			}

			// remove the matching segments, so that we can reinsert them in the
			// new order
			PhoneticShapeNode cur = first.Prev;
			for (PhoneticShapeNode node = first; node != last.Next; node = node.Next)
				node.Remove();

			// reinsert the segments in the new order
			for (int i = 0; i < m_lhsTemp.Count; i++)
			{
				IList<PhoneticShapeNode> partNodes = match.GetPartition(i);
				if (partNodes == null)
					continue;

				IEnumerable<PhoneticShapeNode> partEnum = dir == Direction.RIGHT ? partNodes
					: ReverseNodes(partNodes);
				foreach (PhoneticShapeNode node in partEnum)
				{
					cur.Insert(node, Direction.RIGHT);
					cur = node;
				}
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:MetathesisRule.cs

示例2: Apply

		/// <summary>
		/// Applies the simple context to the input partition and copies it over to the output
		/// phonetic shape.
		/// </summary>
		/// <param name="match">The match.</param>
		/// <param name="input">The input word synthesis.</param>
		/// <param name="output">The output word synthesis.</param>
		/// <param name="morpheme">The morpheme info.</param>
		public override void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph)
		{
			IList<PhoneticShapeNode> nodes = match.GetPartition(m_partition);
			if (nodes != null && nodes.Count > 0)
			{
				Morph morph = null;
				if (allomorph != null)
				{
					morph = new Morph(allomorph);
					output.Morphs.Add(morph);
				}
				for (PhoneticShapeNode node = nodes[0]; node != nodes[nodes.Count - 1].Next; node = node.Next)
				{
					PhoneticShapeNode newNode = node.Clone();
					if (node.Type == PhoneticShapeNode.NodeType.SEGMENT)
					{
						Segment seg = newNode as Segment;
						// sets the context's features on the segment
						m_ctxt.Apply(seg, match.VariableValues);
						seg.IsClean = false;
						seg.Partition = morph == null ? -1 : morph.Partition;
					}
					if (morph != null)
						morph.Shape.Add(newNode.Clone());
					output.Shape.Add(newNode);
				}
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:36,代码来源:MorphologicalTransform.cs

示例3: Unapply

		/// <summary>
		/// Unapplies this transform to the specified partition in the specified match.
		/// </summary>
		/// <param name="match">The match.</param>
		/// <param name="partition">The partition.</param>
		/// <param name="output">The output.</param>
		public void Unapply(Match match, int partition, PhoneticShape output)
		{
			IList<PhoneticShapeNode> nodes = match.GetPartition(partition);
			if (nodes != null && nodes.Count > 0)
			{
				SimpleContext ctxt;
				if (!m_modifyFromCtxts.TryGetValue(partition, out ctxt))
					ctxt = null;

				foreach (PhoneticShapeNode node in nodes)
				{
					switch (node.Type)
					{
						case PhoneticShapeNode.NodeType.SEGMENT:
							Segment newSeg = new Segment(node as Segment);
							// if there is a modify-from context on this partition, unapply it
							if (ctxt != null)
								ctxt.Unapply(newSeg, match.VariableValues);
							output.Add(newSeg);
							break;

						case PhoneticShapeNode.NodeType.BOUNDARY:
							output.Add(node.Clone());
							break;
					}
				}
			}
			else
			{
				// untruncate a partition
				Untruncate(m_lhs[partition], output, false, match.VariableValues);
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:39,代码来源:MorphologicalTransform.cs


注:本文中的Match.GetPartition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。