Ejemplo n.º 1
0
        public void Segments_MissingMiddleSourceSegment_ReturnsSegments()
        {
            var sourceText = new MemoryText("text1", new[]
            {
                new TextSegment(new TextSegmentRef(1, 1), "source segment 1 1 .".Split()),
                new TextSegment(new TextSegmentRef(1, 3), "source segment 1 3 .".Split())
            });
            var targetText = new MemoryText("text1", new[]
            {
                new TextSegment(new TextSegmentRef(1, 1), "target segment 1 1 .".Split()),
                new TextSegment(new TextSegmentRef(1, 2), "target segment 1 2 .".Split()),
                new TextSegment(new TextSegmentRef(1, 3), "target segment 1 3 .".Split())
            });
            var alignments = new MemoryTextAlignmentCollection("text1", new[]
            {
                new TextAlignment(new TextSegmentRef(1, 1), new[] { new AlignedWordPair(0, 0) }),
                new TextAlignment(new TextSegmentRef(1, 3), new[] { new AlignedWordPair(2, 2) })
            });

            var parallelText = new ParallelText(sourceText, targetText, alignments);

            ParallelTextSegment[] segments = parallelText.Segments.ToArray();
            Assert.That(segments.Length, Is.EqualTo(2));
            Assert.That(segments[0].SourceSegment, Is.EqualTo("source segment 1 1 .".Split()));
            Assert.That(segments[0].TargetSegment, Is.EqualTo("target segment 1 1 .".Split()));
            Assert.That(segments[0].AlignedWordPairs, Is.EquivalentTo(new[] { new AlignedWordPair(0, 0) }));
            Assert.That(segments[1].SourceSegment, Is.EqualTo("source segment 1 3 .".Split()));
            Assert.That(segments[1].TargetSegment, Is.EqualTo("target segment 1 3 .".Split()));
            Assert.That(segments[1].AlignedWordPairs, Is.EquivalentTo(new[] { new AlignedWordPair(2, 2) }));
        }
Ejemplo n.º 2
0
        public void Segments_NoSegments_ReturnsEmpty()
        {
            var sourceText   = new MemoryText("text1", Enumerable.Empty <TextSegment>());
            var targetText   = new MemoryText("text1", Enumerable.Empty <TextSegment>());
            var parallelText = new ParallelText(sourceText, targetText);

            Assert.That(parallelText.Segments, Is.Empty);
        }