public TextGridLine(TextGridInterval interval)
 {
     XMin    = interval.XMin;
     XMax    = interval.XMax;
     Item    = interval.Item;
     Content = interval.Content;
 }
        private static IEnumerable <string> OutputInterval(TextGridInterval interval1, TextGridInterval interval2)
        {
            yield return($"[{interval1.XMin} {interval1.XMax}] S1 <{interval1.Item}> {GetContent(interval1)} <{interval1.Item}/>");

            yield return($"[{interval1.XMin} {interval1.XMax}] S1 <{interval2.Item}> {GetContent(interval2)} <{interval2.Item}/>");
        }
        private static IEnumerable <TextGridInterval> GetIntervalsNew(IEnumerable <string> textgridText)
        {
            TextGridInterval interval   = new TextGridInterval();
            bool             inSg       = false;
            bool             inHg       = false;
            bool             inInterval = false;

            foreach (string s in textgridText)
            {
                string sRaw = GetRaw(s);
                if (sRaw == "name=\"sg\"")
                {
                    inSg = true;
                    inHg = false;
                    continue;
                }
                if (sRaw == "name=\"hg\"")
                {
                    inHg = true;
                    inSg = false;
                    continue;
                }
                if (!inSg && !inHg)
                {
                    continue;
                }
                if (inSg && inHg)
                {
                    throw new CommonException("Item wrong, cannot be both in SG and HG.");
                }
                if (sRaw.StartsWith("item["))
                {
                    inInterval = false;
                    if (inSg)
                    {
                        interval.Item = SG_TAG;
                    }
                    else
                    {
                        interval.Item = HG_TAG;
                    }
                    yield return(interval);

                    continue;
                }
                if (IntervalReg.IsMatch(s))
                {
                    if (inInterval)
                    {
                        if (inSg)
                        {
                            interval.Item = SG_TAG;
                        }
                        else
                        {
                            interval.Item = HG_TAG;
                        }
                        yield return(interval);
                    }
                    interval   = new TextGridInterval();
                    inInterval = true;
                    continue;
                }
                if (inInterval)
                {
                    if (sRaw.StartsWith("xmin="))
                    {
                        interval.XMin = sRaw.Split('=')[1];
                        continue;
                    }
                    if (sRaw.StartsWith("xmax="))
                    {
                        interval.XMax = sRaw.Split('=')[1];
                        continue;
                    }
                    if (sRaw.StartsWith("text="))
                    {
                        Sanity.Requires(interval.ContentList == null, "Content is not empty");
                        interval.ContentList = new List <string>();
                        interval.ContentList.Add(s.Split('=')[1]);
                        continue;
                    }
                    else
                    {
                        interval.ContentList.Add(s);
                    }
                }
            }
            if (inSg)
            {
                interval.Item = SG_TAG;
            }
            else
            {
                interval.Item = HG_TAG;
            }
            yield return(interval);
        }
 private static string GetContent(TextGridInterval interval)
 {
     return(string.Join(" ", interval.ContentList).Trim(' ', '"'));
 }