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); } }
public EditUnnaturalClassViewModel(IDialogService dialogService, Segmenter segmenter, IEnumerable <SoundClass> soundClasses, UnnaturalClass unnaturalClass) : base("Edit Segment-based Class", soundClasses, unnaturalClass) { _dialogService = dialogService; _segmenter = segmenter; _ignoreModifiers = unnaturalClass.IgnoreModifiers; _segments = new BindableList <string>(unnaturalClass.Segments); _addSegmentCommand = new RelayCommand(AddSegment); _removeSegmentCommand = new RelayCommand(RemoveSegment, CanRemoveSegment); }