10
11:-ensure_loaded(logicmoo_module_aiml_toplevel).
12
13:-dynamic(recordedTime/2).
14timeRecorded(Call):-timeRecorded(Call,Time),asserta(recordedTime(Time,Call)),listing(recordedTime/2),!.
15timeRecorded(Call,Time):- statistics(cputime,Start),context_module(M),prolog_statistics:time(M:Call),statistics(cputime,End),Time is End - Start.
17
18save:-tell(aimlCate),
19 aimlCateSig(CateSig),
20 listing(CateSig),
21 listing(dict),
22 told,
23 predicate_property(CateSig,number_of_clauses(N)),
24 predicate_property(dict(_,_,_),number_of_clauses(ND)),
25 debugFmt([aimlCate=N,dict=ND]),!.
26
27dt:- withAttributes(Ctx,[graph='ChomskyAIML'],load_aiml_files(Ctx,'chomskyAIML/*.aiml')).
28
29do:-load_aiml_files,alicebot.
30
31
32hasLibrarySupport :- absolute_file_name(library('programk/logicmoo_module_aiml_toplevel.pl'),File),exists_file(File).
33throwNoLib:- absolute_file_name('.',Here),throw(error(existence_error(url, Here), context(_, status(404, Here)))).
34
36 up_one_if :- absolute_file_name('./logicmoo_module_aiml_toplevel.pl',File),(exists_file(File)->cd('../');true).
37
39
41
43
44
46addSupportHere:-
47 absolute_file_name('logicmoo_module_aiml_toplevel.pl',File),
48 (exists_file(File)-> ((
49 absolute_file_name('.',Here),
50 asserta(library_directory(Here))));true).
51
53
55
59
60
62
64
65dtt:- timeRecorded(dt),statistics,alicebot.
66
67dttt:-timeRecorded(consult(aimlCate_checkpoint)),alicebot.
68
69:-catch(noguitracer,_,true).
70:-traceAll.
71
73
75
77
84
85stdCatchAll:-
86 87 assert_cate_in_load(aimlCate(*,*,*,*,*,*,*,*,*,*,
88 [element(srai,[],['STDCATCHALL',star(pattern,[],[])])],
89 element(category,[],[element(pattern,[],[*]),
90 element(template,[],[element(srai,[],['STDCATCHALL',element(star,[],[])])])]),
91 'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':737-20056,aruleStd2)),
92 93 assert_cate_in_load(aimlCate(*,*,*,*,*,['STDCATCHALL',*],*,*,*,*,
94 ['ERROR',understanding,:,star(pattern,[],[])],
95 element(category,[],[element(pattern,[],['STDCATCHALL *']),
96 element(template,[],['ERROR understanding:',element(star,[],[])])]),
97 'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205,aruleStd3)).
98
99unusedCates:-assert_cate_in_load(aimlCate(*,*,*,*,*,[34],*,*,*,*,element(template,[],[element(srai,[],[1])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
100 assert_cate_in_load(aimlCate(*,*,*,*,*,['34'],*,*,*,*,element(template,[],[element(srai,[],[2])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
101 assert_cate_in_load(aimlCate(*,*,*,*,*,[35],*,*,*,*,element(template,[],[element(srai,[],[3])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
102 assert_cate_in_load(aimlCate(*,*,*,*,*,['35'],*,*,*,*,element(template,[],[element(srai,[],[4])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
103 assert_cate_in_load(aimlCate(*,*,*,*,*,[37],*,*,*,*,element(template,[],[element(srai,[],['6'])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
104 assert_cate_in_load(aimlCate(*,*,*,*,*,['38'],*,*,*,*,element(template,[],[element(srai,[],['7'])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
105 assert_cate_in_load(aimlCate(*,*,*,*,*,[39],*,*,*,*,element(template,[],[element(srai,[],['8'])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)),
106 assert_cate_in_load(aimlCate(*,*,*,*,*,['40'],*,*,*,*,element(template,[],[element(srai,[],['9'])]),foo3,'c:/development/opensim4opencog/bin/cynd/programk/test_suite/customtagtest.aiml':44-3205)).
107
109chomskyAIML:-once(load_aiml_files(('chomskyAIML/*.aiml'))).
110
111test_suite_files:-once(load_aiml_files(('test_suite/*.aiml'))).
112
113loadBasicDictionaries:-once(load_aiml_files(('test_suite/ProgramD/predicates.xml'))),fail.
114loadBasicDictionaries:-once(load_aiml_files(('test_suite/ProgramD/properties.xml'))),fail.
115loadBasicDictionaries:-once(load_aiml_files(('test_suite/ProgramD/substitutions.xml'))),fail.
116loadBasicDictionaries.
117
118run_chat_tests_here(Ctx):-
119 timeRecorded(test_suite_files),
120 timeRecorded(test_call(alicebotCTX(Ctx,'qt'))),
121 timeRecorded(test_call(alicebotCTX(Ctx,'qt1'))),!.
122
123run2(Ctx):-
124 125 test_call(alicebotCTX(Ctx,'What is your name')),
126 test_call(alicebotCTX(Ctx,'What is your thing')),
127 test_call(alicebotCTX(Ctx,'My name is Fred.')),
128 test_call(alicebotCTX(Ctx,'what is my name?')).
129
130blackjack_test_load:- test_call(alicebot('@load blackjack.aiml')).
131blackjack_test:- blackjack_test_load,
132 test_call(alicebotCTX(Ctx,'blackjack')),
133 test_call(alicebotCTX(Ctx,'d')),
134 test_call(alicebotCTX(Ctx,'3')),!.
135
136annie:-withNamedContext(toplevel,Ctx),timeRecorded(run_chat_tests_here(Ctx)),unify_listing(ju:unitTestResult(unit_failed,_)).
137
139
149
150
151
153
155
156
158
161
162setupTesting:-
163 stdCatchAll,
164 alicebot('<category><pattern>*</pattern><that>what was it</that><template><think><set name="it"><star/></set></think></template></category>'),
165 alicebot('<category><pattern>pppp</pattern><template>555555</template><that>*</that></category>'),
166 alicebot('<category><pattern>suggest a topic</pattern><template><srai>random topic</srai></template><that>*</that></category>').
167
168stdalice:-timeRecorded(load_aiml_files('std_alice/*.aiml')),!. 169
171
172saveAIMLCore :- tell('aimlCore.pl'),listing(aimlCate),listing(argNFound),listing(dict),told.
173saveAIMLCore2 :- tell('aimlCore2.pl'),listing(aimlCate),listing(argNFound),listing(dict),told.
174
176
177blastAll:-aimlCateSig(Sig),retractall(Sig),fail.
178blastAll:-retractall(argNFound(_,_,_,_)),fail.
179blastAll.
180
182
183run_aiml_tests:-
184 setupTesting,
185 timeRecorded(annie),
186 unify_listing(ju:unitTestResult(unit_passed,_)),
187 unify_listing(ju:unitTestResult(unit_failed,_)),
188 !