Example #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)
Example #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))
Example #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()
Example #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()
Example #5
0
# -*- 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)

Example #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))
Example #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

        response = proto.dialogue(text)
        print("{prompt}{response}".format(prompt=build_prompt(proto),
                                          response=response))
Example #8
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()
Example #9
0
from unmo import Unmo
from rulebased import Rulebase


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('manachan')


    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=='tm':
            markov_tr_list = []