def rifu(): global pre_append global keywords print "starting time:", now = datetime.datetime.now() print datetime.time(now.hour, now.minute, now.second) url = request.args.get('url', 0, type=str) #SCRAPE print "URL:"+url text = scrape.scrapePage(url) print text #GET KEYWORDS obj = get_keywords.proper_noun() keywords = obj.keywords(url,text) #GET CONTEXT #nearbywordsObj = getnearbywords_intokens.getnearbywords() #results = nearbywordsObj.get_words_from_proximity(keywords,text) #GET SEARCH RESULTS results ="" results = search.search_web(keywords,results,0,4) pre_append = results results +='{"test":"dummy_res"}' #Add dummy result for comma after last result results += "]}" print "\n\ntokenize :\n\n"+results return results
def get_rem_results(): global pre_append global keywords global doc_freq global url print "\n\nGETTING NEXT RESULTS SOON....." print "\nPREVIOUS RES:" #print pre_append results = pre_append results = search.search_web(doc_freq, results, 4, len(doc_freq), url) ############################ #import pdb;pdb.set_trace(); tab_id = request.args.get('tab_id', 0, type=int) results += '{"tab_id":' + str( tab_id) + '}' #Add dummy result for comma after last result results += "]}" #print results print "\n\nDONE HERE..PLEASE SEE THE BROWSER" print "\nkeywords::" + str(len(keywords)) print keywords return results
def process_message(payload): """ dict -> None Processes a Slack message. """ data = payload['data'] # Ensure the bot isn't responding to itself or messages without text (i.e. link-only messages) if 'subtype' in data and data[ 'subtype'] == 'bot_message' or 'text' not in data: return web_client = payload['web_client'] channel = data['channel'] message = data['text'] _input = re.split(r'\s+', message) command = _input[0].lower() if not command.startswith('!'): return arguments = _input[1:] if command == '!help': send_message(help_message, channel, web_client) elif command == '!search': try: website = arguments[0].lower() query = ' '.join(arguments[1:]) if website in website_map: website = website_map[website] elif website.split('|')[1][:-1] in list(website_map.values()): website = website.split('|')[1][:-1] elif website not in list(website_map.values()): send_message('Website or acronym not supported!', channel, web_client) return except: send_message( 'Invalid arguments. Type !help for assistance with this command.', channel, web_client) return send_message('\n'.join(search.search_web(website, query, 3)), channel, web_client) else: matches = difflib.get_close_matches(command, available_commands) if not matches or len(matches) > 1 or matches[0] == '!help': send_message( "I don't recognize that command. Type in '!help' for a list of available commands.", channel, web_client) else: send_message( "I don't recognize that command. Did you mean " + matches[0] + "? If not, type in '!help' for a list of available commands.", channel, web_client)
def get_rem_results(): global pre_append global keywords print "\n\nGETTING NEXT RESULTS SOON....." print "\nPREVIOUS RES:" print pre_append results = pre_append results = search.search_web(keywords,results,4,len(keywords)) results +='{"test":"dummy_res"}' #Add dummy result for comma after last result results += "]}" print "\n\nget remaining result :\n\n"+results print "\n\nDONE HERE..PLEASE SEE THE BROWSER" return results
def rifu(): global pre_append global keywords global doc_freq global url print "starting time:", now = datetime.datetime.now() print datetime.time(now.hour, now.minute, now.second) url = request.args.get('url', 0, type=str) #webpage = urllib2.urlopen(url).read() #para= re.compile('<p>(.*)</p>') #collect data in p tags and store in para object # raw = re.findall(para , webpage) # rawstr = ' '.join(raw) # text = tokenize(rawstr) #SCRAPE print "URL:" + url text = scrape.scrapePage(url) print "\nScraping Done" print text #GET KEYWORDS keywords = keywords_file.get_keywords(url, text) print "my keywords:::" print keywords #GET CONTEXT nearbywordsObj = getnearbywords_intokens.getnearbywords() doc_freq = nearbywordsObj.get_words_from_proximity(keywords, text) # import pdb;pdb.set_trace(); print "doc freq::::" + str(doc_freq) #GET SEARCH RESULTS results = "" results = search.search_web(doc_freq, results, 0, 4, url) pre_append = results tab_id = request.args.get('tab_id', 0, type=int) results += '{"tab_id":' + str( tab_id) + '}' #Add dummy result for comma after last result results += "]}" print results return results
def rifu(): global pre_append global keywords global doc_freq global url print "starting time:", now = datetime.datetime.now() print datetime.time(now.hour, now.minute, now.second) url = request.args.get('url', 0, type=str) #webpage = urllib2.urlopen(url).read() #para= re.compile('<p>(.*)</p>') #collect data in p tags and store in para object # raw = re.findall(para , webpage) # rawstr = ' '.join(raw) # text = tokenize(rawstr) #SCRAPE print "URL:"+url text = scrape.scrapePage(url) print "\nScraping Done" print text #GET KEYWORDS keywords = keywords_file.get_keywords(url,text) print "my keywords:::" print keywords #GET CONTEXT nearbywordsObj = getnearbywords_intokens.getnearbywords() doc_freq = nearbywordsObj.get_words_from_proximity(keywords,text) # import pdb;pdb.set_trace(); print "doc freq::::"+ str(doc_freq) #GET SEARCH RESULTS results ="" results = search.search_web(doc_freq,results,0,4,url) pre_append = results tab_id = request.args.get('tab_id',0,type=int) results +='{"tab_id":'+str(tab_id)+'}' #Add dummy result for comma after last result results += "]}" print results return results
def get_rem_results(): global pre_append global keywords global doc_freq global url print "\n\nGETTING NEXT RESULTS SOON....." print "\nPREVIOUS RES:" #print pre_append results = pre_append results = search.search_web(doc_freq,results,4,len(doc_freq),url) ############################ #import pdb;pdb.set_trace(); tab_id = request.args.get('tab_id',0,type=int) results +='{"tab_id":'+str(tab_id)+'}' #Add dummy result for comma after last result results += "]}" #print results print "\n\nDONE HERE..PLEASE SEE THE BROWSER" print "\nkeywords::"+str(len(keywords)) print keywords return results
def process_text(text): try: if 'web' in text.lower() or 'play' in text.lower(): search.search_web(text) elif "who are you" in text.lower() or "define yourself" in text.lower( ): speak = 'HELLO I AM JARVIS YOUR PERSONAL ASSISTANT' assistant_speakes(speak) elif "who made you" in text.lower() or "created you" in text.lower(): speak = "I have been created by master Henish." assistant_speakes(speak) elif 'open' in text.lower(): calc.open_application(text) elif 'date' in text.lower() or 'today date' in text.lower(): date = datetime.datetime.date().today() assistant_speakes(date) elif 'time' in text.lower() or 'current time' in text.lower( ) or 'what is time' in text.lower(): time = datetime.datetime.today().time().replace(microsecond=0) assistant_speakes(time) else: assistant_speakes( "I can search the web for you , Do you want to continue?") ans = get_audio() if 'yes' in str(ans) or 'yeah' in str(ans): search.search_web(text) else: exit() except: assistant_speakes( "I don't understand, I can search the web for you, Do you want to continue?" ) ans = get_audio() if 'yes' in str(ans) or 'yeah' in str(ans): search.search_web(text)
def AssistantSkill(cmd): try: if vision.split(cmd) in web_dict: search.search_web(cmd) return elif cmd in media_toggle[0]: vision.speak("opening your music player") mediaplayer.music() return elif cmd in media_toggle[1]: vision.speak("opening your video player") mediaplayer.video() return elif 'send email' in cmd or 'sent mail' in cmd: mail.mail() return elif "who are you" in cmd or "define yourself" in cmd: speaks = '''Hello, I am Person. Your personal Assistant. I am here to make your life easier. You can command me to perform various tasks such as calculating sums or opening applications etc ''' vision.speak(speaks) return elif "who made you" in cmd or "created you" in cmd: speaks = "I have been created by Developer." vision.speak(speaks) return elif "calculate" in cmd.lower(): wolframalph.WolframSkills(cmd) return elif cmd in frequent[1]: date_time.tell_the_date() return elif cmd in frequent[0]: date_time.tell_the_time() return elif cmd in system_toggle: systeminfo.SystemInfo() return elif 'network speed' in cmd: netinfo.Speed() return elif 'check internet connection' in cmd: netinfo.InternetConnection() return elif 'open' in cmd: desktopapps.open_application(cmd) return elif 'close' in cmd: desktopapps.close_application(cmd) return elif 'news' in cmd: news.news(cmd) return elif "weather" in cmd: weather.main(cmd) return elif cmd in whereAbouts: location.location() return elif "shutdown" in cmd: os.system("shutdown /s /t 1") return elif "restart" in cmd: os.system("shutdown /r /t 1") return else: vision.speak("Please check my skill listed in info file...") return except Exception as e: vision.speak(e) return