[{"data":1,"prerenderedAt":555},["ShallowReactive",2],{"i-lucide:menu":3,"i-lucide:arrow-up-right":8,"i-lucide:moon":10,"i-lucide:sun":12,"i-lucide:rss":14,"i-simple-icons:github":16,"i-simple-icons:linkedin":18,"post-\u002F2010\u002Fchatting-with-a-chatterbot-ai-in-python":21,"surround-\u002F2010\u002Fchatting-with-a-chatterbot-ai-in-python":58,"i-lucide:arrow-left":67,"i-lucide:arrow-right":69,"gist-2656913":71},{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":7},0,24,false,"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 5h16M4 12h16M4 19h16\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":9},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M7 7h10v10M7 17L17 7\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":11},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":13},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Ccircle cx=\"12\" cy=\"12\" r=\"4\"\u002F>\u003Cpath d=\"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":15},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M4 11a9 9 0 0 1 9 9M4 4a16 16 0 0 1 16 16\"\u002F>\u003Ccircle cx=\"5\" cy=\"19\" r=\"1\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":17},"\u003Cpath fill=\"currentColor\" d=\"M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":19,"hidden":20},"\u003Cpath fill=\"currentColor\" d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037c-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85c3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.06 2.06 0 0 1-2.063-2.065a2.064 2.064 0 1 1 2.063 2.065m1.782 13.019H3.555V9h3.564zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0z\"\u002F>",true,{"id":22,"title":23,"body":24,"category":39,"comments":40,"date":41,"description":30,"excerpt":40,"extension":42,"image":40,"meta":43,"navigation":20,"path":44,"readingTime":45,"seo":46,"stem":47,"subtitle":40,"tags":48,"wordCount":56,"__hash__":57},"posts\u002F2010\u002Fchatting-with-a-chatterbot-ai-in-python.md","Chatting with a ChatterBot AI in Python",{"type":25,"value":26,"toc":35},"minimark",[27,31],[28,29,30],"p",{},"Have a conversation with a PandaBot AI!",[32,33],"gist",{"id":34},"2656913",{"title":36,"searchDepth":37,"depth":37,"links":38},"",2,[],"Projects",null,"2010-07-22","md",{},"\u002F2010\u002Fchatting-with-a-chatterbot-ai-in-python","less than 1 minute",{"title":23,"description":30},"2010\u002Fchatting-with-a-chatterbot-ai-in-python",[49,50,51,52,53,54,55],"python","ai","api","chat","chatterbot","pandabot","xml",9,"An8_I1KWkB9Mzex8U7PSNn1vuSO0kKixxdxYFQrw1rA",[59,63],{"title":60,"path":61,"stem":62,"children":-1},"The most brilliant python script ever written","\u002F2010\u002Fthe-most-brilliant-python-script-ever-written","2010\u002Fthe-most-brilliant-python-script-ever-written",{"title":64,"path":65,"stem":66,"children":-1},"Talky-AI","\u002F2010\u002Fchatty-ai","2010\u002Fchatty-ai",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":68},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m12 19l-7-7l7-7m7 7H5\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":70},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 12h14m-7-7l7 7l-7 7\"\u002F>",{"id":72,"title":73,"body":74,"createdAt":546,"description":36,"extension":42,"files":547,"gistId":34,"meta":548,"navigation":20,"owner":549,"path":550,"seo":551,"stem":552,"url":553,"__hash__":554},"gists\u002Fgists\u002F2656913.md","Have a conversation with a PandaBot AI",{"type":25,"value":75,"toc":544},[76,540],[77,78,82],"pre",{"className":79,"code":80,"filename":81,"language":49,"meta":36,"style":36},"language-python shiki shiki-themes github-light github-dark","#!\u002Fusr\u002Fbin\u002Fpython -tt\n\n# Have a conversation with a PandaBot AI\n# Author A.Roots\n\nimport urllib, urllib2\nimport sys\nfrom xml.dom import minidom\nfrom xml.sax.saxutils import unescape\n\ndef main():\n  \n  human_input = raw_input('You: ')\n  if human_input == 'exit':\n    sys.exit(0)\n  \n  base_url = 'http:\u002F\u002Fwww.pandorabots.com\u002Fpandora\u002Ftalk-xml'\n  data = urllib.urlencode([('botid', 'ebbf27804e3458c5'), ('input', human_input)])\n  \n  # Submit POST data and download response XML\n  req = urllib2.Request(base_url)\n  fd = urllib2.urlopen(req, data)\n  \n  # Take Bot's response out of XML\n  xmlFile = fd.read()\n  dom = minidom.parseString(xmlFile)\n  objektid = dom.getElementsByTagName('that')\n  bot_response = objektid[0].toxml()\n  bot_response = bot_response[6:]\n  bot_response = bot_response[:-7]\n  # Some nasty unescaping\n  bot_response = unescape(bot_response, {\"&amp;apos;\": \"'\", \"&amp;quot;\": '\"'})\n  \n  print 'Getter:',str(bot_response)\n  \n  # Repeat until terminated\n  while 1:\n    main()\n\nif __name__ == '__main__':\n  print 'Hi. You can now talk to Getter. Type \"exit\" when done.'\n  main()\n","chatty.py",[83,84,85,94,99,105,111,116,127,135,149,161,166,179,185,208,226,238,243,254,283,288,294,305,316,321,326,337,348,364,380,396,415,421,453,458,476,481,487,498,504,509,526,534],"code",{"__ignoreMap":36},[86,87,90],"span",{"class":88,"line":89},"line",1,[86,91,93],{"class":92},"sJ8bj","#!\u002Fusr\u002Fbin\u002Fpython -tt\n",[86,95,96],{"class":88,"line":37},[86,97,98],{"emptyLinePlaceholder":20},"\n",[86,100,102],{"class":88,"line":101},3,[86,103,104],{"class":92},"# Have a conversation with a PandaBot AI\n",[86,106,108],{"class":88,"line":107},4,[86,109,110],{"class":92},"# Author A.Roots\n",[86,112,114],{"class":88,"line":113},5,[86,115,98],{"emptyLinePlaceholder":20},[86,117,119,123],{"class":88,"line":118},6,[86,120,122],{"class":121},"szBVR","import",[86,124,126],{"class":125},"sVt8B"," urllib, urllib2\n",[86,128,130,132],{"class":88,"line":129},7,[86,131,122],{"class":121},[86,133,134],{"class":125}," sys\n",[86,136,138,141,144,146],{"class":88,"line":137},8,[86,139,140],{"class":121},"from",[86,142,143],{"class":125}," xml.dom ",[86,145,122],{"class":121},[86,147,148],{"class":125}," minidom\n",[86,150,151,153,156,158],{"class":88,"line":56},[86,152,140],{"class":121},[86,154,155],{"class":125}," xml.sax.saxutils ",[86,157,122],{"class":121},[86,159,160],{"class":125}," unescape\n",[86,162,164],{"class":88,"line":163},10,[86,165,98],{"emptyLinePlaceholder":20},[86,167,169,172,176],{"class":88,"line":168},11,[86,170,171],{"class":121},"def",[86,173,175],{"class":174},"sScJk"," main",[86,177,178],{"class":125},"():\n",[86,180,182],{"class":88,"line":181},12,[86,183,184],{"class":125},"  \n",[86,186,188,191,194,198,201,205],{"class":88,"line":187},13,[86,189,190],{"class":125},"  human_input ",[86,192,193],{"class":121},"=",[86,195,197],{"class":196},"s4XuR"," raw_input",[86,199,200],{"class":125},"(",[86,202,204],{"class":203},"sZZnC","'You: '",[86,206,207],{"class":125},")\n",[86,209,211,214,217,220,223],{"class":88,"line":210},14,[86,212,213],{"class":121},"  if",[86,215,216],{"class":125}," human_input ",[86,218,219],{"class":121},"==",[86,221,222],{"class":203}," 'exit'",[86,224,225],{"class":125},":\n",[86,227,229,232,236],{"class":88,"line":228},15,[86,230,231],{"class":125},"    sys.exit(",[86,233,235],{"class":234},"sj4cs","0",[86,237,207],{"class":125},[86,239,241],{"class":88,"line":240},16,[86,242,184],{"class":125},[86,244,246,249,251],{"class":88,"line":245},17,[86,247,248],{"class":125},"  base_url ",[86,250,193],{"class":121},[86,252,253],{"class":203}," 'http:\u002F\u002Fwww.pandorabots.com\u002Fpandora\u002Ftalk-xml'\n",[86,255,257,260,262,265,268,271,274,277,280],{"class":88,"line":256},18,[86,258,259],{"class":125},"  data ",[86,261,193],{"class":121},[86,263,264],{"class":125}," urllib.urlencode([(",[86,266,267],{"class":203},"'botid'",[86,269,270],{"class":125},", ",[86,272,273],{"class":203},"'ebbf27804e3458c5'",[86,275,276],{"class":125},"), (",[86,278,279],{"class":203},"'input'",[86,281,282],{"class":125},", human_input)])\n",[86,284,286],{"class":88,"line":285},19,[86,287,184],{"class":125},[86,289,291],{"class":88,"line":290},20,[86,292,293],{"class":92},"  # Submit POST data and download response XML\n",[86,295,297,300,302],{"class":88,"line":296},21,[86,298,299],{"class":125},"  req ",[86,301,193],{"class":121},[86,303,304],{"class":125}," urllib2.Request(base_url)\n",[86,306,308,311,313],{"class":88,"line":307},22,[86,309,310],{"class":125},"  fd ",[86,312,193],{"class":121},[86,314,315],{"class":125}," urllib2.urlopen(req, data)\n",[86,317,319],{"class":88,"line":318},23,[86,320,184],{"class":125},[86,322,323],{"class":88,"line":5},[86,324,325],{"class":92},"  # Take Bot's response out of XML\n",[86,327,329,332,334],{"class":88,"line":328},25,[86,330,331],{"class":125},"  xmlFile ",[86,333,193],{"class":121},[86,335,336],{"class":125}," fd.read()\n",[86,338,340,343,345],{"class":88,"line":339},26,[86,341,342],{"class":125},"  dom ",[86,344,193],{"class":121},[86,346,347],{"class":125}," minidom.parseString(xmlFile)\n",[86,349,351,354,356,359,362],{"class":88,"line":350},27,[86,352,353],{"class":125},"  objektid ",[86,355,193],{"class":121},[86,357,358],{"class":125}," dom.getElementsByTagName(",[86,360,361],{"class":203},"'that'",[86,363,207],{"class":125},[86,365,367,370,372,375,377],{"class":88,"line":366},28,[86,368,369],{"class":125},"  bot_response ",[86,371,193],{"class":121},[86,373,374],{"class":125}," objektid[",[86,376,235],{"class":234},[86,378,379],{"class":125},"].toxml()\n",[86,381,383,385,387,390,393],{"class":88,"line":382},29,[86,384,369],{"class":125},[86,386,193],{"class":121},[86,388,389],{"class":125}," bot_response[",[86,391,392],{"class":234},"6",[86,394,395],{"class":125},":]\n",[86,397,399,401,403,406,409,412],{"class":88,"line":398},30,[86,400,369],{"class":125},[86,402,193],{"class":121},[86,404,405],{"class":125}," bot_response[:",[86,407,408],{"class":121},"-",[86,410,411],{"class":234},"7",[86,413,414],{"class":125},"]\n",[86,416,418],{"class":88,"line":417},31,[86,419,420],{"class":92},"  # Some nasty unescaping\n",[86,422,424,426,428,431,434,437,440,442,445,447,450],{"class":88,"line":423},32,[86,425,369],{"class":125},[86,427,193],{"class":121},[86,429,430],{"class":125}," unescape(bot_response, {",[86,432,433],{"class":203},"\"&amp;apos;\"",[86,435,436],{"class":125},": ",[86,438,439],{"class":203},"\"'\"",[86,441,270],{"class":125},[86,443,444],{"class":203},"\"&amp;quot;\"",[86,446,436],{"class":125},[86,448,449],{"class":203},"'\"'",[86,451,452],{"class":125},"})\n",[86,454,456],{"class":88,"line":455},33,[86,457,184],{"class":125},[86,459,461,464,467,470,473],{"class":88,"line":460},34,[86,462,463],{"class":234},"  print",[86,465,466],{"class":203}," 'Getter:'",[86,468,469],{"class":125},",",[86,471,472],{"class":234},"str",[86,474,475],{"class":125},"(bot_response)\n",[86,477,479],{"class":88,"line":478},35,[86,480,184],{"class":125},[86,482,484],{"class":88,"line":483},36,[86,485,486],{"class":92},"  # Repeat until terminated\n",[86,488,490,493,496],{"class":88,"line":489},37,[86,491,492],{"class":121},"  while",[86,494,495],{"class":234}," 1",[86,497,225],{"class":125},[86,499,501],{"class":88,"line":500},38,[86,502,503],{"class":125},"    main()\n",[86,505,507],{"class":88,"line":506},39,[86,508,98],{"emptyLinePlaceholder":20},[86,510,512,515,518,521,524],{"class":88,"line":511},40,[86,513,514],{"class":121},"if",[86,516,517],{"class":234}," __name__",[86,519,520],{"class":121}," ==",[86,522,523],{"class":203}," '__main__'",[86,525,225],{"class":125},[86,527,529,531],{"class":88,"line":528},41,[86,530,463],{"class":234},[86,532,533],{"class":203}," 'Hi. You can now talk to Getter. Type \"exit\" when done.'\n",[86,535,537],{"class":88,"line":536},42,[86,538,539],{"class":125},"  main()\n",[541,542,543],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":37,"depth":37,"links":545},[],"2012-05-11T01:20:15Z",[81],{},"anroots","\u002Fgists\u002F2656913",{"title":73,"description":36},"gists\u002F2656913","https:\u002F\u002Fgist.github.com\u002Fanroots\u002F2656913","WBek4jL6QPf1Q59_0PlIFaLkw4RE_FW3sGMyIAzebuQ",1790886933901]