public void IsWithinRange()
        {
            int contextSizeChars = 5;
            string testStr = "alama";
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, testStr),
                new PositionTextPair(contextSizeChars, testStr),
                new PositionTextPair(contextSizeChars * 2 + testStr.Length - 1, testStr),
                new PositionTextPair(contextSizeChars * 2 + testStr.Length, testStr),
                new PositionTextPair(contextSizeChars * 2 + testStr.Length + 1, testStr)
            };
            PositionTextPairGroup group = new PositionTextPairGroup(pairs[0], contextSizeChars);

            Assert.IsTrue(group.IsWithinRange(pairs[0], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[1], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[2], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[3], contextSizeChars));
            Assert.IsFalse(group.IsWithinRange(pairs[4], contextSizeChars));

            group = new PositionTextPairGroup(pairs[4], contextSizeChars);

            Assert.IsFalse(group.IsWithinRange(pairs[0], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[1], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[2], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[3], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[4], contextSizeChars));
        }
        public void IsWithinRange()
        {
            int    contextSizeChars = 5;
            string testStr          = "alama";

            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, testStr),
                new PositionTextPair(contextSizeChars, testStr),
                new PositionTextPair(contextSizeChars * 2 + testStr.Length - 1, testStr),
                new PositionTextPair(contextSizeChars * 2 + testStr.Length, testStr),
                new PositionTextPair(contextSizeChars * 2 + testStr.Length + 1, testStr)
            };
            PositionTextPairGroup group = new PositionTextPairGroup(pairs[0], contextSizeChars);

            Assert.IsTrue(group.IsWithinRange(pairs[0], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[1], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[2], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[3], contextSizeChars));
            Assert.IsFalse(group.IsWithinRange(pairs[4], contextSizeChars));

            group = new PositionTextPairGroup(pairs[4], contextSizeChars);

            Assert.IsFalse(group.IsWithinRange(pairs[0], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[1], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[2], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[3], contextSizeChars));
            Assert.IsTrue(group.IsWithinRange(pairs[4], contextSizeChars));
        }
Ejemplo n.º 3
0
        public void Overlaps()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "ala"),
                new PositionTextPair(1, "lama"),
                new PositionTextPair(3, "ma"),
                new PositionTextPair(4, "akota")
            };

            Assert.IsTrue(pairs[0].OverlapsOrIsAdjacentTo(pairs[1]));
            Assert.IsTrue(pairs[1].OverlapsOrIsAdjacentTo(pairs[0]));
            Assert.IsTrue(pairs[0].OverlapsOrIsAdjacentTo(pairs[2]));
            Assert.IsTrue(pairs[2].OverlapsOrIsAdjacentTo(pairs[0]));
            Assert.IsFalse(pairs[0].OverlapsOrIsAdjacentTo(pairs[3]));
            Assert.IsFalse(pairs[3].OverlapsOrIsAdjacentTo(pairs[0]));
        }
Ejemplo n.º 4
0
        public void Merge_Substring_CommonEnd()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "alama"),
                new PositionTextPair(2, "ama"),
                new PositionTextPair(0, "alama"),
                new PositionTextPair(2, "ama")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("alama", pairs[0].text);
            Assert.AreEqual(2, pairs[1].position);
            Assert.AreEqual("ama", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("alama", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("alama", pairs[2].text);
        }
Ejemplo n.º 5
0
        public void Merge_Overlapping()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "ma"),
                new PositionTextPair(1, "ala"),
                new PositionTextPair(0, "ma"),
                new PositionTextPair(1, "ala"),
                new PositionTextPair(20, "alama"),
                new PositionTextPair(24, "ala"),
                new PositionTextPair(20, "alama"),
                new PositionTextPair(24, "ala")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("mala", pairs[0].text);
            Assert.AreEqual(1, pairs[1].position);
            Assert.AreEqual("ala", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("mala", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("ma", pairs[2].text);

            pairs[4].Merge(pairs[5]);
            pairs[7].Merge(pairs[6]);

            Assert.AreEqual(20, pairs[4].position);
            Assert.AreEqual("alamala", pairs[4].text);
            Assert.AreEqual(24, pairs[5].position);
            Assert.AreEqual("ala", pairs[5].text);

            Assert.AreEqual(20, pairs[7].position);
            Assert.AreEqual("alamala", pairs[7].text);
            Assert.AreEqual(20, pairs[6].position);
            Assert.AreEqual("alama", pairs[6].text);
        }
Ejemplo n.º 6
0
        public void Merge_Adjacent()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "ala"),
                new PositionTextPair(3, "ma"),
                new PositionTextPair(0, "ala"),
                new PositionTextPair(3, "ma")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("alama", pairs[0].text);
            Assert.AreEqual(3, pairs[1].position);
            Assert.AreEqual("ma", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("alama", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("ala", pairs[2].text);
        }
Ejemplo n.º 7
0
        public void Merge_Substring_CommonStart()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "alama"),
                new PositionTextPair(0, "ala"),
                new PositionTextPair(0, "alama"),
                new PositionTextPair(0, "ala")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("alama", pairs[0].text);
            Assert.AreEqual(0, pairs[1].position);
            Assert.AreEqual("ala", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("alama", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("alama", pairs[2].text);
        }
Ejemplo n.º 8
0
        public void Merge_Overlapping()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "ma"),
                new PositionTextPair(1, "ala"),
                new PositionTextPair(0, "ma"),
                new PositionTextPair(1, "ala"),
                new PositionTextPair(20, "alama"),
                new PositionTextPair(24, "ala"),
                new PositionTextPair(20, "alama"),
                new PositionTextPair(24, "ala")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("mala", pairs[0].text);
            Assert.AreEqual(1, pairs[1].position);
            Assert.AreEqual("ala", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("mala", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("ma", pairs[2].text);

            pairs[4].Merge(pairs[5]);
            pairs[7].Merge(pairs[6]);

            Assert.AreEqual(20, pairs[4].position);
            Assert.AreEqual("alamala", pairs[4].text);
            Assert.AreEqual(24, pairs[5].position);
            Assert.AreEqual("ala", pairs[5].text);

            Assert.AreEqual(20, pairs[7].position);
            Assert.AreEqual("alamala", pairs[7].text);
            Assert.AreEqual(20, pairs[6].position);
            Assert.AreEqual("alama", pairs[6].text);
        }
Ejemplo n.º 9
0
        public void Merge_Adjacent()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "ala"),
                new PositionTextPair(3, "ma"),
                new PositionTextPair(0, "ala"),
                new PositionTextPair(3, "ma")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("alama", pairs[0].text);
            Assert.AreEqual(3, pairs[1].position);
            Assert.AreEqual("ma", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("alama", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("ala", pairs[2].text);
        }
Ejemplo n.º 10
0
        public void Merge_Substring_Inside()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "alama"),
                new PositionTextPair(1, "lam"),
                new PositionTextPair(0, "alama"),
                new PositionTextPair(1, "lam")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("alama", pairs[0].text);
            Assert.AreEqual(1, pairs[1].position);
            Assert.AreEqual("lam", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("alama", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("alama", pairs[2].text);
        }
Ejemplo n.º 11
0
        public void Overlaps()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "ala"),
                new PositionTextPair(1, "lama"),
                new PositionTextPair(3, "ma"),
                new PositionTextPair(4, "akota")
            };

            Assert.IsTrue(pairs[0].OverlapsOrIsAdjacentTo(pairs[1]));
            Assert.IsTrue(pairs[1].OverlapsOrIsAdjacentTo(pairs[0]));
            Assert.IsTrue(pairs[0].OverlapsOrIsAdjacentTo(pairs[2]));
            Assert.IsTrue(pairs[2].OverlapsOrIsAdjacentTo(pairs[0]));
            Assert.IsFalse(pairs[0].OverlapsOrIsAdjacentTo(pairs[3]));
            Assert.IsFalse(pairs[3].OverlapsOrIsAdjacentTo(pairs[0]));
        }
Ejemplo n.º 12
0
        public void Merge_Substring_Inside()
        {
            PositionTextPair[] pairs = new PositionTextPair[] {
                new PositionTextPair(0, "alama"),
                new PositionTextPair(1, "lam"),
                new PositionTextPair(0, "alama"),
                new PositionTextPair(1, "lam")
            };

            pairs[0].Merge(pairs[1]);
            pairs[3].Merge(pairs[2]);

            Assert.AreEqual(0, pairs[0].position);
            Assert.AreEqual("alama", pairs[0].text);
            Assert.AreEqual(1, pairs[1].position);
            Assert.AreEqual("lam", pairs[1].text);

            Assert.AreEqual(0, pairs[3].position);
            Assert.AreEqual("alama", pairs[3].text);
            Assert.AreEqual(0, pairs[2].position);
            Assert.AreEqual("alama", pairs[2].text);
        }