示例#1
0
        public static bool LoadFromFile(string file, out Bot bot)
        {
            bot = null;
            if (!file.EndsWith(".xml") | !File.Exists(file))
            {
                return(false);
            }
            string directory     = Path.GetDirectoryName(Path.GetFullPath(file));
            string aimldirectory = Path.Combine(directory, "aiml");

            bot = new Bot();
            bot.isAcceptingUserInput = false;
            bot.loadSettings(file);
            bot.DefaultPredicates.loadSettings(directory + "\\DefaultPredicates.xml");
            bot.GenderSubstitutions.loadSettings(directory + "\\GenderSubstitutions.xml");
            bot.Person2Substitutions.loadSettings(directory + "\\Person2Substitutions.xml");
            bot.PersonSubstitutions.loadSettings(directory + "\\PersonSubstitutions.xml");
            bot.loadSplitters(directory + "\\Splitters.xml");
            bot.Substitutions.loadSettings(directory + "\\Substitutions.xml");
            bot.loadAIMLFromFiles(aimldirectory);
            bot.isAcceptingUserInput = true;
            return(true);
        }