【问题标题】:Expert system doesn't initialize专家系统未初始化
【发布时间】:2013-05-05 22:47:59
【问题描述】:

我正在使用 AI::ExpertSystem::Advanced 从 Web 内容运行专家系统。

我有一个网站,我在其中使用以下代码运行 Perl 脚本:

use strict;
use warnings;

use AI::ExpertSystem::Advanced;
use AI::ExpertSystem::Advanced::KnowledgeDB::Factory;
use Data::Dumper;
use File::Slurp;

open(LOG, ">C:\\xampp\\htdocs\\xampp\\bc\\log.txt");

print LOG "START EXPERT\n";
system("C:\\Perl\\bin\\perl C:\\xampp\\htdocs\\xampp\\bc\\create_yaml.pl");

print LOG "START CREATE DB\n";
my $yaml_kdb = AI::ExpertSystem::Advanced::KnowledgeDB::Factory->new('yaml', {
    filename => 'C:\\xampp\\htdocs\\xampp\\bc\\recepty.yaml'
});

print LOG "LOAD RECEPTY\n";
my $text = read_file(
    'C:\\xampp\\htdocs\\xampp\\bc\\knowledgebase.yaml',
    array_ref => 1,
    chomp     => 1
);

print LOG "LOAD DB\n";
my $ai = AI::ExpertSystem::Advanced->new(
    viewer_class  => 'terminal',
    knowledge_db  => $yaml_kdb,
    initial_facts => $text
);

print LOG "NEW ES\n";
$ai->mixed();

print LOG "RESULT DONE\n";
#$ai->summary();
close LOG;

我试图创建一个日志。当我在终端中运行此源时,我的日志已满并且一切正常。但是当我从网络上运行它时,它是错误的。我的日志文件只有:

START EXPERT
START CREATE DB
LOAD RECEPTY
LOAD DB

我认为创建新专家系统的做法很糟糕。链接或者我不知道。你怎么看?

我的本​​地服务器错误:

Compilation failed in require at C:/Perl/lib/Term/ReadLine/Perl.pm line 65. 
The system cannot find the path specified. Unable to get Terminal Size. 
The Win32 GetConsoleScreenBufferInfo call didn't work. 
The COLUMNS and LINES environment variables didn't work. 
The resize program didn't work. at C:/Perl/lib/Term/ReadKey.pm line 362. 
Compilation failed in require at C:/Perl/lib/Term/ReadLine/Perl.pm line 65.

【问题讨论】:

  • 您查看过网络服务器的错误日志吗?
  • Compilation failed in require at C:/Perl/lib/Term/ReadLine/Perl.pm line 65. The system cannot find the path specified. Unable to get Terminal Size. The Win32 GetConsoleScreenBufferInfo call didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. at C:/Perl/lib/Term/ReadKey.pm line 362. Compilation failed in require at C:/Perl/lib/Term/ReadLine/Perl.pm line 65.

标签: perl expert-system


【解决方案1】:

(最初作为对How can I find place of error in perl 重复问题的回答提交)

问题中的错误消息表明错误在C:/Perl/lib/Term/ReadKey.pm line 362 处引发,use Term::ReadKey 出现在C:/Perl/lib/Term/ReadLine/Perl.pm line 65 处。如果您在 CGI 环境中运行此代码,则使用 ReadLine/ReadKey 毫无意义,而且它们无法初始化也就不足为奇了。

但是,您正在使用viewer_class => 'terminal' 创建您的 ExpertSystem 实例,这会导致它使用 AI::ExpertSystem::Advanced::Viewer::Terminal,“扩展自 AI::ExpertSystem::Advanced::Viewer::Base 和 它的主要用途是与(控制台)终端交互”(重点是我的),它使用 ReadLine 来做到这一点。为了完成这项工作,您需要使用不“与(控制台)终端交互”的不同查看器类。

不幸的是,a search of metacpan 找不到其他可用的查看器,因此您需要在其他地方找到一个(AI::ExpertSystem::Advanced 的作者可能知道在哪里可以找到一个用于 CGI 的查看器)或编写自己的查看器类。

【讨论】:

  • 我尝试编写自己的查看器类。你有什么好主意吗?怎么办?我创建了一个 .pm 文件,但我不知道应该使用什么来代替 ReadLine/ReadKey ???
  • 很遗憾,不,我没有使用此模块的经验。最好的办法是尝试联系作者(PFISCHER,在 AI::ES::A 文档中的电子邮件地址或 PFISCHER@cpan.org)。
猜你喜欢
  • 2018-03-05
  • 1970-01-01
  • 1970-01-01
  • 2010-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多