当前位置: 首页>>代码示例>>Java>>正文


Java Chat.multisentenceRespond方法代码示例

本文整理汇总了Java中org.alicebot.ab.Chat.multisentenceRespond方法的典型用法代码示例。如果您正苦于以下问题:Java Chat.multisentenceRespond方法的具体用法?Java Chat.multisentenceRespond怎么用?Java Chat.multisentenceRespond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alicebot.ab.Chat的用法示例。


在下文中一共展示了Chat.multisentenceRespond方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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("&lt;", "<");
	while (answer.contains("&gt;"))
		answer = answer.replace("&gt;", ">");
	System.out.println("Question: " + question);
	System.out.println("Answer: " + answer);
	return answer;
}
 
开发者ID:NguyenAnhDuc,项目名称:AIML,代码行数:16,代码来源:FunctionHelper.java

示例3: 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

示例4: 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


注:本文中的org.alicebot.ab.Chat.multisentenceRespond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。