Python AIML内核启动错误(Python AIML Kernel Startup error)
我试图运行一个脚本来创建AIML Python模块的聊天机器人,并且我是python的新手,每当我运行脚本初始化chat-bot时,在执行的第一阶段和编译它显示导入内核模块时出错,如下所示:
代码如下:
import aiml # Create the kernel and learn AIML files kernel = aiml.Kernel() kernel.learn("std-startup.xml") kernel.respond("load aiml b") # Press CTRL-C to break this loop while True: kernel.respond(raw_input("Enter your message >> "))
aiml目录的文件结构是:
I'm trying to run a script to create a chat-bot with AIML Python module, and I'm new to python, whenever I run the script to initialize the chat-bot, during the first phase of execution and compiling it shows an error importing Kernel module, as follows:
The Code Is As Below:
import aiml # Create the kernel and learn AIML files kernel = aiml.Kernel() kernel.learn("std-startup.xml") kernel.respond("load aiml b") # Press CTRL-C to break this loop while True: kernel.respond(raw_input("Enter your message >> "))
The file Structure for the aiml directory is:
原文:https://stackoverflow.com/questions/40263240
最满意答案
您的“客户”是许多客户的数组。
首先,将客户端更改为客户端以使该事实更加明确。
clients = current_user.clients
您无法在数组上调用accounts方法,这就是您的方法失败的原因。 相反,您需要遍历数组,依次在每个客户端上调用方法帐户。
这应该有用,或者会很接近。
@accounts = Array.new clients.each do |client| @accounts += client.accounts end
Your 'client' is an array of many clients.
First, change client to clients to make that fact more explicit.
clients = current_user.clients
You cannot call the accounts method on an array, which is why your method is failing. Instead you need to iterate through the array, calling your method accounts on each client in turn.
This should work, or will be close.
@accounts = Array.new clients.each do |client| @accounts += client.accounts end
相关问答
更多-
从对象中检索数据(Retrieve data from an object)[2022-09-19]
$(k[0]).text(); http://jsfiddle.net/niklasvh/D9NTr/2/ $(k[0]).text(); http://jsfiddle.net/niklasvh/D9NTr/2/ -
您的“客户”是许多客户的数组。 首先,将客户端更改为客户端以使该事实更加明确。 clients = current_user.clients 您无法在数组上调用accounts方法,这就是您的方法失败的原因。 相反,您需要遍历数组,依次在每个客户端上调用方法帐户。 这应该有用,或者会很接近。 @accounts = Array.new clients.each do |client| @accounts += client.accounts end Your 'client' is an array ...
-
关于什么 class Host has_many :ads, through: :locations has_many :skills, through: :ads end host = Host.first skills = host.skills.pluck(:name) @developers = Developer.tagged_with(skills, any: :true) What about class Host has_many :ads, through: :locati ...
-
检索对象方法(Retrieve object method)[2023-02-20]
我尝试使用Scala Parser Combinators实现简单的解析器。 这是我得到的。 我对解析器组合器不是很有经验,但为了好奇而做了一些工作。 import scala.util.parsing.combinator.JavaTokenParsers case class InfoObject(id: String, objInfo: String, bracedInfos: List[String], infos: List[String]) class ObjectParser extend ... -
前两个非常简单。 获取所有文本/文档对象的统计对象的总数 Statistic.where(:loggable_type => "Text").where(:loggable_id => company.texts) 获取本月所有文本/文档对象的统计对象总数 Statistic.where('created_at between ? and ?', 1.month.ago, Time.now).where(:loggable_type => "Text").where(:loggable_id => d.t ...
-
如果要向ErraiBus服务方法发送消息,则可以使用Message对象。 您可以从中检索会话并获取该会话的ID,如下所示: @Service public class ClientHelloService implements MessageCallback { @Override public void callback(final Message message) { HttpSession session = message.getResource( HttpServl ...
-
Rails 5:通过多态关系检索多个对象(Rails 5: retrieve multiple objects through polymorphic relationship)[2021-05-30]
为了解决这个问题,看起来问题(或者至少是一个大问题)是模型名称和关联中复数/单数元素的混淆。 一般来说: 型号名称是单数。 在这种情况下,“中等”是单数,“媒体”是复数。 当在模型中使用关联构造时,“has_many”通常将采用复数,而“belongs_to”将采用单数。 所以,期待has_many :companies和belongs_to :user 。 基础表名称是复数。 因此,“中”模型基于“媒体”表。 有了这个,我创建了一个简单的Rails应用程序,它作为上述代码的最小工作示例。 由于此处未显示“ ... -
这样就可以了: new_brazusc = member.events.find_by(name: "Brazusc") new_brazusc.build_brazusc.save This would do the trick: new_brazusc = member.events.find_by(name: "Brazusc") new_brazusc.build_brazusc.save
-
因为你没有描述A和B之间的关系,所以它是OneToOne ManyToOne OneToMany ManyToMany我将假设它是A的一侧的ManyToOne,因为每个A只与一个B相关,你需要第三个表来制作加入所以每个A与一个B相关但B可以与许多A(s)相关 @Entity @Table(name = "A") public class A { @GenericGenerator(name = "idGenerator", strategy = "increment") ...
-
Rails ActiveRecord连接三个表并检索嵌套对象(Rails ActiveRecord join three tables and retrieve nested objects)[2022-05-09]
我想我需要休息一下,现在我能弄清楚了。 我认为我的问题是依靠.inspect命令来检查并查看是否正在加载多级对象。 事实证明,如果我只是将我的查询简化为: @data = Game.joins(teams: :players).find(params[:id]) 然后实际尝试循环查看我的视图中的数据: <% @data.teams.each do |team| %> <%= team.players[0].name %> <% end %> 这使我能够访问我需要的所有数据。 我猜测由于懒加载(但也许 ...