Пример #1
0
        public void SingleWordTest()
        {
            var str        = "Hello";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Single(boundaries);
            Assert.Equal(0, boundaries[0]);
        }
Пример #2
0
        public void CombinedLettersAndDigits()
        {
            var str        = "Hello99 World";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Equal(2, boundaries.Count);
            Assert.Equal(0, boundaries[0]);
            Assert.Equal(8, boundaries[1]);
        }
Пример #3
0
        public void TwoWordTest()
        {
            var str        = "Hello World";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Equal(2, boundaries.Count);
            Assert.Equal(0, boundaries[0]);
            Assert.Equal(6, boundaries[1]);
        }
Пример #4
0
        public void Punctuation2()
        {
            var str        = "Hello () World";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Equal(3, boundaries.Count);
            Assert.Equal(0, boundaries[0]);
            Assert.Equal(6, boundaries[1]);
            Assert.Equal(9, boundaries[2]);
        }
Пример #5
0
        public void TestIsWordBoundary()
        {
            var str = new Utf32Buffer("Hello () World").AsSlice();

            // Get the boundaries (assuming FindWordBoundaries is correct)
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(str).ToList();

            var boundaries2 = new List <int>();

            for (int i = 0; i < str.Length; i++)
            {
                if (WordBoundaryAlgorithm.IsWordBoundary(str.SubSlice(0, i), str.SubSlice(i, str.Length - i)))
                {
                    boundaries2.Add(i);
                }
            }

            Assert.Equal(boundaries, boundaries2);
        }