Пример #1
0
        public void GetBoundaries_Word()
        {
            var parts = BreakIterator.GetBoundaries(BreakIterator.UBreakIteratorType.WORD, new Locale("en-US"), WordBoundaryTestData.Text);

            Assert.That(parts.Count(), Is.EqualTo(WordBoundaryTestData.ExpectedOnlyWords.Length));
            Assert.That(parts.ToArray(), Is.EquivalentTo(WordBoundaryTestData.ExpectedOnlyWords));
        }
Пример #2
0
        public void GetBoundaries_LocaleDependentBreakPoints_Line()
        {
            var text = "論‼";

            var parts = BreakIterator.GetBoundaries(BreakIterator.UBreakIteratorType.LINE, new Locale("ja@lb=loose"), text);

            // we only get 2 boundaries if the ja locale is passed correctly
            Assert.That(parts.Count(), Is.EqualTo(2));
        }
Пример #3
0
        public void GetBoundaries_Sentence()
        {
            var text     = "Aa bb. Ccdef 3.5 x? Y?x! Z";
            var expected = new[] {
                new Boundary(0, 7), new Boundary(7, 20), new Boundary(20, 22), new Boundary(22, 25), new Boundary(25, 26)
            };

            var parts = BreakIterator.GetBoundaries(BreakIterator.UBreakIteratorType.SENTENCE, new Locale("en-US"), text);

            Assert.That(parts.Count(), Is.EqualTo(expected.Length));
            Assert.That(parts.ToArray(), Is.EquivalentTo(expected));
        }
Пример #4
0
        public void GetBoundaries_Character()
        {
            var text     = "abc? 1";
            var expected = new[] {
                new Boundary(0, 1), new Boundary(1, 2), new Boundary(2, 3), new Boundary(3, 4), new Boundary(4, 5), new Boundary(5, 6)
            };

            var parts = BreakIterator.GetBoundaries(BreakIterator.UBreakIteratorType.CHARACTER, new Locale("en-US"), text);

            Assert.That(parts.Count(), Is.EqualTo(expected.Length));
            Assert.That(parts.ToArray(), Is.EquivalentTo(expected));
        }
Пример #5
0
        public void GetWordAndLineBoundariesWithHyphenatedText()
        {
            var text          = "Good-day, kind sir !";
            var expectedWords = new[] {
                new Boundary(0, 4), new Boundary(5, 8), new Boundary(10, 14), new Boundary(15, 18)
            };
            var expectedLines = new[] {
                new Boundary(0, 5), new Boundary(5, 10), new Boundary(10, 15), new Boundary(15, 20)
            };

            var wordBoundaries = BreakIterator.GetBoundaries(BreakIterator.UBreakIteratorType.WORD, new Locale("en-US"), text);
            var lineBoundaries = BreakIterator.GetBoundaries(BreakIterator.UBreakIteratorType.LINE, new Locale("en-US"), text);

            Assert.That(wordBoundaries.Count(), Is.EqualTo(expectedWords.Length));
            Assert.That(wordBoundaries.ToArray(), Is.EquivalentTo(expectedWords));

            Assert.That(lineBoundaries.Count(), Is.EqualTo(expectedLines.Length));
            Assert.That(lineBoundaries.ToArray(), Is.EquivalentTo(expectedLines));
        }