Exemplo n.º 1
0
 private void AppendItem(Bit bit)
 {
     XmlElement el = doc.CreateElement((bit.MismatchType == MismatchType.Match) ? "Identity" : "Change");
     if (bit.MismatchType != MismatchType.Match)
     {
         el.Attributes.Append(CreateAttribute("Type", ((int)bit.MismatchType).ToString()));
         el.Attributes.Append(CreateAttribute("Number", currentChangeNum.ToString()));
         currentChangeNum++;
     }
     XmlElement subEl = doc.CreateElement("PlainText");
     el.AppendChild(subEl);
     subEl.InnerText = bit.Text;
     root.AppendChild(el);
 }
Exemplo n.º 2
0
        private List<Bit> Process(string taggedText)
        {
            // first replace '<<>' and '<>>'

            List<Bit> result = new List<Bit>();

            int iPos = 0;
            while (iPos < taggedText.Length)
            {
                int iNext = taggedText.IndexOf("<S:", iPos);
                if (iNext == -1)
                {
                    Bit newBit = new Bit(taggedText.Substring(iPos), MismatchType.Match);
                    result.Add(newBit);
                    break;
                }
                else if (iNext > iPos)
                {
                    Bit newBit = new Bit(taggedText.Substring(iPos, iNext - iPos), MismatchType.Match);
                    result.Add(newBit);
                }
                int textStartPos = taggedText.IndexOf('>', iNext) + 1;
                int textEndPos = taggedText.IndexOf("</S>", textStartPos);
                MismatchType mmt = ParseMismatchType(taggedText.Substring(iNext, textStartPos - iNext));
                result.Add( new Bit(taggedText.Substring(textStartPos, textEndPos - textStartPos), mmt));

                iPos = textEndPos + 4;
            }

            return result;
        }