private string RomaniseMedial(KoreanSyllable Syllable, KoreanSyllable?PrecedingSyllable, KoreanSyllable?SucceedingSyllable) { if (PrecedingSyllable != null && (PrecedingSyllable.Value.Medial == KoreanLetter.A || PrecedingSyllable.Value.Medial == KoreanLetter.O) && !PrecedingSyllable.Value.HasFinal && Syllable.Initial == KoreanLetter.Ieung && Syllable.Medial == KoreanLetter.E) { return("ë"); } return(MedialRomanisationRules.First(r => r.Medial == Syllable.Medial).Romanisation); }
public override string RomaniseSyllable(KoreanSyllable Syllable, KoreanSyllable?PrecedingSyllable = null, KoreanSyllable?SucceedingSyllable = null) { var StringBuilder1 = new StringBuilder(); StringBuilder1.Append(RomaniseInitial(Syllable)); StringBuilder1.Append(RomaniseMedial(Syllable)); StringBuilder1.Append(RomaniseFinal(Syllable, PrecedingSyllable, SucceedingSyllable)); return(StringBuilder1.ToString()); }
public string RomaniseTextBlock(TextBlock TextBlock1) { var StringBuilder1 = new StringBuilder(); foreach (var TextSection in TextBlock1.TextSections) { if (TextSection is KoreanTextSection) { var KoreanTextSection1 = TextSection as KoreanTextSection; var Syllables = KoreanTextSection1.Syllables.ToArray(); if (Syllables.Length > 1) { for (var i = 0; i < Syllables.Length; i++) { KoreanSyllable?PrecedingSyllable = null; KoreanSyllable Syllable = Syllables[i]; KoreanSyllable?SucceedingSyllable = null; var RomanisedText = ""; if (i > 0) { PrecedingSyllable = Syllables[i - 1]; } else if (i < Syllables.Length - 1) { SucceedingSyllable = Syllables[i + 1]; } RomanisedText = RomaniseSyllable(Syllable, PrecedingSyllable, SucceedingSyllable); StringBuilder1.Append(RomanisedText); } } else if (Syllables.Length == 1) { var RomanisedText = RomaniseSyllable(Syllables[0]); StringBuilder1.Append(RomanisedText); } } else if (TextSection is NonKoreanTextSection) { var Content = (TextSection as NonKoreanTextSection).Content; StringBuilder1.Append(Content); } } return(StringBuilder1.ToString()); }
/// <summary> /// Takes a text string and converts it into a text block of Korean and non-Korean text sections. /// </summary> /// <param name="Text"></param> /// <returns></returns> public TextBlock GetTextBlock(string Text) { var TextBlock1 = new TextBlock(); var KoreanTextSection1 = new KoreanTextSection(); var NonKoreanTextSection1 = new NonKoreanTextSection(); foreach (var Character in Text) { if (KoreanSyllable.IsAKoreanSyllable(Character)) { var Syllable = new KoreanSyllable(Character); if (NonKoreanTextSection1.Content != "") { TextBlock1.TextSections.Add(NonKoreanTextSection1); NonKoreanTextSection1 = new NonKoreanTextSection(); } KoreanTextSection1.Syllables.Add(Syllable); } else { if (KoreanTextSection1.Syllables.Any()) { TextBlock1.TextSections.Add(KoreanTextSection1); KoreanTextSection1 = new KoreanTextSection(); } NonKoreanTextSection1.Content += Character; } } if (NonKoreanTextSection1.Content != "") { TextBlock1.TextSections.Add(NonKoreanTextSection1); } if (KoreanTextSection1.Syllables.Any()) { TextBlock1.TextSections.Add(KoreanTextSection1); } return(TextBlock1); }
private string RomaniseFinal(KoreanSyllable Syllable, KoreanSyllable?PrecedingSyllable, KoreanSyllable?SucceedingSyllable) { if (Syllable.HasFinal) { if (SucceedingSyllable != null) { var PronunciationChangeRomanisationRule = FinalPronunciationChangeRomanisationRules.FirstOrDefault(r => r.Final == Syllable.Final && r.SucceedingInitial == SucceedingSyllable.Value.Initial); if (PronunciationChangeRomanisationRule != null) { return(PronunciationChangeRomanisationRule.Romanisation); } } return(FinalRomanisationRules.First(r => r.Final == Syllable.Final).Romanisation); } return(""); }
private string RomaniseInitial(KoreanSyllable Syllable, KoreanSyllable?PrecedingSyllable, KoreanSyllable?SucceedingSyllable) { if (PrecedingSyllable != null) { var PronunciationChangeRomanisationRule = InitialPronunciationChangeRomanisationRules.FirstOrDefault(r => r.PrecedingFinal == PrecedingSyllable.Value.Final && r.Initial == Syllable.Initial); if (PronunciationChangeRomanisationRule != null) { return(PronunciationChangeRomanisationRule.Romanisation); } } var IsSInitial = (Syllable.Initial == KoreanLetter.Shiot || Syllable.Initial == KoreanLetter.SsangShiot); if (UseSh && IsSInitial && IsIMedial(Syllable.Medial)) { return("sh"); } return(InitialRomanisationRules.First(r => r.Initial == Syllable.Initial).Romanisation); }
private string RomaniseMedial(KoreanSyllable Syllable) { return(MedialRomanisationRules.First(r => r.Medial == Syllable.Medial).Romanisation); }
private string RomaniseInitial(KoreanSyllable Syllable) { return(InitialRomanisationRules.First(r => r.Initial == Syllable.Initial).Romanisation); }
public abstract string RomaniseSyllable(KoreanSyllable Syllable, KoreanSyllable?PrecedingSyllable = null, KoreanSyllable?SucceedingSyllable = null);