Exemplo n.º 1
0
        public void TestMatchesWithLookBehindAndLookAhead()
        {
            var v = new PhonemeQuery(new[] { "a", "e", "i", "o", "u" });
            var c = new PhonemeQuery(new[] { "r", "t", "b", "l" });
            var q = new ContextualQuery(c, lookBehind: v, lookAhead: v);

            var word = new Word(Phonemes("r", "a", "t", "a", "b", "l", "e", "r", "a"), null, null);

            var matches  = q.Match(word).Map((string[] px) => string.Join(string.Empty, px)).ToArray();
            var expected = new[]
            {
                new Interval <string>(2, 1, "t"),
                new Interval <string>(7, 1, "r"),
            };

            Assert.Equal(expected, matches);
        }
Exemplo n.º 2
0
        public void TestMatches()
        {
            var v = new PhonemeQuery(new[] { "a", "e", "i", "o", "u" });
            var c = new PhonemeQuery(new[] { "r", "t", "b", "l" });
            var q = new ContextualQuery(new SequenceQuery(new[] { c, v, c }));

            var word = new Word(Phonemes("r", "a", "t", "a", "b", "l", "e", "r", "a"), null, null);

            var matches  = q.Match(word).Map((string[] px) => string.Join(string.Empty, px)).ToArray();
            var expected = new[]
            {
                new Interval <string>(0, 3, "rat"),
                new Interval <string>(5, 3, "ler"),
            };

            Assert.Equal(expected, matches);
        }
Exemplo n.º 3
0
        public void TestMatchesWithScope()
        {
            var t = new PhonemeQuery(new[] { "t" });
            var a = new PhonemeQuery(new[] { "a" });
            var q = new ContextualQuery(new SequenceQuery(new[] { t, a, t }),
                                        scope: "syllable");

            var word = new Word(
                Phonemes("t", "a", "t", "a", "t", "t", "a", "a", "t", "a", "t"), null,
                Fields(Field("syllable", Alignment.Parse("short:2 long:3 short:2 short:1 long:3"))));

            var matches  = q.Match(word).Map((string[] px) => string.Join(string.Empty, px)).ToArray();
            var expected = new[]
            {
                new Interval <string>(2, 3, "tat"),
                new Interval <string>(8, 3, "tat"),
            };

            Assert.Equal(expected, matches);
        }