예제 #1
0
 def main_func(text):
     proto = Unmo('manachan')
     try:
         response = proto.dialogue(text, 1)
     except IndexError as error:
         return '{}: {}'.format(type(error).__name__, str(error)),
         '警告: 辞書が空です。(Responder: {})'.format(proto.responder_name)
     else:
         return '{response}'.format(response=response)
예제 #2
0
    def message(line_event):
        proto = Unmo('proto')
        text = line_event.message.text

        input_text = text.rstrip()
        response = proto.dialogue(input_text)

        line_bot_api.reply_message(line_event.reply_token,
                                   TextSendMessage(text=response))
예제 #3
0
def handle_message(event):
    #if event.reply_token == "00000000000000000000000000000000":
    #return
    if __name__ == '__main__':
        Lala = Unmo('Lala')
    #while True:
    #text = TextMessage
    response = Lala.dialogue(text=event.message.text)
    line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(text=response))  #ここでオウム返しのメッセージを返します。
    gc.collect()
    Lala.save()
예제 #4
0
def handle_message(message):
    print('received message: ' + message, file=sys.stderr)
    send(message, broadcast=True)

    proto = Unmo('proto')

    try:
        response = proto.dialogue(message)
    except IndexError as error:
        print('{}: {}'.format(type(error).__name__, str(error)))
        print('Error: Dictionary is empty. (Responder: {})'.format(proto.responder_name))
    else:
        print('{prompt}{response}'.format(prompt=build_prompt(proto), response=response))

    print('response message: ' + response, file=sys.stderr)
    prompt_response = '{prompt}{response}'.format(prompt=build_prompt(proto), response=response)
    send(prompt_response, broadcast=True)

    proto.save()
예제 #5
0
파일: draw.py 프로젝트: yuzutas0/nobypy
# -*- coding: utf-8 -*-

from unmo import Unmo
from IPython.display import display, clear_output
from PIL import Image
import os
import random
from datetime import datetime
from time import sleep

noby = Unmo('noby')
img_dir = '../KOISURU_PROGRAM/sample/emotion/bmps/'
text = '*******************************************************'
log = []


def now():
    return datetime.now().strftime("[%Y/%m/%d %H:%M:%S] ")


def prompt(unmo):
    return f"{unmo.name}:{unmo.responder.name} > "


def draw_image(file_name):
    clear_output(wait=True)
    image_file = img_dir + file_name
    display(Image.open(image_file))
    sleep(0.1)

예제 #6
0
# Python初心者に送る「人工知能の作り方」
# http://sandmark.hateblo.jp/entry/2017/10/07/141339
# に掲載されたコードを写経して勉強する。

from unmo import Unmo

def build_prompt(unmo):
    """
    AIインスタンスを取り、AIとResponderの名前を整形して返す
    """
    return '{name}:{responder}> '.format(name=unmo.name,
                                responder=unmo.responder_name)

if __name__=='__main__':
    print('Unmo System prototype : proto')
    proto= Unmo('proto')
    while True:
        text = input('> ')
        if not text:
            break

        response = proto.dialogue(text)
        print('{prompt}{response}'.format(prompt=build_prompt(proto),
                                         response=response))
예제 #7
0
from unmo import Unmo


def build_prompt(unmo):
    """ AIインスタンスを取り、AIとResponderの名前を整形して返す """
    return '{name}:{responder}> '.format(name=unmo.name,
                                         responder=unmo.responder_name)


if __name__ == '__main__':
    print('Unmo System prototype : proto')
    proto = Unmo('proto')
    while True:
        text = input('> ')
        if not text:
            break

        try:
            response = proto.dialogue(text)
        except IndexError as error:
            print('{}: {}'.format(type(error).__name__, str(error)))
            print('警告: 辞書が空です。(Responder: {})'.format(proto.responder_name))
        else:
            print('{prompt}{response}'.format(prompt=build_prompt(proto),
                                              response=response))

    proto.save()  # 追加
예제 #8
0
# -*- coding: utf-8 -*-

import os, sys

sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from unmo import Unmo


def prompt(unmo):
    return f"{unmo.name}:{unmo.responder.name} > "


print('Unmo System prototype : proto')
proto = Unmo('proto')

while True:
    print('> ', end='')
    input_text = input()
    input_text = input_text.rstrip()
    if input_text == '':
        break
    response = proto.dialogue(input_text)
    print(prompt(proto) + response)

print('shutdown')
예제 #9
0
파일: chatbot.py 프로젝트: pi-yan/chat
from unmo import Unmo


def build_prompt(unmo):
    """AIインスタンスを取り、AIとResponderの名前を整形して返す"""
    return "{name}:{responder}> ".format(name=unmo.name,
                                         responder=unmo.responder_name)


if __name__ == "__main__":
    print("Unmo System prototype : proto")
    proto = Unmo("proto")
    while True:
        text = input("> ")
        if not text:
            break

        response = proto.dialogue(text)
        print("{prompt}{response}".format(prompt=build_prompt(proto),
                                          response=response))
예제 #10
0
# coding:utf-8

from unmo import Unmo


def build_prompt(unmo):
    """AIインスタンスを取り,AIとResponderの名前を整形して返す"""
    return '{name}:{responder}> '.format(name=unmo.name,
                                         responder=unmo.responder_name)


if __name__ == '__main__':
    print('Unmo System prototype : girlfriend')
    proto = Unmo('girlfriend')
    while True:
        text = input('> ')
        if not text:
            break

        try:
            response = proto.dialogue(text)
        except IndexError as error:
            print('{}: {}'.format(type(error).__name__, str(error)))
            print('警告:辞書が空です.(Responder: {})'.format(proto.responder_name))
        else:
            print('{prompt}{response}'.format(prompt=build_prompt(proto),
                                              response=response))
    proto.save()
예제 #11
0
from unmo import Unmo


def build_prompt(unmo):
    """AIインスタンスを取り、AIとResponderの名前を整形して返す"""
    return '{name}:{responder}> '.format(name=unmo.name,
                                         responder=unmo.responder_name)


if __name__ == '__main__':
    print('Unmo System prototype : proto')
    proto = Unmo('proto')

    markov_training = 0
    while True:

        if markov_training == 1:
            markov_tr_list = markov_tr_list[1:]
            if len(markov_tr_list) == 0:
                markov_training = 0
                print('markov training is done!')
            else:
                text = markov_tr_list[0]
                print('traiing :', text)

        if markov_training != 1:
            text = input('> ')

        if text == 'train markov':
            print('ファイル名を教えて下さい')
            path = input('path = ')