public SyllableRuleList(SyllableRuleList srl) { this.startDate = srl.startDate; this.endDate = srl.endDate; this.syllrulList = srl.syllrulList; }
/// <summary> /// Silbentrennung /// </summary> public void SeparateSyllables() { /* alle gesetzten Silben zurücksetzen */ this.syllables = new List <Syllable>(); foreach (Sign s in this.phonetic) { s.SyllStart = false; s.SyllEnd = false; } foreach (Sign s in this.word) { s.SyllStart = false; s.SyllEnd = false; } SyllableRuleList syllrulList = null; foreach (SyllableRuleList srl in Functions.syllRuleList) { if ((this.time >= srl.StartDate) && (this.time <= srl.EndDate)) { syllrulList = new SyllableRuleList(srl); } } if (syllrulList == null) { Functions.ShowErrorMessage("Keine Silbentrennregel für das Jahr" + this.time + " gefunden"); } syllNum = 1; syllables = new List <Syllable>(); Syllable syll = new Syllable(); List <List <int?> > mapping = new List <List <int?> >(); /* Mapping löschen */ foreach (SignMapping sm in this.mappingList) { sm.SyllPos.Clear(); } /* für jedes Phone*/ for (int i = 0; i < this.phonetic.Count; i++) { bool nextLoop = false; syll.Syll.Add(phonetic[i]); /* Zwischenspeichern für Mapping: * Mapping-Index, PhonPos-Index, Silbe, Position in Silbe */ int mappingIndex = 99; int posInPhon = 99; foreach (SignMapping sm in this.mappingList) { foreach (int?iPhonPos in sm.PhonPos) { if (iPhonPos == null) { continue; } if ((int)iPhonPos == i) { mappingIndex = this.mappingList.IndexOf(sm); posInPhon = sm.PhonPos.IndexOf(iPhonPos); goto mappingIndexFound; } } } mappingIndexFound: mapping.Add(new List <int?> { mappingIndex, posInPhon }); /* für jede Trennregel*/ foreach (SyllableRule syllrul in syllrulList.SyllrulList) { List <List <int?> > mapping_c = new List <List <int?> >(Functions.DeepClone(mapping)); /* Wort ist kürzer als Muster*/ if (i + syllrul.Pattern.Length > this.phonetic.Count) { continue; } List <Sign> partOfWord = new List <Sign>(); Syllable syllEnd = new Syllable(); /* für jeden Regelteil*/ for (int j = 0; j < syllrul.Pattern.Length; j++) { if (i >= this.phonetic.Count) { break; } /* prüfe, ob Wortteil entspricht*/ partOfWord.Add(this.phonetic[i + j]); if ((j != 0) && (j <= (syllrul.PosOfBorder - 1))) { syllEnd.Syll.Add(phonetic[i + j]); } if (syllrul.FindSoundsInPattern(this.phonetic[i + j].Symbol, j) == false) { break; } /* Mapping für Zeichen zwischen erstem und letztem Regelteil */ if ((j != 0) && (j <= (syllrul.PosOfBorder - 1))) { foreach (SignMapping sm in this.mappingList) { foreach (int?iPhonPos in sm.PhonPos) { if (iPhonPos == null) { continue; } if ((int)iPhonPos == i + j) { mappingIndex = this.mappingList.IndexOf(sm); posInPhon = sm.PhonPos.IndexOf(iPhonPos); mapping_c.Add(new List <int?> { mappingIndex, posInPhon }); goto mappingIndexFound_c; } } } } mappingIndexFound_c: /* letzter Regelteil: Bedingungen prüfen*/ if (j == syllrul.Pattern.Length - 1) { if (syllrul.CheckConditions(partOfWord) == true) { /* Silbengrenzen setzen*/ this.phonetic[i + syllrul.PosOfBorder - 1].SyllEnd = true; this.word[i + syllrul.PosOfBorder - 1].SyllEnd = true; Syllable newSyll = syll.Concat(syllEnd); syllables.Add(newSyll); /* Mappen */ int posInSyll = 0; mapping = new List <List <int?> >(Functions.DeepClone(mapping_c)); foreach (List <int?> map in mapping) { for (int k = 0; k < (int)map[1]; k++) { if (mappingList[(int)map[0]].SyllPos.ElementAtOrDefault(k) == null) { mappingList[(int)map[0]].SyllPos.Add(new List <int?> { null, null }); } } mappingList[(int)map[0]].SyllPos.Add(new List <int?> { syllNum - 1, posInSyll }); posInSyll++; } syllNum++; syll = new Syllable(); syllEnd = new Syllable(); mapping = new List <List <int?> >(); i += syllrul.PosOfBorder - 1; if (this.phonetic.Count < i + 1) { this.phonetic[i + syllrul.PosOfBorder].SyllStart = true; } if (this.word.Count < i + 1) { this.word[i + syllrul.PosOfBorder].SyllStart = true; } nextLoop = true; break; } } } if (nextLoop == true) { break; } } } // /* letzte Silbe hinzufügen und mappen */ syllables.Add(syll); int posInSyll2 = 0; foreach (List <int?> map in mapping) { for (int k = 0; k < (int)map[1]; k++) { if ((int)map[0] >= mappingList.Count) { Functions.ShowErrorMessage("Mapping-Fehler in " + this.PrintWord("GraphOutputWord") + "!"); } else { if (mappingList[(int)map[0]].SyllPos.ElementAtOrDefault(k) == null) { mappingList[(int)map[0]].SyllPos.Add(new List <int?> { null, null }); } } } mappingList[(int)map[0]].SyllPos.Add(new List <int?> { syllNum - 1, posInSyll2 }); posInSyll2++; } }