/// <summary> /// Copy constructor. /// </summary> /// <param name="nestedPattern">The nested pattern.</param> public NestedPhoneticPattern(NestedPhoneticPattern nestedPattern) : base(nestedPattern) { m_pattern = new PhoneticPattern(nestedPattern.m_pattern); m_minOccur = nestedPattern.m_minOccur; m_maxOccur = nestedPattern.m_maxOccur; }
PhoneticPattern GenerateChangePartition(PhoneticPattern lhs, PhoneticPattern rhs) { PhoneticPattern result = new PhoneticPattern(); foreach (PhoneticPatternNode node in lhs) { switch (node.Type) { case PhoneticPatternNode.NodeType.SIMP_CTXT: PhoneticPattern temp = new PhoneticPattern(); temp.Add(node.Clone()); // generates the RHS template the same way that phonological rules generate their // RHS analysis targets result.AddMany(rhs.Combine(temp)); break; case PhoneticPatternNode.NodeType.PATTERN: NestedPhoneticPattern nestedPattern = node as NestedPhoneticPattern; PhoneticPattern pattern = GenerateChangePartition(nestedPattern.Pattern, rhs); NestedPhoneticPattern newNestedPattern = new NestedPhoneticPattern(pattern, nestedPattern.MinOccur, nestedPattern.MaxOccur); result.Add(newNestedPattern); break; } } return(result); }
void Untruncate(PhoneticPattern lhs, PhoneticShape output, bool optional, VariableValues instantiatedVars) { // create segments from the LHS partition pattern and append them to the output foreach (PhoneticPatternNode node in lhs) { switch (node.Type) { case PhoneticPatternNode.NodeType.SIMP_CTXT: SimpleContext ctxt = node as SimpleContext; Segment newSeg = ctxt.UnapplyDeletion(instantiatedVars); newSeg.IsOptional = optional; output.Add(newSeg); break; case PhoneticPatternNode.NodeType.PATTERN: NestedPhoneticPattern nestedPattern = node as NestedPhoneticPattern; // untruncate nested partitions the maximum number of times it can occur, // marking any segments that occur after the minimum number of occurrences // as optional for (int j = 0; j < nestedPattern.MaxOccur; j++) { Untruncate(nestedPattern.Pattern, output, j >= nestedPattern.MinOccur, instantiatedVars); } break; case PhoneticPatternNode.NodeType.BDRY_CTXT: // skip boundaries break; } } }
/// <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); }
public bool Equals(NestedPhoneticPattern other) { if (other == null) { return(false); } return(m_pattern.Equals(other.m_pattern) && m_minOccur == other.m_minOccur && m_maxOccur == other.m_maxOccur); }