首页 \ 问答 \ Python AIML内核启动错误(Python AIML Kernel Startup error)

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目录的文件结构是:

针对Python的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:

module import error

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:

AIML Directory For Python


原文:https://stackoverflow.com/questions/40263240
更新时间:2023-09-17 14:09

最满意答案

您的“客户”是许多客户的数组。

首先,将客户端更改为客户端以使该事实更加明确。

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

相关问答

更多
  • $(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 ...
  • 我尝试使用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 ...
  • 为了解决这个问题,看起来问题(或者至少是一个大问题)是模型名称和关联中复数/单数元素的混淆。 一般来说: 型号名称是单数。 在这种情况下,“中等”是单数,“媒体”是复数。 当在模型中使用关联构造时,“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") ...
  • 我想我需要休息一下,现在我能弄清楚了。 我认为我的问题是依靠.inspect命令来检查并查看是否正在加载多级对象。 事实证明,如果我只是将我的查询简化为: @data = Game.joins(teams: :players).find(params[:id]) 然后实际尝试循环查看我的视图中的数据: <% @data.teams.each do |team| %> <%= team.players[0].name %> <% end %> 这使我能够访问我需要的所有数据。 我猜测由于懒加载(但也许 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)