Loading...
Logo
Processing Forum
Hi, i'm trying to implement in Processing the example about the use of CLEVERBOT in java. The library can be found here, but I have some difficulties.

The example in java is below. How can I implement this example in Processing?
package com.google.code.chatterbotapi.test;

import com.google.code.chatterbotapi.*;

public class ChatterBotApiTest {
   
   
public static void main(String[] args) throws Exception {
       
ChatterBotFactory factory = new ChatterBotFactory();

       
ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
       
ChatterBotSession bot1session = bot1.createSession();

       
ChatterBot bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
       
ChatterBotSession bot2session = bot2.createSession();

       
String s = "Hi";
       
while (true) {

           
System.out.println("bot1> " + s);

            s
= bot2session.think(s);
           
System.out.println("bot2> " + s);

            s
= bot1session.think(s);
       
}
   
}
}

Replies(2)

Copy code
  1. import com.google.code.chatterbotapi.*;
  2.  
  3. ChatterBotSession bot1session, bot2session;
  4.  
  5. void setup()
  6. {
  7.   ChatterBotFactory factory = new ChatterBotFactory();
  8.   ChatterBot bot1 = null, bot2 = null;
  9.   try
  10.   {
  11.     bot1 = factory.create(ChatterBotType.CLEVERBOT);
  12.     bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
  13.   }
  14.   catch (Exception e)
  15.   {
  16.     println("Error: " + e);
  17.   }
  18.   bot1session = bot1.createSession();
  19.   bot2session = bot2.createSession();
  20. }
  21.  
  22. String s = "Hi";
  23.  
  24. void draw()
  25. {
  26.   try
  27.   {
  28.     println("bot1> " + s);
  29.  
  30.     s = bot2session.think(s);
  31.     println("bot2> " + s);
  32.  
  33.     s = bot1session.think(s);
  34.   }
  35.   catch (Exception e)
  36.   {
  37.     println("Error: " + e);
  38.   }
  39. }
Amusing: two different kinds of bots chatting together.
Thanks for your help! It works very well!!