ASP.NET项目中的AIML机器人无法找到CONFIG文件?

我在尝试为我的ASP.NET Web项目实现一个AIML机器人,但一直遇到这个错误:

无法找到指定的文件。

源错误:第31行:
{

第32行:myBot = new Bot();

第33行:myBot.loadSettings(@”C:\Users\Public\Documents\SITE\bin\config”);

第34行:myUser = new User(“DefaultUser”, this.myBot);

第35行:AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot);

这是我的代码:

protected void Page_Load(object sender, EventArgs e){            myBot = new Bot();            myBot.loadSettings(@"C:\Users\Public\Documents\SITE\bin\config");            myUser = new User("DefaultUser", this.myBot);            AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot);            this.myBot.isAcceptingUserInput = false;            loader.loadAIML(@"C:\Users\Public\Documents\SITE\bin\aiml");            this.myBot.isAcceptingUserInput = true;}

听起来像是运行在本地主机时找不到配置文件夹?我做错了什么?


回答:

我知道这是一个旧帖子,但我还是要添加我的解决方案,以防其他人遇到同样的问题。

你的问题是没有指定设置文件。

试试这样做:

 myBot.loadSettings(@"C:\Users\Public\Documents\SITE\bin\config\Settings.xml");

但在部署应用程序时,问题仍然存在,因为即使你从文件中加载设置,配置文件夹中其他xml文件的路径仍然是相同的:

 return Path.Combine(Environment.CurrentDirectory, this.GlobalSettings.grabSetting("configdirectory"));

你可以这样做:你可以在C:\Windows\System32\inetsrv中添加配置目录,或者你可以下载源代码并修改PathToConfigFiles属性以满足你的需求,重新构建并再次添加到你的项目中引用。

我这样修改了该属性:

  private string _pathToConfigFiles;        public string PathToConfigFiles        {            get            {                return Path.Combine(this._pathToConfigFiles, this.GlobalSettings.grabSetting("configdirectory"));            }            set            {                this._pathToConfigFiles = value;            }        }

当我实例化机器人时,我这样做:

   Bot myBot = new Bot();   myBot.PathToConfigFiles = ConfigurationManager.AppSettings["AimlConfigPath"];   myBot.loadSettings(ConfigurationManager.AppSettings["AimlSettingsPath"]);

其中”AimlConfigPath”是D:\MyProject\bin,”AimlSettingsPath”是D:\MyProject\bin\config\Settings.xml,这两个都在我的应用程序的web.config文件中添加了。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注