MY MEMO

[PYTHON] Rivescript 추가 본문

STUDYING/PYTHON

[PYTHON] Rivescript 추가

l_j_yeon 2017. 10. 16. 18:55

1) Rivescript에서 한글을 사용하려면 python 2.x버전이 아닌 python 3.x버전을 사용해야한다


코드)

#!/usr/bin/python3

# Python 3 example

from rivescript import RiveScript
import re
rs = RiveScript(utf8=True)
rs.unicode_punctuation = re.compile(r'[.,!?;:]')
rs.load_directory("./eg/brain")
rs.sort_replies()

print("""This is a bare minimal example for how to write your own RiveScript bot!

For a more full-fledged example, try running: `python rivescript brain`
This will run the built-in Interactive Mode of the RiveScript library. It has
some more advanced features like supporting JSON for communication with the
bot. See `python rivescript --help` for more info.

example3.py is just a simple script that loads the RiveScript documents from
the 'brain/' folder, and lets you chat with the bot.

Type /quit when you're done to exit this example.
""")

while True:
msg = input("You> ")
if msg == '/quit':
quit()
reply = rs.reply("localuser", msg)
print("Bot>", reply)

# vim:expandtab

이렇게 하면 한글이 나온다 (.rive로 규칙을 적용한 것도 예쁘게 나온다)

'STUDYING > PYTHON' 카테고리의 다른 글

[WEB] Django 환경 설치하기  (0) 2018.01.16
[PYTHON] pycharm 오류 해결  (0) 2017.10.16
[PYTHON] Rivescript 개념  (0) 2017.10.15
[PYTHON] 추가  (0) 2017.10.15
[PYTHON] 개념 다지기 - 2  (0) 2017.10.07
Comments