def process_text(): search_string = request.args['text'] if not search_string.strip(): return 'No text!' else: chunks = search.split_text(search_string) try: return '\n'.join( [str(search.get_results(chunk)) for chunk in chunks]) except Exception as e: return 'An error occured: %s \n Please try again later' % repr(e)
def search(searchstring): # results = pagerank.search(searchstring) # titles = [e[0] for e in results] # results = wikipedia.search(searchstring) # titles = [e for e in results] print 'running get_results' results = get_results(searchstring.split()) titles = [e[0] for e in results] print(titles) return "|".join([",".join(get_wiki_link(title)) for title in titles])
def index(): # app.logger.debug("hit") if request.method == 'GET': try: results=search.get_results(request.args.get('search')) a_variable = results query="You searched for: "+request.args.get('search') app.logger.debug(a_variable) except: query="" a_variable='' return render_template('index.html', a_variable=a_variable, query=query)
def index(): query = request.form['query'] start_time = time.time() # processed_query = remove_duplicates(stem_query(query)) processed_query = stem_query(query, idf_dict) info = get_results(tfidf_dict, processed_query) searchTime = time.time() - start_time info = [url_dict[x] for x in info] return render_template("index.html", url_list=info, search_time=searchTime, hidden="")
def google_command(self, protocol, caller, source, command, raw_args, parsed_args): if len(parsed_args) < 1: caller.respond("Usage: {CHARS}%s [:page] <query>" % command) page = 0 query = raw_args if len(parsed_args) > 1: if parsed_args[0].startswith(":"): try: page = int(parsed_args[0][1:]) - 1 except Exception: pass else: query = " ".join(raw_args.split(" ")[1:]) d = get_results(query, page, self.num_results) d.addCallback(self.google_response_callback, protocol, caller, source) d.addErrback(self.google_response_callback_failed, protocol, caller, source)
def nosvd(): if request.method == 'POST': datafromjs = request.form['mydata'] return json.dumps(get_results(datafromjs, A, base_words))
def features(self): results = get_results(self.context, self.request) for brain in results: yield BrainPlacemark(brain, self.request, self)