private static InlineString MatchTags(Dictionary <InlineTag, int> pool, InlineString target) { if (pool != null) { foreach (var tag in target.Tags) { int m; pool.TryGetValue(tag, out m); tag.Number = m; } } return(target); }
/// <summary> /// Wraps an inter-segment text in an XliffTransPair. /// </summary> /// <param name="text">Inter-segment text to wrap.</param> /// <returns>XliffTransPair instance that wraps the given text.</returns> private XliffTransPair InterSegmentPair(string text) { var inline = new InlineString(text); return(new XliffTransPair() { Serial = -1, Id = "*", Source = inline, Target = inline, SourceLang = SourceLang, TargetLang = TargetLang, }); }
private XliffTransPair ExtractMsegPair(XElement mseg) { var markup = new InlineString(mseg.Value); return(new XliffTransPair() { Serial = -1, Id = (string)mseg.Attribute("sequence"), Source = markup, Target = markup, SourceLang = SourceLang, TargetLang = TargetLang, }); }
private static Dictionary <InlineTag, int> NumberTags(InlineString source) { if (!source.HasTags) { return(null); } var pool = new Dictionary <InlineTag, int>(); int n = 0; foreach (var tag in source.Tags) { pool[tag] = tag.Number = ++n; } return(pool); }
protected void MatchTags(InlineString source, InlineString target) { var dict = new Dictionary <InlineTag, int>(InlineTag.LooseEqualityComparer); int i = 0; foreach (var tag in source.Tags) { dict[tag] = tag.Number = ++i; } foreach (var tag in target.Tags) { int j; dict.TryGetValue(tag, out j); tag.Number = j; } }
public InlineString AssignTagNumbers(InlineString inline) { foreach (var tag in inline.Tags) { if (Dict == null) { Dict = new Dictionary <InlineTag, int>(); } int number; if (!Dict.TryGetValue(tag, out number)) { number = Dict.Count + 1; Dict.Add(tag.Clone(), number); } tag.Number = number; } return(inline); }
protected XliffTransPair InterSegmentPair(InlineString inline) { // Give local numbers to tags in the inter-segment content. int i = 0; foreach (var tag in inline.Tags) { tag.Number = ++i; } return(new XliffTransPair() { Serial = -1, Id = "*", Source = inline, Target = inline, SourceLang = SourceLang, TargetLang = TargetLang, }); }
public SegmentData(InlineString inline) { InlineString = inline; }