专家系统未初始化 [英] Expert system doesn't initialize

查看:133
本文介绍了专家系统未初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AI::ExpertSystem::Advanced 从中运行专家系统网络内容.

I am using AI::ExpertSystem::Advanced to run an expert system from web content.

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

I have a website where I run a Perl script with this code:

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;

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

I tried to create a log. When I run this source in terminal my log is full and all things are right. But when I run it from web it is something wrong. My log file is only:

START EXPERT
START CREATE DB
LOAD RECEPTY
LOAD DB

我认为创建新专家系统的做法是不好的.链接或我不知道.你觉得呢?

I think that something with creating new expert system is bad. Links or I dont know. What do you think?

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

ERROR OF MY LOCAL SERVER:

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.

推荐答案

(最初作为对重复问题的解答,提交于

(Originally submitted as an answer to the duplicate question at How can I find place of error in perl )

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

The error messages in the question state that the error is thrown at C:/Perl/lib/Term/ReadKey.pm line 362 and that use Term::ReadKey appears at C:/Perl/lib/Term/ReadLine/Perl.pm line 65. If you are running this code in a CGI environment, using ReadLine/ReadKey makes no sense and it's unsurprising that they fail to initialize.

但是,您正在使用viewer_class => 'terminal'创建ExpertSystem实例,这导致它使用

However, you're creating your ExpertSystem instance with viewer_class => 'terminal', which causes it to use AI::ExpertSystem::Advanced::Viewer::Terminal, which "Extends from AI::ExpertSystem::Advanced::Viewer::Base and its main purpose is to interact with a (console) terminal" (emphasis mine) and it uses ReadLine to do so. In order to make this work, you need to use a different viewer class which does not "interact with a (console) terminal".

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

Unfortunately, a search of metacpan finds no other available viewers, so you'll need to either find one somewhere else (the author of AI::ExpertSystem::Advanced may know where you can get one for CGI) or write your own viewer class.

这篇关于专家系统未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆