本文整理汇总了Java中com.google.code.chatterbotapi.ChatterBot类的典型用法代码示例。如果您正苦于以下问题:Java ChatterBot类的具体用法?Java ChatterBot怎么用?Java ChatterBot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChatterBot类属于com.google.code.chatterbotapi包,在下文中一共展示了ChatterBot类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.google.code.chatterbotapi.ChatterBot; //导入依赖的package包/类
@Override
public void execute(GnarMessage message, String[] args)
{
try
{
if (!sessionMap.containsKey(message.getAuthor()))
{
ChatterBot bot = factory.create(ChatterBotType.CLEVERBOT);
sessionMap.put(message.getAuthor(), bot.createSession());
}
message.replyRaw(sessionMap.get(message.getAuthor()).think(StringUtils.join(args, " ")));
}
catch (Exception e)
{
message.reply("Chat Bot encountered an exception. Restarting. `:[`");
sessionMap.remove(message.getAuthor());
}
}
示例2: talkToSelf
import com.google.code.chatterbotapi.ChatterBot; //导入依赖的package包/类
public String talkToSelf(String input) {
try {
ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
ChatterBotSession bot1session = bot1.createSession();
ChatterBot bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
ChatterBotSession bot2session = bot2.createSession();
while (continueToTalkToSelf) {
System.out.println("bot1> " + input);
input = bot2session.think(input);
log.info(input);
System.out.println("bot2> " + input);
log.info(input);
input = bot1session.think(input);
}
} catch (Exception e) {
Logging.logError(e);
}
return input;
}
示例3: talkToSelf
import com.google.code.chatterbotapi.ChatterBot; //导入依赖的package包/类
public String talkToSelf(String input) {
try {
ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
ChatterBotSession bot1session = bot1.createSession();
ChatterBot bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
ChatterBotSession bot2session = bot2.createSession();
while (continueToTalkToSelf) {
System.out.println("bot1> " + input);
input = bot2session.think(input);
log.info(input);
System.out.println("bot2> " + input);
log.info(input);
input = bot1session.think(input);
}
} catch (Exception e) {
Logging.logError(e);
}
return input;
}
示例4: createClever
import com.google.code.chatterbotapi.ChatterBot; //导入依赖的package包/类
private ChatterBot createClever() {
try {
return new ChatterBotFactory()
.create(ChatterBotType.CLEVERBOT, sentryProperties.getDiscord().getCleverBotApiKey());
} catch (Exception e) {
log.warn("Could not create CleverBot session", e);
}
return null;
}
示例5: CleverbotSession
import com.google.code.chatterbotapi.ChatterBot; //导入依赖的package包/类
public CleverbotSession() throws Exception
{
JSONObject json = new JSONObject(Util.getFileContents("config.json"));
ChatterBotFactory factory = new ChatterBotFactory();
ChatterBot bot = factory.create(ChatterBotType.CLEVERBOT, json.getString("cleverbotAPIKey"));
session = bot.createSession(Locale.ENGLISH);
}