Beispiel #1
0
        protected void btnCompress_Click(object sender, EventArgs e)
        {
            string toConvert = Server.HtmlEncode(txtInput.Text);

            Dictionary <string, string> target;

            if (TargetLanguage.SelectedValue == "Latin")
            {
                target = Recode.GetLatinRelex();
            }
            else if (TargetLanguage.SelectedValue == "Russian")
            {
                target = Recode.GetRussianRelex();
            }
            else if (TargetLanguage.SelectedValue == "Icelandic")
            {
                target = Recode.GetIcelandicRelex();
            }
            else
            {
                target = Recode.GetEnglishRelex();
            }

            StringBuilder sb = new StringBuilder();

            foreach (var foo in target)
            {
                sb.Append(foo.Key.ToLower());
                sb.Append("\t");
                sb.Append(foo.Value);
                sb.Append("\n");
            }
            RelexDictionary.Controls.Add(new Literal {
                Text = sb.ToString()
            });
            string relexFirstPass = recoder.ShortenToAnyDictionary(
                toConvert,
                target,
                Recode.ModifierStyle.CapitalizeFirst,
                Recode.PunctuationStyle.Western
                ).Replace("\n", "<br/>");

            if (phonotactics.SelectedValue == "forceTp")
            {
                TransliterateEngine transliterator = new TransliterateEngine();
                string trace;
                relexFirstPass = transliterator.Transliterate(
                    relexFirstPass,
                    out trace,
                    TransliterateEngine.DefaultOptions()).ToLower();
            }


            txtOutput.Text = relexFirstPass;
        }
Beispiel #2
0
        void TransliterateCommand(object sender, CommandEventArgs e)
        {
            string input = HttpUtility.HtmlEncode(ToTransliterate.Text);
            TransliterateEngine transliterator = new TransliterateEngine();
            string        trace;
            List <string> list = new List <string>();

            StringBuilder sb = new StringBuilder();

            sb.Append("<br/>");
            sb.Append("<b>Default Options:  </b>");
            string result = transliterator.Transliterate(input, out trace, TransliterateEngine.DefaultOptions());

            list.Add(result);
            sb.Append(result);
            sb.Append("<br/>");

            if (input.Contains("r") || input.Contains("R"))
            {
                Options r = TransliterateEngine.DefaultOptions();
                r.RLanguage = LanguageForR.FrenchGerman;
                result      = transliterator.Transliterate(input, out trace, r);

                if (!list.Contains(result))
                {
                    sb.Append("<b>French German R:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }


                r.RLanguage = LanguageForR.TrilledTapped;
                result      = transliterator.Transliterate(input, out trace, r);
                if (!list.Contains(result))
                {
                    sb.Append("<b>Trilled Tapped R:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }
            }

            Options vowels = TransliterateEngine.DefaultOptions();

            vowels.VowelCluster = ClusterPreference.Split;
            result = transliterator.Transliterate(input, out trace, vowels);
            if (!list.Contains(result))
            {
                sb.Append("<b>Split vowels:  </b>");
                sb.Append(result);
                sb.Append("<br/>");
                list.Add(result);
            }


            if (input.Contains("r") || input.Contains("R"))
            {
                Options r = TransliterateEngine.DefaultOptions();
                r.RLanguage    = LanguageForR.FrenchGerman;
                r.VowelCluster = ClusterPreference.Split;
                result         = transliterator.Transliterate(input, out trace, r);

                if (!list.Contains(result))
                {
                    sb.Append("<b>French German R, split vowels:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }


                r.RLanguage    = LanguageForR.TrilledTapped;
                r.VowelCluster = ClusterPreference.Split;
                result         = transliterator.Transliterate(input, out trace, r);

                if (!list.Contains(result))
                {
                    sb.Append("<b>Trilled Tapped R, split vowels:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }
            }



            Options consontants = TransliterateEngine.DefaultOptions();

            consontants.ConsonantCluster = ClusterPreference.Split;
            result = transliterator.Transliterate(input, out trace, consontants);
            if (!list.Contains(result))
            {
                sb.Append("<b>Split consonants: </b> ");
                sb.Append(result);
                sb.Append("<br/>");
                list.Add(result);
            }


            if (input.Contains("r") || input.Contains("R"))
            {
                Options r = TransliterateEngine.DefaultOptions();
                r.RLanguage        = LanguageForR.FrenchGerman;
                r.ConsonantCluster = ClusterPreference.Split;
                result             = transliterator.Transliterate(input, out trace, r);

                if (!list.Contains(result))
                {
                    sb.Append("<b>French German R, split consonants:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }


                r.RLanguage        = LanguageForR.TrilledTapped;
                r.ConsonantCluster = ClusterPreference.Split;
                result             = transliterator.Transliterate(input, out trace, r);

                if (!list.Contains(result))
                {
                    sb.Append("<b>Trilled Tapped R, split consonants:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }
            }


            if (input.ToLower().Contains("th"))
            {
                consontants.SorT = "s";
                result           = transliterator.Transliterate(input, out trace, consontants);
                if (!list.Contains(result))
                {
                    sb.Append("<b>Prefer s for th:  </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }


                consontants.SorT = "t";
                result           = transliterator.Transliterate(input, out trace, consontants);
                if (!list.Contains(result))
                {
                    sb.Append("<b>Prefer t for th: </b>");
                    sb.Append(result);
                    sb.Append("<br/>");
                    list.Add(result);
                }
            }

            TokiPonaOutput.Text = sb.ToString();
        }