コード例 #1
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="aKopie"></param>
 public TranscriptionParagraph(TranscriptionParagraph aKopie)
     : this()
 {
     this.Begin           = aKopie.Begin;
     this.End             = aKopie.End;
     this.trainingElement = aKopie.trainingElement;
     this.DataAttributes  = aKopie.DataAttributes;
     if (aKopie.Phrases != null)
     {
         this.Phrases = new VirtualTypeList <TranscriptionPhrase>(this, this._children);
         for (int i = 0; i < aKopie.Phrases.Count; i++)
         {
             this.Phrases.Add(new TranscriptionPhrase(aKopie.Phrases[i]));
         }
     }
     this.Speaker = aKopie.Speaker;
 }
コード例 #2
0
        public static TranscriptionSection DeserializeV2(XElement e, bool isStrict)
        {
            TranscriptionSection tsec = new TranscriptionSection();

            tsec.Name     = e.Attribute("name").Value;
            tsec.Elements = e.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value);
            tsec.Elements.Remove("name");
            foreach (var p in e.Elements(isStrict ? "paragraph" : "pa").Select(p => (TranscriptionElement)TranscriptionParagraph.DeserializeV2(p, isStrict)))
            {
                tsec.Add(p);
            }

            return(tsec);
        }
コード例 #3
0
        /// <summary>
        /// V2 deserialization beware of local variable names
        /// </summary>
        /// <param name="e"></param>
        /// <param name="isStrict"></param>
        /// <returns></returns>
        public static TranscriptionParagraph DeserializeV2(XElement e, bool isStrict)
        {
            TranscriptionParagraph par = new TranscriptionParagraph();

            par._internalID     = int.Parse(e.Attribute(isStrict ? "speakerid" : "s").Value);
            par.AttributeString = (e.Attribute(isStrict ? "attributes" : "a") ?? EmptyAttribute).Value;

            par.Elements = e.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value);
            par.Elements.Remove(isStrict ? "begin" : "b");
            par.Elements.Remove(isStrict ? "end" : "e");
            par.Elements.Remove(isStrict ? "attributes" : "a");
            par.Elements.Remove(isStrict ? "speakerid" : "s");


            e.Elements(isStrict ? "phrase" : "p").Select(p => (TranscriptionElement)TranscriptionPhrase.DeserializeV2(p, isStrict)).ToList().ForEach(p => par.Add(p));;

            if (e.Attribute(isStrict ? "attributes" : "a") != null)
            {
                par.AttributeString = e.Attribute(isStrict ? "attributes" : "a").Value;
            }

            if (e.Attribute(isStrict ? "begin" : "b") != null)
            {
                string val = e.Attribute(isStrict ? "begin" : "b").Value;
                int    ms;
                if (int.TryParse(val, out ms))
                {
                    par.Begin = TimeSpan.FromMilliseconds(ms);
                }
                else
                {
                    par.Begin = XmlConvert.ToTimeSpan(val);
                }
            }
            else
            {
                var ch = par._children.FirstOrDefault();
                par.Begin = ch == null ? TimeSpan.Zero : ch.Begin;
            }

            if (e.Attribute(isStrict ? "end" : "e") != null)
            {
                string val = e.Attribute(isStrict ? "end" : "e").Value;
                int    ms;
                if (int.TryParse(val, out ms))
                {
                    par.End = TimeSpan.FromMilliseconds(ms);
                }
                else
                {
                    par.End = XmlConvert.ToTimeSpan(val);
                }
            }
            else
            {
                var ch = par._children.LastOrDefault();
                par.End = ch == null ? TimeSpan.Zero : ch.Begin;
            }

            return(par);
        }
コード例 #4
0
 public ParagraphLanguageAction(TranscriptionParagraph changedParagraph, TranscriptionIndex changeIndex, int changeAbsoluteIndex, string oldLanguage)
     : base(ChangeType.Modify, changedParagraph, changeIndex, changeAbsoluteIndex)
 {
     _oldLanguage = oldLanguage;
 }
コード例 #5
0
 public ParagraphAttibutesAction(TranscriptionParagraph changedParagraph, TranscriptionIndex changeIndex, int changeAbsoluteIndex, ParagraphAttributes oldAttributes)
     : base(ChangeType.Modify, changedParagraph, changeIndex, changeAbsoluteIndex)
 {
     _oldAttributes = oldAttributes;
 }
コード例 #6
0
 public ParagraphSpeakerAction(TranscriptionParagraph changedParagraph, TranscriptionIndex changeIndex, int changeAbsoluteIndex, Speaker oldSpeaker)
     : base(ChangeType.Modify, changedParagraph, changeIndex, changeAbsoluteIndex)
 {
     _oldSpeaker = oldSpeaker;
 }