是在60年代吧?MIT有个叫Weizanbaum的人做了一个程序叫做Eliza ,是像这样可以做interactive的谈话的。
最初Eliza的pattern是像这样的:
Hello. I am ELIZA. How can I help you?
> hello
Please state your problem.
> I have a headache
You say you have a headache
> yes
You seem quite positive.
> i am a positive person
具体的eliza的实现细节可以参见Weizanbaum的一篇文章(在这里下载 http://portal.acm.org/citation.cfm?id=365168 )
'ELIZA—a computer program for the study of natural language communication between man and machine'
Communications of the ACM
Volume 9 , Issue 1 (January 1966)
Pages: 36 - 45
Year of Publication: 1966
ISSN:0001-0782
大概的一个方式就是根据你的输入的话语在它的模式库里面match一个,然后从相应备选答案里面找一个回答的pattern
UGA有人做了一个prolog版本的eliza,我把这个的模式库的一部分发上来,大家可以看看,其实智能还是很有限的.
rules([[sorry,0],[
[1,[_],0,
[please,do,not,apologize,.],
[apologies,are,not,necessary,.],
[what,feelings,do,you,have,when,you,apologize,?],
['I',have,told,you,that,apologies,are,not,required,.]]]]).
rules([[remember,5],[
[1,[_,you,remember,Y],0,
[do,you,often,think,of,Y,?],
[does,thinking,of,Y,bring,anything,else,to,mind,?],
[what,else,do,you,remember,?],
[why,do,you,remember,Y,just,now,?],
[what,in,the,present,situation,reminds,you,of,Y,?],
[what,is,the,connection,between,me,and,Y,?]],
[2,[_,do,i,remember,Y],0,
[did,you,think,'I',would,forget,Y,?],
[why,do,you,think,i,should,recall,Y,now,?],
[what,about,Y,?],
[equal,[what,0]],
[you,mentioned,Y,.]],
[3,[_],0,
[newkey]]]]).
rules([[if,3],[
[1,[_,if,Y],0,
[do,you,think,it,is,likely,that,Y,?],
[do,you,wish,that,Y,?],
[what,do,you,think,about,Y,?],
[really,',',if,Y,?]]]]).
rules([[dreamt,4],[
[1,[_,you,dreamt,Y],0,
[really,',',Y,?],
[have,you,ever,fantasied,Y,while,you,were,awake,?],
[have,you,dreamt,Y,before,?],
[equal,[dream,3]],
[newkey]]]]).
rules([[dream,3],[
[1,[_],0,
[what,does,that,dream,suggest,to,you,?],
[do,you,dream,often,?],
[what,persons,appear,in,your,dreams,?],
[do,you,believe,that,dreaming,has,something,to,do,with,your,problem,?],
[newkey]]]]).
rules([[none,0],[
[1,[_],0,
['I',am,not,sure,'I',understand,you,fully,.],
[please,go,on,.],
[what,does,that,suggest,to,you,?],
[do,you,feel,strongly,about,discussing,such,things,?]]]]).
rules([[perhaps,0],[
[1,[_],0,
[you,do,not,seem,quite,certain,.],
[why,the,uncertain,tone,?],
[can,you,not,be,more,positive,?],
[you,are,not,sure,?],
[do,you,not,know,?]]]]).
[ 本帖最后由 疯狂坦克II 于 2007-8-27 13:04 编辑 ] |