2017-06-16 30 views
-1

運行時,總是「我沒有答案」的答案在程序ab中我試圖使用程序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 

當我運行主類像下面它的作品,但是當我運行自定義類它不。

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

可有人請讓我知道什麼是錯的自定義類

+0

你在問沒有給我們看的代碼有什麼問題? –

+0

我已經給出了我創建的所有文件。習慣課也給。 – Java

回答

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")); 

    } 
}