本文整理汇总了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;
}
}
}
示例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);
}
}
}
示例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);
}
}