Ejemplo n.º 1
0
        public void IsMapped_ImplicitComplexSegments()
        {
            var segmentPool = new SegmentPool();

            var mappings = new ListSegmentMappings(_segmenter, new[]
                {
                    UnorderedTuple.Create("m", "n"),
                    UnorderedTuple.Create("t", "-"),
                    UnorderedTuple.Create("h#", "-#"),
                    UnorderedTuple.Create("c", "#g"),
                    UnorderedTuple.Create("f", "@")
                }, true);

            Shape shape1 = _segmenter.Segment("s͡mat͡h");
            Shape shape2 = _segmenter.Segment("k͡no");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, segmentPool.Get(shape2.First), shape2.First.Next), Is.True);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last, new Ngram<Segment>(), shape2.Last.Next), Is.True);
            Assert.That(mappings.IsMapped(shape1.First, segmentPool.Get(shape1.First.Next), shape1.Last, shape2.First, segmentPool.Get(shape2.Last), shape2.Last.Next), Is.False);

            shape1 = _segmenter.Segment("got͡h");
            shape2 = _segmenter.Segment("c͡lo");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, segmentPool.Get(shape2.First), shape2.First.Next), Is.True);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last, new Ngram<Segment>(), shape2.Last.Next), Is.True);

            shape1 = _segmenter.Segment("s͡hog");
            shape2 = _segmenter.Segment("oc͡t");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, new Ngram<Segment>(), shape2.First), Is.False);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last.Prev, segmentPool.Get(shape2.Last), shape2.Last.Next), Is.False);
        }
Ejemplo n.º 2
0
        public void IsMapped()
        {
            var segmentPool = new SegmentPool();

            var mappings = new ListSegmentMappings(_segmenter, new[]
                {
                    UnorderedTuple.Create("m", "n"),
                    UnorderedTuple.Create("t", "-"),
                    UnorderedTuple.Create("h#", "-#"),
                    UnorderedTuple.Create("c", "#g"),
                    UnorderedTuple.Create("f", "@"),
                    UnorderedTuple.Create("a", "o"),
                    UnorderedTuple.Create("Cw", "-V")
                }, false);

            Shape shape1 = _segmenter.Segment("ma͡et");
            Shape shape2 = _segmenter.Segment("no");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, segmentPool.Get(shape2.First), shape2.First.Next), Is.True);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last, new Ngram<Segment>(), shape2.Last.Next), Is.True);
            Assert.That(mappings.IsMapped(shape1.First, segmentPool.Get(shape1.First.Next), shape1.Last, shape2.First, segmentPool.Get(shape2.Last), shape2.Last.Next), Is.False);

            shape1 = _segmenter.Segment("goh");
            shape2 = _segmenter.Segment("co");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, segmentPool.Get(shape2.First), shape2.First.Next), Is.True);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last, new Ngram<Segment>(), shape2.Last.Next), Is.True);

            shape1 = _segmenter.Segment("hog");
            shape2 = _segmenter.Segment("oc");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, new Ngram<Segment>(), shape2.First), Is.False);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last.Prev, segmentPool.Get(shape2.Last), shape2.Last.Next), Is.False);

            shape1 = _segmenter.Segment("swat");
            shape2 = _segmenter.Segment("sat");

            Assert.That(mappings.IsMapped(shape1.ElementAt(0), segmentPool.Get(shape1.ElementAt(1)), shape1.ElementAt(2), shape2.ElementAt(0), new Ngram<Segment>(), shape2.ElementAt(1)), Is.True);

            shape1 = _segmenter.Segment("sawat");
            shape2 = _segmenter.Segment("saat");
            Assert.That(mappings.IsMapped(shape1.ElementAt(1), segmentPool.Get(shape1.ElementAt(2)), shape1.ElementAt(3), shape2.ElementAt(1), new Ngram<Segment>(), shape2.ElementAt(2)), Is.False);
        }
Ejemplo n.º 3
0
        public void NoMappings()
        {
            var segmentPool = new SegmentPool();

            var mappings = new ListSegmentMappings(_segmenter, new UnorderedTuple<string, string>[0], false);

            Shape shape1 = _segmenter.Segment("mat");
            Shape shape2 = _segmenter.Segment("no");

            Assert.That(mappings.IsMapped(shape1.First.Prev, segmentPool.Get(shape1.First), shape1.First.Next, shape2.First.Prev, segmentPool.Get(shape2.First), shape2.First.Next), Is.False);
            Assert.That(mappings.IsMapped(shape1.Last.Prev, segmentPool.Get(shape1.Last), shape1.Last.Next, shape2.Last, new Ngram<Segment>(), shape2.Last.Next), Is.False);
        }