예제 #1
0
        private Realization ToRealization(string phonemeStr)
        {
            var phonemes  = phonemeStr.SplitPhonemes().Select(s => Phonemes.BySymbol(s)).ToArray();
            var syllables = _syllabifier.Compute(phonemes).ToArray();

            return(new Realization(phonemeStr, syllables));
        }
예제 #2
0
        public void TestParallelPairs(string s1, string s2, string op, string s3, string s4)
        {
            var p1 = Phonemes.BySymbol(s1);
            var p2 = Phonemes.BySymbol(s2);
            var p3 = Phonemes.BySymbol(s3);
            var p4 = Phonemes.BySymbol(s4);

            var d1 = _distance.GetDistance(p1, p2);
            var d2 = _distance.GetDistance(p3, p4);

            if (op == "=")
            {
                Assert.True(d1 == d2, $"d({p1}, {p2}) = {d1} ≠ {d2} = d({p3}, {p4})");
            }
            else if (op == "<")
            {
                Assert.True(d1 < d2, $"d({p1}, {p2}) = {d1} ≮ {d2} = d({p3}, {p4})");
            }
            else if (op == ">")
            {
                Assert.True(d1 > d2, $"d({p1}, {p2}) = {d1} ≯ {d2} = d({p3}, {p4})");
            }
            else
            {
                throw new NotImplementedException();
            }
        }
예제 #3
0
        public void TestMinimalPairs(string s1, string s2)
        {
            var p1 = Phonemes.BySymbol(s1);
            var p2 = Phonemes.BySymbol(s2);

            var d1 = _distance.GetDistance(p1, p2);

            foreach ((var q1, var q2) in _points.UnorderedPairs())
            {
                var d = _distance.GetDistance(q1, q2);
                Assert.True(d1 <= d, $"d({p1}, {p2}) = {d1} should be minimal but d({q1}, {q2}) = {d}.");
            }
        }
예제 #4
0
        public void TestMinimalPairs(string s1, string s2)
        {
            var p1 = Phonemes.BySymbol(s1);
            var p2 = Phonemes.BySymbol(s2);

            var d1 = _distance.GetDistance(p1, p2);

            foreach ((var q1, var q2) in Phonemes.Vowels.UnorderedPairs())
            {
                var d = _distance.GetDistance(q1, q2);
                Assert.True(d1 <= d, $"d(/{s1}/, /{s2}/) = {d1} should be minimal but d(/{q1.Symbol}/, /{q2.Symbol}/) = {d}.");
            }
        }
예제 #5
0
        public void TestCompute()
        {
            var syllabifier = new Syllabifier();

            var phonemes = "stʁil.bjuʁ.goz.dʁɥi.fwastχ";
            var input    = string.Join("", phonemes.Split('.')).ToCharArray().Select(c => Phonemes.BySymbol(c.ToString())).ToArray();

            var expected = new[]
            {
                new Syllable(
                    onset: new [] { Phonemes.s, Phonemes.t, Phonemes.R, },
                    nucleus: Phonemes.i,
                    coda: new [] { Phonemes.l, }),
                new Syllable(
                    onset: new [] { Phonemes.b, Phonemes.j, },
                    nucleus: Phonemes.u,
                    coda: new [] { Phonemes.R, }),
                new Syllable(
                    onset: new [] { Phonemes.g, },
                    nucleus: Phonemes.o,
                    coda: new [] { Phonemes.z, }),
                new Syllable(
                    onset: new [] { Phonemes.d, Phonemes.R, Phonemes.Y, },
                    nucleus: Phonemes.i,
                    coda: new Phoneme[0]),
                new Syllable(
                    onset: new [] { Phonemes.f, Phonemes.w, },
                    nucleus: Phonemes.a,
                    coda: new [] { Phonemes.s, Phonemes.t, Phonemes.X, }),
            };

            var result = syllabifier.Compute(input).ToArray();

            Assert.Equal(expected.Length, result.Length);
        }
예제 #6
0
 private static Neighborhood <Phoneme> Of(string center, params string[][] circles) =>
 new Neighborhood <Phoneme>(
     Phonemes.BySymbol(center),
     circles.Select(ps => ps.Select(p => Phonemes.BySymbol(p)).ToArray()).ToArray());