Пример #1
0
        public void Test()
        {
            var v = new PhonemeQuery(new[] { "a", "e", "i", "o", "u" });
            var c = new PhonemeQuery(new[] { "r", "t", "b", "l" });
            var q = new SequenceQuery(new IQuery[] { c, new MaybeQuery(c), v });

            var word = new Word(
                phonemes: new[] { "a", "t", "a", "b", "l", "e" },
                graphicalForms: null,
                fields: null);

            QueryAssert.NoMatch(q, word, 0);
            QueryAssert.IsMatch(q, word, 1, new[] { "t", "a" });
            QueryAssert.NoMatch(q, word, 2);
            QueryAssert.IsMatch(q, word, 3, new[] { "b", "l", "e" });
            QueryAssert.IsMatch(q, word, 4, new[] { "l", "e" });
            QueryAssert.NoMatch(q, word, 5);
            QueryAssert.NoMatch(q, word, 6);

            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, -1));
            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, 7));
        }
Пример #2
0
        public void TestScope()
        {
            var v = new PhonemeQuery(new[] { "a", "e", "i", "o", "u" });
            var c = new PhonemeQuery(new[] { "r", "s", "c", "b", "l" });
            var q = new SequenceQuery(new IQuery[] { c, new MaybeQuery(c), v });

            var word = new Word(
                phonemes: new[] { "s", "c", "r", "a", "b", "l", "e", "b", "l", "e" },
                graphicalForms: null,
                fields: null);

            var scope = new Interval(2, 6);

            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, 1, scope));
            QueryAssert.IsMatch(q, word, 2, new[] { "r", "a" }, scope);
            QueryAssert.NoMatch(q, word, 3, scope);
            QueryAssert.IsMatch(q, word, 4, new[] { "b", "l", "e" }, scope);
            QueryAssert.IsMatch(q, word, 5, new[] { "l", "e" }, scope);
            QueryAssert.NoMatch(q, word, 6, scope);
            QueryAssert.NoMatch(q, word, 7, scope);
            QueryAssert.NoMatch(q, word, 8, scope);
            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, 9, scope));
        }
Пример #3
0
        public void TestPhonemeSequence()
        {
            var v = new PhonemeQuery(new[] { "a", "e", "i", "o", "u" });
            var c = new PhonemeQuery(new[] { "r", "t", "b", "l" });
            var q = new SequenceQuery(new[] { c, v, c });

            var word = new Word(
                phonemes: new[] { "r", "a", "t", "a", "b", "l", "e" },
                graphicalForms: null,
                fields: null);

            QueryAssert.IsMatch(q, word, 0, new[] { "r", "a", "t" });
            QueryAssert.NoMatch(q, word, 1);
            QueryAssert.IsMatch(q, word, 2, new[] { "t", "a", "b" });
            QueryAssert.NoMatch(q, word, 3);
            QueryAssert.NoMatch(q, word, 4);
            QueryAssert.NoMatch(q, word, 5);
            QueryAssert.NoMatch(q, word, 6);
            QueryAssert.NoMatch(q, word, 7);

            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, -1));
            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, 8));
        }
Пример #4
0
        public void TestSequenceWithEndAnchor()
        {
            var e = new EndAnchorQuery();
            var v = new PhonemeQuery(new[] { "a", "e", "i", "o", "u" });
            var c = new PhonemeQuery(new[] { "r", "t", "b", "l" });
            var q = new SequenceQuery(new IQuery[] { c, c, v, e });

            var word = new Word(
                phonemes: new[] { "r", "a", "t", "a", "b", "l", "e" },
                graphicalForms: null,
                fields: null);

            QueryAssert.NoMatch(q, word, 0);
            QueryAssert.NoMatch(q, word, 1);
            QueryAssert.NoMatch(q, word, 2);
            QueryAssert.NoMatch(q, word, 3);
            QueryAssert.IsMatch(q, word, 4, new[] { "b", "l", "e" });
            QueryAssert.NoMatch(q, word, 5);
            QueryAssert.NoMatch(q, word, 6);
            QueryAssert.NoMatch(q, word, 7);

            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, -1));
            Assert.Throws <ArgumentOutOfRangeException>(() => q.Match(word, 8));
        }