how to make an virtual chat bot in java? -
i want make chat bot in java don't know how start? i've tried following code not need. in program had write every possibilities of questions. if 1 have solution please me.
import java.io.*; public class chatbot { public static void main(string[]args) throws ioexception { string hel = new string("hello"); string hel1 = new string("hello"); string hel2 = new string("hello"); string hel3 = new string("hii"); string hel4 = new string("hiii"); string hel5 = new string("hii"); string hel6 = new string("hiii"); bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); system.out.println("what name?"); string name = br.readline(); system.out.println("hello "+name+".."); string hellorep = br.readline(); if(hellorep .equals(hel)) { system.out.println("hello there..."); } else if(hellorep .equals(hel1)) { system.out.println("hello there..."); } else if(hellorep .equals(hel2)) { system.out.println("hello there..."); } else if(hellorep .equals(hel3)) { system.out.println("hii"); } else if(hellorep .equals(hel4)) { system.out.println("hiii"); } else if(hellorep .equals(hel5)) { system.out.println("hii"); } else if(hellorep .equals(hel6)) { system.out.println("hiii"); } else { system.out.println("please type again didn't you.."); } } }
if want make window can use jtextfield , add actionlistener , if want make console use input
then message aka store in variable , in respond method
if(stringvariablename.contains("your word want check if contains")) { make bot respond console or jtextfieldname.settext("answer here") }
and add many response possibilities doing else if after if this
if(){ } else if(stringvariablename.contains("")){ }
you can many times want , there have chat bot :d
Comments
Post a Comment