Exemple #1
0
 public SimplificationSystem(SimplificationSystem simplification_system)
     : this(simplification_system.Name)
 {
     if (simplification_system != null)
     {
         this.rules = new List <SimplificationRule>(simplification_system.Rules);
     }
 }
Exemple #2
0
    private static void LoadSimplificationSystem(string title)
    {
        if (!String.IsNullOrEmpty(title))
        {
            if (title.Contains("Waw"))
            {
                int index = title.IndexOf("Waw");
                title = title.Remove(index, "Waw".Length);
            }
            // also (not else :)
            if (title.Contains("Shadda"))
            {
                int index = title.IndexOf("Shadda");
                title = title.Remove(index, "Shadda".Length);
            }

            s_simplification_system = new SimplificationSystem(title);
            if (s_simplification_system != null)
            {
                string filename = Globals.RULES_FOLDER + "/" + title + ".txt";
                if (!File.Exists(filename))
                {
                    string[] parts = NumerologySystem.FAVORITE_NUMERORLOGY_SYSTEM.Split('_');
                    if (parts.Length == 3)
                    {
                        filename = Globals.RULES_FOLDER + "/" + parts[0] + ".txt";
                    }
                }

                if (File.Exists(filename))
                {
                    List<string> lines = DataAccess.LoadLines(filename);
                    foreach (string line in lines)
                    {
                        string[] parts = line.Split('\t');
                        if (parts.Length == 2)
                        {
                            SimplificationRule rule = new SimplificationRule(parts[0], parts[1]);
                            s_simplification_system.Rules.Add(rule);
                        }
                        else
                        {
                            throw new Exception(filename + " file format must be:\r\n\tText TAB Replacement");
                        }
                    }
                }
            }
        }
    }