Ejemplo n.º 1
0
        private void ProcessSyllableWithMaximalOnset(ShapeNode startNode, ShapeNode endNode, Shape newShape)
        {
            ShapeNode node       = startNode;
            ShapeNode onsetStart = node;

            while (node.Type() == CogFeatureSystem.ConsonantType && node != endNode.Next)
            {
                node = node.Next;
            }
            ShapeNode onsetEnd = node.Prev;

            if (onsetStart != node && onsetStart != onsetEnd)
            {
                ShapeNode n = onsetStart;
                if (onsetStart != onsetEnd.List.First)
                {
                    for (; n != onsetEnd.Next; n = n.Next)
                    {
                        string onsetStr = n.GetNodes(onsetEnd).StrRep();
                        if (_initialOnsets.Value.Contains(onsetStr))
                        {
                            break;
                        }
                    }

                    // TODO: ambiguous onset, what should we do? For now, we just assume maximal onset
                    if (n == onsetEnd.Next)
                    {
                        n = onsetStart;
                    }
                }
                if (n != onsetStart)
                {
                    if (onsetStart.Prev.Type() == CogFeatureSystem.ConsonantType)
                    {
                        CombineWith(newShape.GetLast(nd => nd.Type() == CogFeatureSystem.ConsonantType), onsetStart, n.Prev);
                    }
                    else
                    {
                        Combine(CogFeatureSystem.Coda, newShape, onsetStart, n.Prev);
                        Annotation <ShapeNode> prevSyllableAnn = newShape.Annotations.Last(ann => ann.Type() == CogFeatureSystem.SyllableType);
                        prevSyllableAnn.Remove();
                        newShape.Annotations.Add(prevSyllableAnn.Range.Start, newShape.Last, FeatureStruct.New().Symbol(CogFeatureSystem.SyllableType).Value);
                    }
                    startNode = n;
                }
            }

            ProcessSyllable(startNode, endNode, newShape);
        }