本文整理汇总了Java中org.alicebot.ab.Chat类的典型用法代码示例。如果您正苦于以下问题:Java Chat类的具体用法?Java Chat怎么用?Java Chat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Chat类属于org.alicebot.ab包,在下文中一共展示了Chat类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: savePredicates
import org.alicebot.ab.Chat; //导入依赖的package包/类
/**
* Persist the predicates for all known sessions in the robot.
*
* @throws IOException
*
*/
public void savePredicates() throws IOException {
for (String session : sessions.keySet()) {
String sessionPredicateFilename = createSessionPredicateFilename(session);
File sessionPredFile = new File(sessionPredicateFilename);
Chat chat = sessions.get(session);
// overwrite the original file , this should always be a full set.
log.info("Writing predicate file for session {}", session);
FileWriter predWriter = new FileWriter(sessionPredFile, false);
for (String predicate : chat.predicates.keySet()) {
String value = chat.predicates.get(predicate);
predWriter.write(predicate + ":" + value + "\n");
}
predWriter.close();
}
log.info("Done saving predicates.");
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:23,代码来源:ProgramAB.java
示例2: savePredicates
import org.alicebot.ab.Chat; //导入依赖的package包/类
/**
* Persist the predicates for all known sessions in the robot.
*
*/
public void savePredicates() throws IOException {
for (String session : sessions.keySet()) {
// TODO: better parsing of this.
String[] parts = session.split("-");
String username = parts[0];
String botname = session.substring(username.length() + 1);
String sessionPredicateFilename = createSessionPredicateFilename(username, botname);
File sessionPredFile = new File(sessionPredicateFilename);
Chat chat = getChat(username, botname);
// overwrite the original file , this should always be a full set.
log.info("Writing predicate file for session {}", session);
FileWriter predWriter = new FileWriter(sessionPredFile, false);
for (String predicate : chat.predicates.keySet()) {
String value = chat.predicates.get(predicate);
predWriter.write(predicate + ":" + value + "\n");
}
predWriter.close();
}
log.info("Done saving predicates.");
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:27,代码来源:ProgramAB.java
示例3: getResponse
import org.alicebot.ab.Chat; //导入依赖的package包/类
public static BotResponseInfo getResponse(Bot bot, String question){
Chat chat = new Chat(bot);
BotResponseInfo response = new BotResponseInfo();
String answer = chat.multisentenceRespond(question);
History hist = chat.thatHistory.get(0);
String that = "";
if (hist == null) that = MagicStrings.default_that;
else that = hist.getString(0);
String topic = chat.predicates.get("topic");
Nodemapper leaf = chat.bot.brain.match(question, that, topic);
response.setAnswer(answer);
response.setCategory(leaf.category);
return response;
}
开发者ID:NguyenAnhDuc,项目名称:AIML,代码行数:16,代码来源:FunctionHelper.java
示例4: ChatRoom
import org.alicebot.ab.Chat; //导入依赖的package包/类
public ChatRoom(ChatBot bot, Room room, int startBatchNumber, List<Class<? extends BotCommand>> allowedCommands,int dupNotifyStrategy, boolean enableAi){
this.bot = bot;
this.room = room;
this.currentBatchNumber = startBatchNumber;
this.allowedCommands = allowedCommands;
this.dupNotifyStrategy = dupNotifyStrategy;
if (enableAi){
chatSession = new Chat(bot.getAiBot());
}
}
开发者ID:SOBotics,项目名称:SOCVFinder,代码行数:11,代码来源:ChatRoom.java
示例5: updateLocation
import org.alicebot.ab.Chat; //导入依赖的package包/类
private void updateLocation() {
Location updatedLocation = bestLastKnownLocation(MIN_LAST_READ_ACCURACY, TEN_MIN);
if (updatedLocation != null) {
location = updatedLocation;
Chat.locationKnown = true;
Chat.longitude = Double.toString(location.getLongitude());
Chat.latitude = Double.toString(location.getLatitude());
}
}
开发者ID:datjandra,项目名称:Daytripper,代码行数:11,代码来源:MainActivity.java
示例6: initChatbot
import org.alicebot.ab.Chat; //导入依赖的package包/类
private void initChatbot() {
try {
String botDir = "bots";
String botName = "alice2";
AssetUtils.copyFileOrDir(botDir, this);
File botPath = getExternalFilesDir(null);
Bot bot = new Bot(botName, botPath.getAbsolutePath());
chatSession = new Chat(bot);
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
}
开发者ID:datjandra,项目名称:Daytripper,代码行数:13,代码来源:Daytripper.java
示例7: getChat
import org.alicebot.ab.Chat; //导入依赖的package包/类
public Chat getChat(String userName, String botName) {
String sessionKey = resolveSessionKey(userName, botName);
if (!sessions.containsKey(sessionKey)) {
error("%s session does not exist", sessionKey);
return null;
} else {
return sessions.get(sessionKey).chat;
}
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:10,代码来源:ProgramAB.java
示例8: getAnswer
import org.alicebot.ab.Chat; //导入依赖的package包/类
public static String getAnswer(Bot bot,String question) {
// bot.preProcessor.normalizeFile("c:/ab/bots/super/aiml/thats.txt",
// "c:/ab/bots/super/aiml/normalthats.txt");
Chat chatSession = new Chat(bot);
bot.brain.nodeStats();
String answer = chatSession.multisentenceRespond(question);
while (answer.contains("<"))
answer = answer.replace("<", "<");
while (answer.contains(">"))
answer = answer.replace(">", ">");
System.out.println("Question: " + question);
System.out.println("Answer: " + answer);
return answer;
}
开发者ID:NguyenAnhDuc,项目名称:AIML,代码行数:16,代码来源:FunctionHelper.java
示例9: trainBot
import org.alicebot.ab.Chat; //导入依赖的package包/类
public static void trainBot(BotInfo botInfo, String question, String newAnswer) {
// TODO Auto-generated method stub
Bot bot = getRunningBot(botInfo).getBot();
Chat chat = new Chat(bot);
chat.multisentenceRespond(question);
History hist = chat.thatHistory.get(0);
String that = "";
if (hist == null) that = MagicStrings.default_that;
else that = hist.getString(0);
String topic = chat.predicates.get("topic");
Nodemapper leaf = chat.bot.brain.match(question, that, topic);
leaf.category.setTemplate(newAnswer);
bot.writeAIMLFiles();
bot.writeAIMLIFFiles();
}
开发者ID:NguyenAnhDuc,项目名称:AIML,代码行数:16,代码来源:FunctionHelper.java
示例10: onHandleIntent
import org.alicebot.ab.Chat; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Log.i(TAG, "onHandleIntent()");
String query = intent.getStringExtra(KEY_QUERY);
query = query.toLowerCase(Locale.getDefault()).replace("\'", "");
DoubleMetaphone encoder = new DoubleMetaphone();
Set<String> ngrams = StringUtils.extractNgrams(query, NGRAM_SIZE);
for (String segment : ngrams) {
String hash = encoder.encode(segment);
if (KEYWORD_HASHES.containsKey(hash)) {
query = query.replace(segment, KEYWORD_HASHES.get(hash));
break;
}
}
final Daytripper daytripper = (Daytripper) getApplicationContext();
final Chat chatSession = daytripper.getChatSession();
String response = chatSession.multisentenceRespond(query);
Intent broadcastIntent = new Intent();
broadcastIntent.setAction(RESPONSE_ACTION);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
String url = chatSession.predicates.get("url");
if (!TextUtils.isEmpty(url) && !url.equalsIgnoreCase("unknown")) {
chatSession.predicates.remove("url");
broadcastIntent.putExtra(EXTRA_URL_MESSAGE, url);
} else {
broadcastIntent.putExtra(EXTRA_CONTENT_MESSAGE, response);
}
String voice = chatSession.predicates.get(VOICE_FLAG);
if (!TextUtils.isEmpty(voice) && !voice.equalsIgnoreCase("unknown")) {
chatSession.predicates.remove(VOICE_FLAG);
broadcastIntent.putExtra(VOICE_FLAG, voice);
}
broadcastIntent.putExtra(EXTRA_TEXT_MESSAGE, Jsoup.parse(response).text());
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);
}
开发者ID:datjandra,项目名称:Daytripper,代码行数:42,代码来源:ResponderService.java
示例11: ChatData
import org.alicebot.ab.Chat; //导入依赖的package包/类
public ChatData(Chat chat) {
this.chat = chat;
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:4,代码来源:ChatData.java
示例12: getChatSession
import org.alicebot.ab.Chat; //导入依赖的package包/类
public final static Chat getChatSession() { return Daytripper.chatSession; }
开发者ID:datjandra,项目名称:Daytripper,代码行数:2,代码来源:Daytripper.java
注:本文中的org.alicebot.ab.Chat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论