Esempio n. 1
0
        private bool HasSonorityScaleChanged(CogProject project, SonorityClass[] scale)
        {
            SonorityClass[] origSonorityScale = {
                    new SonorityClass(1, new NaturalClass("Stop", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("stop").Symbol("nasal-").Value)),
                    new SonorityClass(2, new NaturalClass("Affricate", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("affricate").Value)),
                    new SonorityClass(3, new NaturalClass("Fricative", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("fricative").Symbol("lateral-").Value)),
                    new SonorityClass(4, new NaturalClass("Nasal", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("nasal+").Value)),
                    new SonorityClass(5, new NaturalClass("Trill", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("trill").Value)),
                    new SonorityClass(6, new NaturalClass("Lateral", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("lateral+").Value)),
                    new SonorityClass(7, new NaturalClass("Flap", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("flap").Value)),
                    new SonorityClass(8, new UnnaturalClass("Glide", new[] {"j", "ɥ", "ɰ", "w"}, false, project.Segmenter)),
                    new SonorityClass(8, new NaturalClass("Non-syllabic vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic-").Value)),
                    new SonorityClass(9, new NaturalClass("Close vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("close").Value)),
                    new SonorityClass(10, new NaturalClass("Near-close vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("near-close").Value)),
                    new SonorityClass(11, new NaturalClass("Close-mid vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("close-mid").Value)),
                    new SonorityClass(12, new NaturalClass("Mid vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("mid").Value)),
                    new SonorityClass(13, new NaturalClass("Open-mid vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("open-mid").Value)),
                    new SonorityClass(14, new NaturalClass("Near-open vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("near-open").Value)),
                    new SonorityClass(15, new NaturalClass("Open vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("open-vowel").Value))
                };

            if (origSonorityScale.Length != scale.Length)
                return true;

            for (int i = 0; i < origSonorityScale.Length; i++)
            {
                SonorityClass origClass = origSonorityScale[i];
                SonorityClass curClass = scale[i];
                if (origClass.Sonority != curClass.Sonority || origClass.SoundClass.Name != curClass.SoundClass.Name)
                    return true;

                var origNC = origClass.SoundClass as NaturalClass;
                if (origNC != null)
                {
                    var curNC = curClass.SoundClass as NaturalClass;
                    if (curNC == null)
                        return true;
                    FeatureStruct origFS1 = origNC.FeatureStruct;
                    FeatureStruct origFS2 = null;
                    // the original open vowel class can have the height set to open or the manner set to open-vowel
                    if (origNC.Name == "Open vowel")
                        origFS2 = FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("open").Value;
                    if (!origFS1.ValueEquals(curNC.FeatureStruct) && (origFS2 == null || !origFS2.ValueEquals(curNC.FeatureStruct)))
                        return true;
                }
                else
                {
                    var origUC = (UnnaturalClass) origClass.SoundClass;
                    var curUC = curClass.SoundClass as UnnaturalClass;
                    if (curUC == null || !origUC.Segments.SequenceEqual(curUC.Segments))
                        return true;
                }
            }
            return false;
        }
Esempio n. 2
0
        public void Migrate_ModifiedSspSyllabifier_SspSyllabifierNotUpdated()
        {
            var oldSyllabifier = (SspSyllabifier) _project.VarietyProcessors[ComponentIdentifiers.Syllabifier];
            SonorityClass[] oldScale = oldSyllabifier.SonorityScale.ToArray();
            oldScale[0] = new SonorityClass(1, new NaturalClass("Stop", FeatureStruct.New(_project.FeatureSystem).Symbol(CogFeatureSystem.ConsonantType).Symbol("stop").Value));
            var newSyllabifier = new SspSyllabifier(oldSyllabifier.CombineVowels, oldSyllabifier.CombineConsonants, oldSyllabifier.VowelsSameSonorityTautosyllabic,
                _segmentPool, oldScale);
            _project.VarietyProcessors[ComponentIdentifiers.Syllabifier] = newSyllabifier;

            var pm = new ProjectMigration4();
            pm.Migrate(_segmentPool, _project);
            Assert.That(_project.VarietyProcessors[ComponentIdentifiers.Syllabifier], Is.EqualTo(newSyllabifier));
        }
Esempio n. 3
0
        public void Migrate_SettingsSspSyllabifier_SspSyllabifierUpdated()
        {
            var oldSyllabifier = (SspSyllabifier) _project.VarietyProcessors[ComponentIdentifiers.Syllabifier];
            SonorityClass[] oldScale = oldSyllabifier.SonorityScale.ToArray();
            oldScale[7] = new SonorityClass(8, new UnnaturalClass("Glide", new[] {"j", "ɥ", "ɰ", "w"}, true, _project.Segmenter));
            oldScale[15] = new SonorityClass(15, new NaturalClass("Open vowel", FeatureStruct.New(_project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("open").Symbol("syllabic+").Value));
            var newSyllabifier = new SspSyllabifier(oldSyllabifier.CombineVowels, oldSyllabifier.CombineConsonants, oldSyllabifier.VowelsSameSonorityTautosyllabic,
                _segmentPool, oldScale);
            _project.VarietyProcessors[ComponentIdentifiers.Syllabifier] = newSyllabifier;

            var pm = new ProjectMigration4();
            pm.Migrate(_segmentPool, _project);
            var syllabifier = (SspSyllabifier) _project.VarietyProcessors[ComponentIdentifiers.Syllabifier];
            SonorityClass[] scale = syllabifier.SonorityScale.ToArray();
            Assert.That(scale.Length, Is.EqualTo(17));
            Assert.That(scale[0].SoundClass.Name, Is.EqualTo("Prenasal"));
        }