private void CombineWith(ShapeNode node, ShapeNode start, ShapeNode end) { if ((CombineVowels && node.Type() == CogFeatureSystem.VowelType) || (CombineConsonants && node.Type() == CogFeatureSystem.ConsonantType)) { var strRep = new StringBuilder(); var origStrRep = new StringBuilder(); strRep.Append(node.StrRep()); origStrRep.Append(node.OriginalStrRep()); ShapeNode n = start; while (n != end.Next) { strRep.Append(n.StrRep()); origStrRep.Append(n.OriginalStrRep()); node.Annotation.FeatureStruct.Add(n.Annotation.FeatureStruct); n = n.Next; } node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.StrRep, strRep.ToString()); node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.OriginalStrRep, origStrRep.ToString()); node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.SegmentType, CogFeatureSystem.Complex); FeatureStruct firstFS; if (start.IsComplex()) { firstFS = start.Annotation.FeatureStruct.GetValue(CogFeatureSystem.First); } else { firstFS = new FeatureStruct(); foreach (Feature feature in start.Annotation.FeatureStruct.Features.Where(f => !CogFeatureSystem.Instance.ContainsFeature(f))) { firstFS.AddValue(feature, start.Annotation.FeatureStruct.GetValue(feature)); } } node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.First, firstFS); } else { ShapeNode n = start; while (n != end.Next) { var newNode = n.Clone(); node.AddAfter(newNode); node = newNode; n = n.Next; } } }
protected ShapeNode Combine(FeatureSymbol syllablePosition, Shape newShape, ShapeNode start, ShapeNode end) { ShapeNode newStart = null; if (start == end) { newStart = start.DeepClone(); newStart.Annotation.FeatureStruct.AddValue(CogFeatureSystem.SyllablePosition, syllablePosition); newShape.Add(newStart); } else if ((_combineVowels && syllablePosition == CogFeatureSystem.Nucleus) || (_combineConsonants && syllablePosition != CogFeatureSystem.Nucleus)) { var fs = start.Annotation.FeatureStruct.DeepClone(); var strRep = new StringBuilder(); var origStrRep = new StringBuilder(); strRep.Append(start.StrRep()); origStrRep.Append(start.OriginalStrRep()); ShapeNode node = start.Next; bool isComplex = false; while (node != end.Next) { strRep.Append(node.StrRep()); origStrRep.Append(node.OriginalStrRep()); fs.Add(node.Annotation.FeatureStruct); node = node.Next; isComplex = true; } fs.AddValue(CogFeatureSystem.StrRep, strRep.ToString()); fs.AddValue(CogFeatureSystem.OriginalStrRep, origStrRep.ToString()); fs.AddValue(CogFeatureSystem.SegmentType, isComplex ? CogFeatureSystem.Complex : CogFeatureSystem.Simple); fs.AddValue(CogFeatureSystem.SyllablePosition, syllablePosition); if (isComplex) { FeatureStruct firstFS; if (start.IsComplex()) { firstFS = start.Annotation.FeatureStruct.GetValue(CogFeatureSystem.First); } else { firstFS = new FeatureStruct(); foreach (Feature feature in start.Annotation.FeatureStruct.Features.Where(f => !CogFeatureSystem.Instance.ContainsFeature(f))) { firstFS.AddValue(feature, start.Annotation.FeatureStruct.GetValue(feature)); } } fs.AddValue(CogFeatureSystem.First, firstFS); } newStart = newShape.Add(fs); } else { ShapeNode node = start; while (node != end.Next) { var newNode = node.DeepClone(); newNode.Annotation.FeatureStruct.AddValue(CogFeatureSystem.SyllablePosition, syllablePosition); newShape.Add(newNode); if (newStart == null) { newStart = newNode; } node = node.Next; } } Debug.Assert(newStart != null); return(newStart); }
private void CombineWith(ShapeNode node, ShapeNode start, ShapeNode end) { if ((CombineVowels && node.Type() == CogFeatureSystem.VowelType) || (CombineConsonants && node.Type() == CogFeatureSystem.ConsonantType)) { var strRep = new StringBuilder(); var origStrRep = new StringBuilder(); strRep.Append(node.StrRep()); origStrRep.Append(node.OriginalStrRep()); ShapeNode n = start; while (n != end.Next) { strRep.Append(n.StrRep()); origStrRep.Append(n.OriginalStrRep()); node.Annotation.FeatureStruct.Add(n.Annotation.FeatureStruct); n = n.Next; } node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.StrRep, strRep.ToString()); node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.OriginalStrRep, origStrRep.ToString()); node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.SegmentType, CogFeatureSystem.Complex); FeatureStruct firstFS; if (start.IsComplex()) { firstFS = start.Annotation.FeatureStruct.GetValue(CogFeatureSystem.First); } else { firstFS = new FeatureStruct(); foreach (Feature feature in start.Annotation.FeatureStruct.Features.Where(f => !CogFeatureSystem.Instance.ContainsFeature(f))) firstFS.AddValue(feature, start.Annotation.FeatureStruct.GetValue(feature)); } node.Annotation.FeatureStruct.AddValue(CogFeatureSystem.First, firstFS); } else { ShapeNode n = start; while (n != end.Next) { var newNode = n.DeepClone(); node.AddAfter(newNode); node = newNode; n = n.Next; } } }