Ejemplo n.º 1
0
def main():
    bot = DialogManager()

    while True:
        query = input('>>>:')
        answer = bot.get_answer(query)
        print('Bot: ', answer)
Ejemplo n.º 2
0
def gameMenuTree(stack, window):
    clerkDialogManager = DialogManager('redneck')
    diag = DialogFrame(stack, window, clerkDialogManager, playerImage='media/avatars/protag.png', npcImage='media/avatars/notnigel.png')

    gameMenu = MenuTree(stack, window, [["Quit", sys.exit], ["Dialog", diag], ["Return", None]], \
                        pygame.Rect((50, 50), (500, 500)), highlighting=(250, 100, 100),                          \
                        color=(100, 100, 100, 100), renderOver=(len(stack) - 1))
                        
    return gameMenu
Ejemplo n.º 3
0
def eval():
    topn = 10
    data = pd.read_csv('data/qa_processed')
    questions = data.sample(100)['question'].tolist()

    bot = DialogManager()
    result_df = {'top' + str(i): [] for i in range(topn)}
    for question in questions:
        cand_questions = bot.eval(question, topn=topn)
        for i, q in enumerate(cand_questions):
            result_df['top' + str(i)].append(q)

    result_df['input'] = questions
    result_df['model'] = ['my_model' for i in range(len(questions))]

    eval_data = pd.DataFrame(result_df)
    eval_data.to_csv('./data/eval_data.csv')

    print('finished create eval data')
Ejemplo n.º 4
0
def gameFrame(window, stack):
    clerkDialogManager = DialogManager('redneck')
    diag = DialogFrame(stack, window, clerkDialogManager, playerImage='media/avatars/protag.png', npcImage='media/avatars/notnigel.png')
    b = Board((20,20))

    for x in range(0,20):
        for y in range(0,20):
            b.spaces[x][y] = Tile('media/tiles/basic.png', [])

    p = Player(20, 10, None, None, None, 4)
    p.enableRender()
    b.placeEntity(p, 3, 4)
    b.placeEntity(Clerk(20, 10, None, diag), 5,5)

    return GameplayFrame(stack, window, b, p)
Ejemplo n.º 5
0
 def interact(self, board, stack, window):
     self.interactTime = self.speed
     ispace = super(Player, self).interact(board)
     if ispace:
         for entity in ispace.contents:
             if isinstance(entity, Creature):
                 self.attack(entity, board)
             if isinstance(entity, Clerk):
                 clerkDialogManager = DialogManager(entity.conversation)
                 stack.append(
                     DialogFrame(
                         stack,
                         window,
                         clerkDialogManager,
                         playerImage='media/avatars/prot_shitty.png',
                         npcImage='media/avatars/never_use.png'))
Ejemplo n.º 6
0
        if self.npcImage != None:
            self.window.blit(self.npcImage, self.npcPosition)

        if self.playerImage != None:
            self.window.blit(self.playerImage, self.playerPosition)

    def update(self):
        super(DialogFrame, self).update()


if __name__ == '__main__':
    pygame.init()
    fpsClock = pygame.time.Clock()
    window = pygame.display.set_mode((600, 600))
    pygame.display.set_caption('72 --- dialogTest')

    manager = DialogManager('countergirl')

    frame = DialogFrame(None,
                        window,
                        manager,
                        npcImage='media/avatars/never_use.png',
                        playerImage='media/avatars/prot_shitty.png')

    while True:
        window.fill(pygame.Color(255, 255, 255))
        if not runStack([frame]):
            break
        pygame.display.update()
        fpsClock.tick(30)
Ejemplo n.º 7
0
@Version :   1.0
@Desc    :   None
'''

from dialogue import DialogManager
from flask import Flask, render_template, request


app = Flask(__name__, static_folder='templates', static_url_path='')


# 因为在使用sklearn tf-idf模型使用时自定义了分词方法, pickle load时需要该方法在__main__空间中
def split_func(s): return s.split()


bot = DialogManager()


@app.route('/api/chat', methods=['GET'])
def chat():
    query = request.args.get('message')
    print(query)
    output = bot.get_answer(query)
    return output


@app.route('/')
def main():
    return render_template('index.html')