从自定义类运行时,程序ab中始终“我没有答案”

时间:2017-06-16 04:50:22

标签: java aiml

我尝试使用程序ab创建自定义聊天机器人。以下是我创建的课程

public class Test{
    public static void main(String args[]){
        String botname="super";
        String path="F:/Jars/NLP"; 
        Bot bot = new Bot(botname, path);
        Chat chatSession = new Chat(bot);
        Scanner sc=new Scanner(System.in);

        String request = "Hello";
        do{
        request = sc.next();
        String response = chatSession.multisentenceRespond(request); 
        System.out.println(response); 
        }while(!request.equals("exit"));

    }}

当我运行这个课程时,我得到以下输出

Name = super Path = F:/Jars/NLP/bots/super
c:/ab
F:/Jars/NLP/bots
F:/Jars/NLP/bots/super
F:/Jars/NLP/bots/super/aiml
F:/Jars/NLP/bots/super/aimlif
F:/Jars/NLP/bots/super/config
F:/Jars/NLP/bots/super/logs
F:/Jars/NLP/bots/super/sets
F:/Jars/NLP/bots/super/maps
Preprocessor: 0 norms 0 persons 0 person2
Get Properties: F:/Jars/NLP/bots/super/config/properties.txt
Loading AIML Sets files from F:/Jars/NLP/bots/super/sets
Loading AIML Map files from F:/Jars/NLP/bots/super/maps
AIML modified Thu Jun 15 19:03:38 IST 2017 AIMLIF modified Thu Jun 15 19:32:05 I
ST 2017
No deleted.aiml.csv file found
No deleted.aiml.csv file found
Loading AIML files from F:/Jars/NLP/bots/super/aimlif
Reading Learnf file
Loaded 2 categories in 0.015 sec
--> Bot super 2 completed 0 deleted 0 unfinished
Setting predicate topic to unknown
I like Mango
normalized = I
No match.
writeCertainIFCaegories learnf.aiml size= 0
I have no answer for that.
normalized = like
No match.
writeCertainIFCaegories learnf.aiml size= 0
I have no answer for that.
normalized = Mango
No match.
writeCertainIFCaegories learnf.aiml size= 0
I have no answer for that.

我的AIML文件 star.aiml

<?xml version = "1.0" encoding = "UTF-8"?>
<aiml>

   <category>
      <pattern>I LIKE *</pattern>
      <template>
         I too like <star/>.
      </template>
   </category>

   <category>
      <pattern>A * IS A *</pattern>
      <template>
         How <star index = "1"/> can not be a <star index = "2"/>?
      </template>
   </category>

</aiml>

.csv文件

star.aiml.csv

0,I LIKE *,*,*,I too like <star/>.,star.aiml
0,A * IS A *,*,*,How <star index = "1"/> can not be a <star index = "2"/>?,star.aiml

当我像下面那样运行Main类时它可以工作,但是当我运行自定义类时它不会。

java -cp lib/Ab.jar Main bot=super action=chat trace=false

任何人都可以告诉我自定义课程的错误

1 个答案:

答案 0 :(得分:0)

最后我得到了答案。

import java.util.Scanner;

import org.alicebot.ab.AB;
import org.alicebot.ab.Bot;
import org.alicebot.ab.Chat;
import org.alicebot.ab.PCAIMLProcessorExtension;
import org.alicebot.ab.utils.IOUtils;


public class Test_001 {
    public static void main(String args[]){
        String botname="super";
        String path="F:/Jars/NLP"; 
        org.alicebot.ab.AIMLProcessor.extension = new PCAIMLProcessorExtension();
        Bot bot = new Bot(botname, path,"chat");
        Chat chatSession = new Chat(bot);
        AB.ab(bot);
        Scanner sc=new Scanner(System.in);

        String request = "Hello";
        do{

        request = IOUtils.readInputTextLine();
        String response = chatSession.multisentenceRespond(request); 
        System.out.println(response); 
        }while(!request.equals("exit"));

    }
}
相关问题