Beispiel #1
0
        /// <summary>
        /// Generals the options text.
        /// </summary>
        /// <param name="lexicon">The lexicon.</param>
        /// <param name="addComments">if set to <c>true</c> [add comments].</param>
        /// <returns>System.String.</returns>
        private string GeneralOptionsText(bool addComments)
        {
            var sb = new StringBuilder();

            if (addComments)
            {
                sb.AddCommentBlock("GENERAL OPTIONS");
            }

            sb.AppendLine(OptionsText(Lexicon.GeneralOptions, addComments));

            return(sb.ToString());
        }
Beispiel #2
0
        private string AffixesText(bool addComments)
        {
            Lexicon.Affixes.Sort();

            var sb = new StringBuilder();

            sb.AddCommentBlock(new string[] { "AFFIX CLASSES", $"COUNT: {Lexicon.Affixes.Count}" });

            foreach (var affix in Lexicon.Affixes)
            {
                // Add header
                if (addComments)
                {
                    sb.AddCommentBar();
                    sb.AddComments($"[{affix.Flag}] {affix.Label.ToUpperInvariant()}");

                    var comments = affix.Comments?.SplitToLines()?.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());

                    if (comments.Count() > 0)
                    {
                        sb.AddSectionBar();

                        sb.AddComments(comments);
                    }

                    sb.AddCommentBar();
                }

                // Affix Intro
                sb.AppendLine($"{affix.Type.ToFlag()} {affix.Flag} {(affix.CanCombine ? 'Y' : 'N')} {affix.Rules.Count}");

                // Sort the rules
                affix.Rules.Sort();

                // Rules
                sb.AppendLineCollection(affix.Rules.Select(r => r.ToText(affix, Lexicon, addComments)));

                if (addComments)
                {
                    sb.AppendLine(string.Empty);
                }
            }

            return(sb.ToString());
        }
Beispiel #3
0
        public string AffixListingText()
        {
            var primaries = new List <string>(Lexicon.Affixes
                                              .Where(aff => aff.IsPrimary == true)
                                              .Select(aff => $"*[{aff.Flag}] [{aff.Type.ToFlag()}] [{aff.Rules.Count(),5}]: {aff.Label}"));

            primaries.Sort((a1, a2) => string.CompareOrdinal(a1, a2));

            var dependents = new List <string>(Lexicon.Affixes
                                               .Where(aff => aff.IsPrimary == false)
                                               .Select(aff => $" [{aff.Flag}] [{aff.Type.ToFlag()}] [{aff.Rules.Count(),5}]: {aff.Label}"));

            dependents.Sort((a1, a2) => string.CompareOrdinal(a1, a2));

            var sb = new StringBuilder();

            sb.AddCommentBlock($"AFFIX LISTING - COUNT: {Lexicon.Affixes.Count} [Primary: {primaries.Count}; Dependents: {dependents.Count}]");
            sb.AddComments(primaries);
            sb.AddComments(dependents);

            return(sb.ToString());
        }
Beispiel #4
0
        private string SuggestionOptionsText(bool addComments)
        {
            var sb = new StringBuilder();

            if (addComments)
            {
                sb.AddCommentBlock("SUGGESTION OPTIONS");
            }

            sb.AppendLine(OptionsText(Lexicon.SuggestionOptions, addComments));

            // MAPPINGS
            if (Lexicon.SuggestionOptions.Mappings?.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("MAPPINGS");
                }

                sb.AppendLine($"MAP {Lexicon.SuggestionOptions.Mappings.Count}");

                foreach (var map in Lexicon.SuggestionOptions.Mappings)
                {
                    var mapping = $"MAP {(map.From.Length > 1 ? $"({map.From})" : map.From)}{(map.To.Length > 1 ? $"({map.To})" : map.To)}";

                    if (addComments)
                    {
                        sb.AppendLine($"{mapping,OptionWidth} # {map.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(mapping);
                    }
                }
            }

            // PHONETIC RULES
            if (Lexicon.SuggestionOptions.Replacements?.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("REPLACEMENTS");
                }

                sb.AppendLine($"REP {Lexicon.SuggestionOptions.Replacements.Count}");

                foreach (var rep in Lexicon.SuggestionOptions.Replacements)
                {
                    var replacement = $"REP {rep.From} {rep.To}";

                    if (addComments)
                    {
                        sb.AppendLine($"{replacement,OptionWidth} # {rep.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(replacement);
                    }
                }
            }

            if (Lexicon.SuggestionOptions.PhoneticRules?.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("PHONETIC RULES");
                }

                sb.AppendLine($"PHONE {Lexicon.SuggestionOptions.PhoneticRules.Count}");

                foreach (var phone in Lexicon.SuggestionOptions.PhoneticRules)
                {
                    var rule = $"PHONE {phone.From} {phone.To}";

                    if (addComments)
                    {
                        sb.AppendLine($"{rule,OptionWidth} # {phone.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(rule);
                    }
                }
            }
            return(sb.ToString());
        }
Beispiel #5
0
        private string ConversionOptionsText(bool addComments)
        {
            var sb = new StringBuilder();

            if (addComments)
            {
                sb.AddCommentBlock("CONVERSION OPTIONS");
            }

            sb.AppendLine(OptionsText(Lexicon.CompoundingOptions, addComments));

            // INPUT CONVERSIONS
            if (Lexicon.ConversionOptions.InputConversions?.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("INPUT CONVERSIONS");
                }

                sb.AppendLine($"ICONV {Lexicon.ConversionOptions.InputConversions.Count}");

                foreach (var con in Lexicon.ConversionOptions.InputConversions)
                {
                    var line = $"ICONV {con.From} {con.To}";

                    if (addComments & !(string.IsNullOrWhiteSpace(con.Comments)))
                    {
                        sb.AppendLine($"{line,NameWidth} # {con.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(line);
                    }
                }
            }

            // OUTPUT CONVERSIONS
            if (Lexicon.ConversionOptions.OutputConversions?.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("OUTPUT CONVERSIONS");
                }

                sb.AppendLine($"OCONV {Lexicon.ConversionOptions.InputConversions.Count}");

                foreach (var con in Lexicon.ConversionOptions.InputConversions)
                {
                    var line = $"OCONV {con.From} {con.To}";

                    if (addComments & !(string.IsNullOrWhiteSpace(con.Comments)))
                    {
                        sb.AppendLine($"{line,NameWidth} # {con.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(line);
                    }
                }
            }

            return(sb.ToString());
        }
Beispiel #6
0
        private string CompoundingOptionsText(bool addComments)
        {
            var sb = new StringBuilder();

            if (addComments)
            {
                sb.AddCommentBlock("COMPOUNDING OPTIONS");
            }

            sb.AppendLine(OptionsText(Lexicon.CompoundingOptions, addComments));

            // BREAKS
            if (Lexicon.CompoundingOptions?.Breaks.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("COMPOUNDING BREAKS");
                }

                sb.AppendLine($"BREAK {Lexicon.CompoundingOptions.Breaks.Count}");

                foreach (var @break in Lexicon.CompoundingOptions.Breaks)
                {
                    var line = $"BREAK {@break.Value}";

                    if (addComments)
                    {
                        sb.AppendLine($"{line,NameWidth} # {@break.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(line);
                    }
                }
            }

            // COMPOUND RULES
            if (Lexicon.CompoundingOptions?.CompoundRules.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("COMPOUNDING RULES");
                }

                sb.AppendLine($"COMPOUNDRULE {Lexicon.CompoundingOptions.CompoundRules.Count}");

                foreach (var rule in Lexicon.CompoundingOptions.CompoundRules)
                {
                    var line = $"COMPOUNDRULE {rule.Value}";

                    if (addComments)
                    {
                        sb.AppendLine($"{line,NameWidth} # {rule.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(line);
                    }
                }
            }

            // COMPOUND PATTERNS
            if (Lexicon.CompoundingOptions?.CheckCompoundPatterns.Count > 0)
            {
                if (addComments)
                {
                    sb.AddSectionBlock("COMPOUNDING PATTERNS");
                }

                sb.AppendLine($"CHECKCOMPOUNDPATTERN {Lexicon.CompoundingOptions.CompoundRules.Count}");

                foreach (var pattern in Lexicon.CompoundingOptions.CompoundRules)
                {
                    var line = $"CHECKCOMPOUNDPATTERN {pattern.Value}";

                    if (addComments)
                    {
                        sb.AppendLine($"{line,NameWidth} # {pattern.Comments}");
                    }
                    else
                    {
                        sb.AppendLine(line);
                    }
                }
            }

            return(sb.ToString());
        }