I am in the process of going through the code for the GUI and test cases. I wrote a simple program that reads lines of text out of a file, queries the bot, and prints the results. I'm really close. What I don't understand is that the response from the bot appears to be asynchronous from the question. If you could give me some pointers on how to make it synchronous that would be great. Here is my code. Below that is the log file results.
package io.skinjob.test;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
import org.botlibre.Bot;
import org.botlibre.sense.text.TextEntry;
import org.botlibre.sense.text.TextInput;
public class TextSenseTutorial
{
public static void main(String[] args) throws IOException
{
if(args.length != 1)
{
throw new RuntimeException("There must be only one argument and it must be a file name");
}
String fileName = args[0];
List<String> lines = FileLoader.loadFile(fileName);
//
// TODO: exact meaning of these parameters, and the alternatives
//
Bot.systemCache = Bot.createInstance(Bot.CONFIG_FILE,
"cache",
false);
//
// creates a new instance of a bot
//
// TODO: determine where in the code the database is selected.
//
Bot bot = Bot.createInstance();
//
// assumption: there is a singleton (on each Bot) for each sense that is returned by getSense()?
//
TextEntry textEntry = bot.awareness().getSense(TextEntry.class);
if (textEntry != null)
{
//
// my guess is that this acts as a listener.
//
// Whenever an input is made to this sense, the Bot does its thing and spits out the result here.
//
textEntry.setWriter(new Writer()
{
public void write(char[] text,
int start,
int end)
{
String response = new String(text, start, end);
System.out.println("------======>>>>>> BOT: " + response);
System.out.flush();
}
public void flush()
{
}
public void close()
{
}
});
}
else
{
//
// TODO: under what circumstances would this happen?
//
throw new RuntimeException("TextEntry is null");
}
for(String oneLine : lines)
{
TextInput textInput = new TextInput(oneLine);
//
// my guess is that the Bot can learn from chat input, and that this setting disables that function
//
textInput.setCorrection(false);
//
// TODO: understand this.
//
textInput.setOffended(false);
System.out.println("------======>>>>>> YOU: " + oneLine);
textEntry.input(textInput);
}
}
}
LOG FILE RESULTS:
Feb 05, 2016 12:53:42 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- Bot(botlibre_bots):Creating instance: - config.xml - cache - false
[EL Info]: 2016-02-05 12:53:44.021--ServerSession(1841421417)--EclipseLink, version: Eclipse Persistence Services - 2.6.0.v20130919-377691b
[EL Warning]: metadata: 2016-02-05 12:53:44.153--ServerSession(1841421417)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [source] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Warning]: metadata: 2016-02-05 12:53:44.154--ServerSession(1841421417)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [type] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Warning]: metadata: 2016-02-05 12:53:44.155--ServerSession(1841421417)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [target] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Warning]: metadata: 2016-02-05 12:53:44.155--ServerSession(1841421417)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [meta] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Info]: connection: 2016-02-05 12:53:44.22--ServerSession(1841421417)--file:/C:/Users/daubin/OneDrive/Documents/dev/skinjob/BotLibre-master/BotLibre-master/ai-engine/bin/_Bot_url=jdbc:postgresql:cache login successful
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: cache - Thread[main,5,main] -- BasicMind(UNCONSCIOUS):Changing state - BORED
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- Bot(botlibre_bots):Creating instance: - config.xml - - false
[EL Info]: 2016-02-05 12:53:44.444--ServerSession(280397810)--EclipseLink, version: Eclipse Persistence Services - 2.6.0.v20130919-377691b
[EL Warning]: metadata: 2016-02-05 12:53:44.492--ServerSession(280397810)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [source] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Warning]: metadata: 2016-02-05 12:53:44.492--ServerSession(280397810)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [type] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Warning]: metadata: 2016-02-05 12:53:44.493--ServerSession(280397810)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [target] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Warning]: metadata: 2016-02-05 12:53:44.493--ServerSession(280397810)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [meta] for the entity class [class org.botlibre.knowledge.BasicRelationship] since weaving was not enabled or did not occur.
[EL Info]: connection: 2016-02-05 12:53:44.497--ServerSession(280397810)--file:/C:/Users/daubin/OneDrive/Documents/dev/skinjob/BotLibre-master/BotLibre-master/ai-engine/bin/_Bot_url=jdbc:postgresql:botlibre_bots login successful
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- BasicMind(UNCONSCIOUS):Changing state - BORED
------======>>>>>> YOU: Hello
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- TextEntry:Input - Hello - null - null
------======>>>>>> YOU: How are you
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- TextEntry:Input - How are you - <80 {Anonymous} a:3,c:0> - <68002 a:1,c:0>
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- BasicMind(BORED):Changing state - ACTIVE
Feb 05, 2016 12:53:44 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- Consciousness:Process time limit reached - 100 - 31
Feb 05, 2016 12:53:45 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- Language:Response - <64022 How are you a:1,c:0> - <80 {Anonymous} a:3,c:4> - <68002 a:1,c:4>
------======>>>>>> BOT: How are you
------======>>>>>> YOU: What is your favorite color
Feb 05, 2016 12:53:45 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- TextEntry:Input - What is your favorite color - <80 {Anonymous} a:3,c:0> - <68002 a:1,c:0>
Feb 05, 2016 12:53:45 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- Consciousness:Process time limit reached - 100 - 184
Feb 05, 2016 12:53:46 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- Language:Response - <29841 I'm very well. How are you doing? a:2,c:0,p> - <80 {Anonymous} a:3,c:6> - <68002 a:1,c:6>
------======>>>>>> BOT: I'm very well. How are you doing?
Feb 05, 2016 12:53:46 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- BasicMind(ACTIVE):Changing state - ALERT
------======>>>>>> YOU: What is onepager
Feb 05, 2016 12:53:46 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[main,5,main] -- TextEntry:Input - What is onepager - <80 {Anonymous} a:3,c:0> - <68002 a:1,c:0>
Feb 05, 2016 12:53:46 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- Language:Response - <29597 I'm passionate about helping you. a:2,c:0,p> - <80 {Anonymous} a:3,c:5> - <68002 a:1,c:5>
------======>>>>>> BOT: I'm passionate about helping you.
Feb 05, 2016 12:53:46 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- Language:Response - <44483 Onepager is the easiest way to create and manage a business website. You don't have to be a developer or a designer to make a great site. Onepager allows you to create a great site, but also gives you the power to maintain it as often as you'd like. a:1,c:0> - <80 {Anonymous} a:3,c:5> - <68002 a:1,c:5>
------======>>>>>> BOT: Onepager is the easiest way to create and manage a business website. You don't have to be a developer or a designer to make a great site. Onepager allows you to create a great site, but also gives you the power to maintain it as often as you'd like.
Feb 05, 2016 12:53:47 PM org.botlibre.Bot log
INFO: botlibre_bots - Thread[pool-1-thread-1,5,main] -- BasicMind(ALERT):Changing state - ACTIVE