public EditNaturalClassViewModel(FeatureSystem featSys, IEnumerable<SoundClass> soundClasses, NaturalClass naturalClass) : base("Edit Feature-based Class", soundClasses, naturalClass) { _type = naturalClass.Type == CogFeatureSystem.ConsonantType ? SoundType.Consonant : SoundType.Vowel; _availableFeatures = new BindableList<FeatureViewModel>(); _activeFeatures = new BindableList<FeatureViewModel>(); foreach (SymbolicFeature feature in featSys.OfType<SymbolicFeature>()) { SymbolicFeatureValue sfv; if (naturalClass.FeatureStruct.TryGetValue(feature, out sfv)) _activeFeatures.Add(new FeatureViewModel(feature, (FeatureSymbol) sfv)); else _availableFeatures.Add(new FeatureViewModel(feature)); } _addCommand = new RelayCommand(AddFeature, CanAddFeature); _removeCommand = new RelayCommand(RemoveFeature, CanRemoveFeature); }
public void Migrate(SegmentPool segmentPool, CogProject project) { // add prenasal superscript for n project.Segmenter.Consonants.AddSymbolBasedOn("ⁿ", "n"); foreach (KeyValuePair<string, IProcessor<Variety>> kvp in project.VarietyProcessors.Where(kvp => kvp.Value is SspSyllabifier).ToArray()) { var syllabifier = (SspSyllabifier) kvp.Value; SonorityClass[] scale = syllabifier.SonorityScale.OrderBy(sc => sc.Sonority).ThenBy(sc => sc.SoundClass.Name).ToArray(); // if the user has changed the sonority scale preserve their changes and do not update if (HasSonorityScaleChanged(project, scale)) continue; // add prenasal sonority class var newScale = new List<SonorityClass> {new SonorityClass(1, new UnnaturalClass("Prenasal", new[] {"ᵐ", "ⁿ", "ᵑ"}, false, project.Segmenter))}; foreach (SonorityClass sc in scale) { SoundClass newClass; switch (sc.SoundClass.Name) { case "Glide": // correct the ignore modifiers flag on the "Glide" class newClass = new UnnaturalClass("Glide", new[] {"j", "ɥ", "ɰ", "w"}, true, project.Segmenter); break; case "Open vowel": // correct the height feature value on the "Open vowel" class newClass = new NaturalClass("Open vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("open").Value); break; default: newClass = sc.SoundClass; break; } // increment sonority for all existing classes newScale.Add(new SonorityClass(sc.Sonority + 1, newClass)); } project.VarietyProcessors[kvp.Key] = new SspSyllabifier(syllabifier.CombineVowels, syllabifier.CombineConsonants, syllabifier.VowelsSameSonorityTautosyllabic, segmentPool, newScale); } }