repl.it
@anonymous/

RedundantGregariousComments

Python

No description

fork
loading
Files
  • main.py
  • chat.csv
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#coding: utf-8

import csv
from nltk.chat.util import Chat, reflections
pairs = []
with open('chat.csv', newline='') as File:  
  reader = csv.reader(File, delimiter=';')
  for linha in reader:
    add = [
      r"{}".format(linha[0]), # Expressão regular
      [] # Resposta
    ]
    # Adiciona cada resposta na lista
    for x in linha[1].split('|'): add[1].append(x)
    # Adiciona "add" em "pairs"
    pairs.append(add)

def bob_bot(): 
    print("Como posso te ajudar hoje?") 
    chat = Chat(pairs, reflections) 
    chat.converse() 

if __name__ == "__main__": 
    bob_bot()