Exemplo n.º 1
0
        public void SetMergedParagraphMarker(ISegmentPair segmentPair)
        {
            var translationOrigin = segmentPair.Properties.TranslationOrigin ?? _segmentBuilder.CreateTranslationOrigin();

            if (translationOrigin != null)
            {
                translationOrigin.OriginSystem = Constants.MergedParagraph;
            }

            segmentPair.Properties.TranslationOrigin = translationOrigin;
            segmentPair.Properties.IsLocked          = true;
        }
Exemplo n.º 2
0
 public SegmentPair(SegmentBuilder segmentBuilder)
 {
     ConfirmationLevel = ConfirmationLevel.Unspecified;
     TranslationOrigin = segmentBuilder.CreateTranslationOrigin();
     Source            = new Source();
     Target            = new Target();
 }
Exemplo n.º 3
0
        private ITranslationOrigin ReadPreviousTranslationOrigin(XmlReader xmlReader)
        {
            var translationOrigin = _segmentBuilder.CreateTranslationOrigin();

            var index = 0;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (index == 0 && string.Compare(xmlReader.Name, NsPrefix + ":prev-origin", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        index++;
                        while (xmlReader.MoveToNextAttribute())
                        {
                            if (string.Compare(xmlReader.Name, "origin", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                translationOrigin.OriginType = xmlReader.Value;
                            }
                            if (string.Compare(xmlReader.Name, "origin-system", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                translationOrigin.OriginSystem = xmlReader.Value;
                            }
                            if (string.Compare(xmlReader.Name, "percent", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                var success = byte.TryParse(xmlReader.Value, out var result);
                                translationOrigin.MatchPercent = success ? result : (byte)0;
                            }
                            if (string.Compare(xmlReader.Name, "struct-match", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                var success = bool.TryParse(xmlReader.Value, out var result);
                                translationOrigin.IsStructureContextMatch = success && result;
                            }
                            if (string.Compare(xmlReader.Name, "text-match", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                var success = Enum.TryParse <TextContextMatchLevel>(xmlReader.Value, true, out var result);
                                translationOrigin.TextContextMatchLevel = success ? result : TextContextMatchLevel.None;
                            }
                        }
                    }
                    if (string.Compare(xmlReader.Name, NsPrefix + ":prev-origin", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        translationOrigin.OriginBeforeAdaptation = ReadPreviousTranslationOrigin(xmlReaderSub);
                        xmlReaderSub.Close();
                    }

                    break;
                }
            }

            return(translationOrigin);
        }