Advertisement
CaptainLepidus

parse(text)

Apr 26th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. def parse(text):
  2.     reply = "Hello"
  3.     rep = "Hi,Hello,Hey->Hello.,Hi.,Hey!|Can you,Will you,Do you>If you like.".split("|")
  4.     for i in range(len(rep)):
  5.         part1,_,part2 = rep[i].partition(">")
  6.         pos = part1.split(",")
  7.         for j in range(len(pos)):
  8.             tmp = pos[j]
  9.             if tmp[0:len(tmp)]==text[0:len(tmp)]:
  10.                 reply = random.choice(part2.split(","))
  11.     return reply
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement