nonkung51

hello_intent.py

May 11th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. import intentparser # อิมพอร์ตตัวไลบรารี่เข้ามาก่อน
  2. intent = intentparser.intentParser({ #ประกาศตัวแปร intent
  3.     'description' : {
  4.                     "type" : 'HelloIntent', #ประเภท HelloIntent
  5.                     "args" : [], # เราไม่ต้องการ args เลยว่างไว้
  6.                     "keyword" : [
  7.                     (0, "hello_keyword"), #Keyword ของเราเก็บไว้ใน dict คีย์ 'hello_keyword' เลข 0 แปลว่าต้องมีในประโยคนั้นๆครับ
  8.                     ]},
  9.     'hello_keyword' : ['hello', 'hi'], # ใส่ คีเวิร์ดของเราลงไป
  10. })
  11. intent.teachWords(["Hello, How are you?", "Hi, Mr.John", "Hello, nice to meet you!"]) # บรรทัดใช้สอนข้อความให้ intent ของเรา
  12.  
  13. print(intent.getResult("Hello, Mr.John?")) # สอนเสร็จก็ลองใช้ซักหน่อย
  14. print(intent.getResult("Hello, nice to meet you! Mr.John!"))
Advertisement
Add Comment
Please, Sign In to add comment