nonkung51

bye_intent.py

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