资源简介
人工智能机器人alice的java版源代码Alice人工智能机器人alice的java版源代码Alice
代码片段和文件信息
/*
Copyleft (C) 2004 H閘io Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) any later version.
ChatterBean is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documentos/ directory); if not either write to the Free Software Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean;
import java.util.List;
import bitoflife.chatterbean.aiml.Category;
import bitoflife.chatterbean.text.Request;
import bitoflife.chatterbean.text.Response;
import bitoflife.chatterbean.text.Sentence;
import bitoflife.chatterbean.text.Transformations;
public class AliceBot
{
/*
Attribute Section
*/
/** Context information for this bot current conversation. */
private Context context;
/** The Graphmaster maps user requests to AIML categories. */
private Graphmaster graphmaster;
/*
Constructor Section
*/
/**
Default constructor.
*/
public AliceBot()
{
}
/**
Creates a new AliceBot from a Graphmaster.
@param graphmaster Graphmaster object.
*/
public AliceBot(Graphmaster graphmaster)
{
setContext(new Context());
setGraphmaster(graphmaster);
}
/**
Creates a new AliceBot from a Context and a Graphmaster.
@param context A Context.
@param graphmaster A Graphmaster.
*/
public AliceBot(Context context Graphmaster graphmaster)
{
setContext(context);
setGraphmaster(graphmaster);
}
/*
Method Section
*/
private void respond(Sentence sentence Sentence that Sentence topic Response response)
{
if (sentence.length() > 0)
{
Match match = new Match(this sentence that topic);
Category category = graphmaster.match(match);
response.append(category.process(match));
}
}
/**
Responds a request.
@param request A Request.
@return A response to the request.
*/
public Response respond(Request request)
{
String original = request.getOriginal();
if (original == null || ““.equals(original.trim()))
return new Response(““);
Sentence that = context.getThat();
Sentence topic = context.getTopic();
transformations().normalization(request);
context.appendRequest(request);
Response response = new Response();
for(Sentence sentence : request.getSentences())
respond(sentence that topic response);
context.appendResponse(response);
return response;
}
/**
Responds a req
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 408 2009-09-21 13:10 Alice\.classpath
文件 381 2009-09-21 13:08 Alice\.project
文件 394 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\A.java
文件 2668 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Aiml.java
文件 1103 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLElement.java
文件 4516 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLHandler.java
文件 25443 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLHandlerTest.java
文件 1905 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLParser.java
文件 1177 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLParserConfigurationException.java
文件 1327 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLParserException.java
文件 3839 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLParserTest.java
文件 1326 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\AIMLStack.java
文件 394 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\B.java
文件 1765 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Bot.java
文件 626 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Br.java
文件 4147 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Category.java
文件 1762 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\CategoryTest.java
文件 3554 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Condition.java
文件 2022 2009-09-15 15:27 Alice\alice-src\bitoflife\chatterbean\aiml\Date.java
文件 397 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Em.java
文件 1805 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Formal.java
文件 1527 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Gender.java
文件 1855 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Get.java
文件 1610 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Gossip.java
文件 1630 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Id.java
文件 2220 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Input.java
文件 2050 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\ja
文件 1856 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Learn.java
文件 2060 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Li.java
文件 1376 2009-09-11 14:44 Alice\alice-src\bitoflife\chatterbean\aiml\Lowercase.java
............此处省略226个文件信息
- 上一篇:会议室管理 面向对象课设
- 下一篇:安卓SL4A_R6.APK文件
评论
共有 条评论