简体   繁体   English

如何向我的聊天机器人添加计算器

[英]how do I add a calculator to my chatbot

I have a chatbot (javascript) that works according to my written answers, I enter a command that has a keyword, go through the input written and if the keyword is find the chatbot responds with a code written according to my answer.我有一个根据我的书面答案工作的聊天机器人 (javascript),我输入一个带有关键字的命令,通过输入的内容,如果找到关键字,聊天机器人会根据我的答案编写代码进行响应。 I need help to make my chatbot have the ability to calculate simple math problems (+,-,*,/).我需要帮助让我的聊天机器人能够计算简单的数学问题(+、-、*、/)。

Take the value from the chat, in this case a command to calculate, say [calc](calculationhere) then parse the equation with a library.从聊天中获取值,在这种情况下是一个计算命令,比如[calc](calculationhere)然后用库解析方程。 A simple search will yield many javascript calculation parsers for simple operations like with that fashion.一个简单的搜索将产生许多 javascript 计算解析器,用于像这种方式那样的简单操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM