public TranscriptionPhrase(TranscriptionPhrase kopie) { this._begin = kopie._begin; this._end = kopie._end; this._text = kopie._text; this._phonetics = kopie._phonetics; this.height = kopie.height; }
/// <summary> /// V2 serialization /// </summary> /// <param name="e"></param> /// <param name="isStrict"></param> public static TranscriptionPhrase DeserializeV2(XElement e, bool isStrict) { TranscriptionPhrase phr = new TranscriptionPhrase(); phr.Elements = e.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value); phr.Elements.Remove(isStrict ? "begin" : "b"); phr.Elements.Remove(isStrict ? "end" : "e"); phr.Elements.Remove(isStrict ? "fon" : "f"); phr._phonetics = (e.Attribute(isStrict ? "fon" : "f") ?? EmptyAttribute).Value; phr._text = e.Value.Trim('\r', '\n'); if (e.Attribute(isStrict ? "begin" : "b") != null) { string val = e.Attribute(isStrict ? "begin" : "b").Value; int ms; if (int.TryParse(val, out ms)) { phr.Begin = TimeSpan.FromMilliseconds(ms); } else { phr.Begin = XmlConvert.ToTimeSpan(val); } } if (e.Attribute(isStrict ? "end" : "e") != null) { string val = e.Attribute(isStrict ? "end" : "e").Value; int ms; if (int.TryParse(val, out ms)) { phr.End = TimeSpan.FromMilliseconds(ms); } else { phr.End = XmlConvert.ToTimeSpan(val); } } return(phr); }
/// <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); }
public PhrasePhoneticsAction(TranscriptionPhrase changedelement, TranscriptionIndex changeIndex, int changeAbsoluteIndex, string oldphonetics) : base(ChangeType.Modify, changedelement, changeIndex, changeAbsoluteIndex) { _oldtstring = oldphonetics; }