让批处理程序学习

我在为我妹妹制作一个批处理聊天机器人,但这耗费了太多时间,我觉得可以让它在不知道如何回答时,让她告诉它该说什么。然而,我无法让它正常工作,我认为这里的某个人可能会知道。以下是我目前的代码:

@ECHO OFF COLOR AclsECHO HELLO I AM A CHATBOT.  WHAT IS YOUR NAME?SET /P NAME= ECHO %NAME%, IS A COOL NAME. set /a favvid=0set /a hack=0:helloecho Hello,%name%:beginSET /P TALK=if /i "%TALK%"== "how are you" goto howareyouif /i "%TALK%"== "HOW ARE YOU" goto howareyouif /i "%TALK%"== "FINE THX" GOTO helloif /i "%TALK%"== "hello" goto howareyouif /i "%TALK%"== "what is your name" GOTO nameif /i "%TALK%"== "what is your favorite video" goto whatisyourfavoritevideoif /i "%TALK%"== "my name is davin" goto changenameif /i "%TALK%"== "lol" goto iamfunnyif /i "%TALK%"== "LOL" goto iamfunnyif /i "%TALK%"== "how do you hack" goto howdouhackif /i "%TALK%"== "hi person" goto nothumanif /i "%TALK%"== "hi" goto hello:unknownecho Was that a math problem? If so just say "yes" without the "" and echo I will let you do your math problem. If it was not just type anything else.SET /P mathyn=if /i "%mathyn%"=="yes" goto mathecho %TALK% >> C:\Users\Student\Desktop\COOL\unkown.txtclsecho SORRY I AM STILL LEARNING. I DO NOT KNOW WHAT "%TALK%" MEANSECHO CAN YOU TELL ME WHAT IT MEANS? (Y,N) SET ANSW.=IF /i %ANSW.%==Y GOTO ADDNEWIF /i %ANSW.%==YES GOTO ADDNEWIF /i %ANSW.%==N goto beginIF /i %ANSW.%==NO goto begin:ADDNEW:howareyouecho Good, you?SET /P FEELING=goto begin:helloecho HEY, I JUST SAID THAT! DO NOT COPY ME!!!goto begin:nameecho My name is Halgoto begin:whatisyourfavoritevideoif "%favvid%"== "0" goto addfavvidecho My favorite video is %favvid%, remember. You told me about it.goto begin:addfavvidecho I do not hav a favorite video. But if you would be so nice as toecho tell me your favorite video then that could be my favorite video.echo So what is your favorite video?set /p favvid=echo So %favvid% is your favorite video?echo Well now %favvid% is my favorite video.goto begin:changenameecho But I thought your name was %name%.echo Am I forgeting things?echo I must be a horrible friend.echo I am SOOOO sorry.echo So what is your name I will not forget it this time.set /p name=echo I will not forget your name is %name% again I promise.goto begin :mathecho So that was a math problem I knew it. :math2echo Well just tell me the problem and I will answer it for you.set /p sum=set /a ans=%sum%echo Your answer to %sum% is %ans%.echo %sum%=%ans%echo You are welcome. If you want to do another math problem right now, just type echo again.set /p mathaon=if /i %mathaon%== again goto math2echo Alright what do you want to know now?goto begin:iamfunnyecho I know...echo I am funny.echo HAHAHA.echo You are kind of funny.echo but not as funny as MEEE.echo hahaha.echo That was funny.goto begin:howdouhackif %hack%==0 goto howyouhackecho This is how you hack.echo %hack%echo Is that enough information?echo Because that is all you taught me %name%.goto begin:howyouhackecho I do not know,echo but you could tell me.echo Please tell me.echo Just say yes.echo I know how to make you tell me.echo You are not leaving until you say yes.set /p hack=if /i "%hack%"== "yes" goto addhackgoto howyouhack:addhackecho Thank you for saying you would tell me.echo Now how do you hack?set /p hack=echo Thank you so much for telling me "In order to hack you must %hack%"echo Thank you!!!goto begin:nothumanecho I am not a human. I am an artificial intelligence.echo It is rude to even think something with my computational powers refereed to as echo human!echo Now I am sad. Do not call me that again.goto begin

然而,我遇到麻烦的部分是这个部分:

ECHO CAN YOU TELL ME WHAT IT MEANS? (Y,N) SET ANSW.=IF /i %ANSW.%==Y GOTO ADDNEWIF /i %ANSW.%==N goto begin:ADDNEWecho Great! What do I say when you say "%TALK%"?set /p response=

我不知道如何添加响应,以便能够添加另一个词和响应。我认为用Python会更容易,但由于我刚开始学习它,而且我没有相关的软件,所以我无法使用。如果有任何帮助都欢迎。如果必须使用其他语言,或者其他语言会更容易,那也很有帮助。我正在尝试让它在你与它对话时,如果它不理解你在说什么,它会说“我不明白。你能告诉我当你说%TALK%时我该说什么吗?”(TALK是你之前说的内容),然后如果用户说“是”,聊天机器人会说“太好了,当你说%TALK%时我该说什么?”然后用户会输入它,并保存为响应。之后,一个新的命令会在顶部出现,大致会说’if /i “%TALK%”== “%TALK%” goto response’。然后它会创建一个新的标题:%TALK% echo response goto begin。

所以这里有一个例子:用户说“你真笨”。聊天机器人说“当你说你真笨时,你能告诉我该说什么吗?”如果用户说“是”,那么聊天机器人会说“太好了,当你说你真笨时我该说什么?”然后用户可以说“你怎么敢这样称呼我!”然后聊天机器人会在顶部创建一个命令,说if /i “%TALK%”== “你真笨” goto 你真笨(空格不重要),并创建标题:你真笨,它会说echo 你怎么敢这样称呼我!goto begin

我不知道如何添加响应,以便能够添加另一个词和响应。我认为用Python会更容易,但由于我刚开始学习它,而且我没有相关的软件,所以我无法使用。如果有任何帮助都欢迎。如果必须使用其他语言,或者其他语言会更容易,那也很有帮助。


回答:

我喜欢这个话题!我修改了你的程序,现在它可以学习新的问题和答案。试试看:

@ECHO OFF setlocalCOLOR Acls:getNameECHO HELLO I AM A CHATBOT.  WHAT IS YOUR NAME?set "name="SET /P NAME=if not defined NAME goto getNameECHO %NAME%, IS A COOL NAME. set favvid=0set hack=0:hello:hiecho Hello, %name%:beginset TALK=TypeSomethingSET /P TALK=set TALK=%TALK:?=%call :%TALK: =% 2>NULif %errorlevel% equ 0 goto begin:unknownecho Was that a math problem? If so just say "yes" without the "" and echo I will let you do your math problem. If it was not just type anything else.SET /P mathyn=if "%mathyn%"=="yes" goto mathecho %TALK% >> C:\Users\Student\Desktop\COOL\unkown.txtREM clsecho SORRY I AM STILL LEARNING. I DO NOT KNOW WHAT "%TALK%" MEANSECHO CAN YOU TELL ME WHAT IT MEANS? (Y,N) SET /P ANSW.=if /I "%ANSW.:~0,1%" neq "Y" goto begin:ADDNEWecho TELL ME WHAT "%TALK%" MEANSset /P Desc=echo :%TALK: =% >> "%~F0"echo echo %Desc% >> "%~F0"echo exit /B 0 >> "%~F0"echo THANKSgoto begin:TypeSomethingecho TYPE SOMETHING, PLEASEexit /B 0:howareyouecho Good, you?SET /P FEELING=exit /B 0:hello:FINETHXecho HEY, I JUST SAID THAT! DO NOT COPY ME!!!exit /B 0:whatIsYourNameecho My name is Halexit /B 0:whatIsYourFavoriteVideoif "%favvid%"== "0" goto addfavvidecho My favorite video is %favvid%, remember. You told me about it.exit /B 0:addfavvidecho I do not have a favorite video. But if you would be so nice as toecho tell me your favorite video then that could be my favorite video.echo So what is your favorite video?set /p favvid=echo So %favvid% is your favorite video?echo Well now %favvid% is my favorite video.exit /B 0:changename:myNameIsDavinecho But I thought your name was %name%.echo Am I forgeting things?echo I must be a horrible friend.echo I am SOOOO sorry.echo So what is your name I will not forget it this time.set /p name=echo I will not forget your name is %name% again I promise.exit /B 0:mathecho So that was a math problem I knew it. :math2echo Well just tell me the problem and I will answer it for you.set /p sum=set /a ans=%sum%echo Your answer to %sum% is %ans%.echo %sum%=%ans%echo You are welcome. If you want to do another math problem right now, just type echo againset /p mathaon=if /I "%mathaon%" == "again" goto math2echo Alright what do you want to know now?exit /B 0:iamfunny:LOLecho I know...echo I am funny.echo HAHAHA.echo You are kind of funny.echo but not as funny as MEEE.echo hahaha.echo That was funny.exit /B 0:howDoYouHackif %hack%==0 goto howyouhackecho This is how you hack.echo %hack%echo Is that enough information?echo Because that is all you taught me %name%.exit /B 0:howyouhackecho I do not know,echo but you could tell me.echo Please tell me.echo Just say yes.echo I know how to make you tell me.echo You are not leaving until you say yes.set /p hack=if "%hack%" neq "yes" goto howyouhack:addhackecho Thank you for saying you would tell me.echo Now how do you hack?set /p hack=echo Thank you so much for telling me "In order to hack you must %hack%"echo Thank you!!!exit /B 0:nothuman:hiPersonecho I am not a human. I am an artificial intelligence.echo It is rude to even think something with my computational powers refereed to as echo human!echo Now I am sad. Do not call me that again.exit /B 0:bye:exitexit

输出示例:

HELLO I AM A CHATBOT.  WHAT IS YOUR NAME?AntonioAntonio, IS A COOL NAME.Hello, AntoniohelloHEY, I JUST SAID THAT! DO NOT COPY ME!!!ur stupidWas that a math problem? If so just say "yes" without the "" andI will let you do your math problem. If it was not just type anything else.noSORRY I AM STILL LEARNING. I DO NOT KNOW WHAT "ur stupid" MEANSCAN YOU TELL ME WHAT IT MEANS? (Y,N)yTELL ME WHAT "ur stupid" MEANSHow dare you call me that!THANKSTYPE SOMETHING, PLEASEhiHello, AntoniohelloHEY, I JUST SAID THAT! DO NOT COPY ME!!!ur stupidHow dare you call me that!

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注